From dd1a341da72ce98193997a79f864abbed4468260 Mon Sep 17 00:00:00 2001 From: rockwellll Date: Sat, 11 Apr 2026 20:02:50 +0300 Subject: [PATCH] Use payload fingerprints for identify dedupe --- __tests__/hellotext_test.js | 116 ++++++++++++++++++++++++--- __tests__/models/fingerprint_test.js | 96 ++++++++++++++++++++++ __tests__/models/user_test.js | 26 ++++-- dist/hellotext.js | 2 +- index.d.ts | 3 +- lib/hellotext.cjs | 15 ++-- lib/hellotext.js | 15 ++-- lib/models/fingerprint.cjs | 89 ++++++++++++++++++++ lib/models/fingerprint.js | 101 +++++++++++++++++++++++ lib/models/index.cjs | 7 ++ lib/models/index.js | 1 + lib/models/user.cjs | 11 ++- lib/models/user.js | 11 ++- src/hellotext.js | 22 +++-- src/models/fingerprint.js | 98 ++++++++++++++++++++++ src/models/index.js | 1 + src/models/user.js | 11 ++- 17 files changed, 588 insertions(+), 37 deletions(-) create mode 100644 __tests__/models/fingerprint_test.js create mode 100644 lib/models/fingerprint.cjs create mode 100644 lib/models/fingerprint.js create mode 100644 src/models/fingerprint.js diff --git a/__tests__/hellotext_test.js b/__tests__/hellotext_test.js index 7b19637..b78820c 100644 --- a/__tests__/hellotext_test.js +++ b/__tests__/hellotext_test.js @@ -1,5 +1,5 @@ import Hellotext from "../src/hellotext"; -import { Business } from "../src/models"; +import { Business, Session } from "../src/models"; const getCookieValue = name => document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)')?.pop() @@ -264,6 +264,7 @@ describe("when the class is initialized successfully", () => { // Clear identification cookies document.cookie = "hello_user_id=;expires=Thu, 01 Jan 1970 00:00:00 GMT" document.cookie = "hello_user_source=;expires=Thu, 01 Jan 1970 00:00:00 GMT" + document.cookie = "hello_user_identification_hash=;expires=Thu, 01 Jan 1970 00:00:00 GMT" }) it("sends correct request body with user and options", async () => { @@ -312,6 +313,7 @@ describe("when the class is initialized successfully", () => { expect(response.succeeded).toEqual(true) expect(getCookieValue("hello_user_id")).toEqual("user_456") expect(getCookieValue("hello_user_source")).toEqual("woocommerce") + expect(getCookieValue("hello_user_identification_hash")).toMatch(/^v1:/) }) it("does not set cookies when identification fails", async () => { @@ -329,6 +331,7 @@ describe("when the class is initialized successfully", () => { expect(response.failed).toEqual(true) expect(getCookieValue("hello_user_id")).toBeUndefined() expect(getCookieValue("hello_user_source")).toBeUndefined() + expect(getCookieValue("hello_user_identification_hash")).toBeUndefined() }) it("works with minimal options (only user id)", async () => { @@ -388,30 +391,125 @@ describe("when the class is initialized successfully", () => { expect(requestBody).toHaveProperty('session', 'test_session') }) - it("skips API call when user is already identified with same ID", async () => { + it("skips API call when identify payload is unchanged", async () => { global.fetch = jest.fn().mockResolvedValue({ json: jest.fn().mockResolvedValue({received: "success"}), status: 200, ok: true }) - // First identify the user await Hellotext.identify("user_existing", { - email: "existing@example.com", - source: "shopify" + shopify: { + customer: { + email: "existing@example.com", + phone: "+1234567890", + }, + domain: "example.myshopify.com", + }, + tags: ["vip", "repeat"], + source: "shopify", }) expect(global.fetch).toHaveBeenCalledTimes(1) - // Try to identify with the same ID again const response = await Hellotext.identify("user_existing", { - email: "different@example.com", - source: "woocommerce" + tags: ["vip", "repeat"], + shopify: { + domain: "example.myshopify.com", + customer: { + phone: "+1234567890", + email: "existing@example.com", + }, + }, + source: "shopify", }) - // Should not make another API call expect(global.fetch).toHaveBeenCalledTimes(1) expect(response.succeeded).toEqual(true) }) + + it("does not skip API call when identify options change for the same user", async () => { + global.fetch = jest.fn().mockResolvedValue({ + json: jest.fn().mockResolvedValue({received: "success"}), + status: 200, + ok: true + }) + + await Hellotext.identify("user_existing", { + email: "existing@example.com", + source: "shopify" + }) + + await Hellotext.identify("user_existing", { + email: "existing@example.com", + phone: "+1234567890", + source: "shopify" + }) + + expect(global.fetch).toHaveBeenCalledTimes(2) + }) + + it("does not skip API call when array order changes", async () => { + global.fetch = jest.fn().mockResolvedValue({ + json: jest.fn().mockResolvedValue({received: "success"}), + status: 200, + ok: true + }) + + await Hellotext.identify("user_existing", { + tags: ["vip", "repeat"], + source: "shopify" + }) + + await Hellotext.identify("user_existing", { + tags: ["repeat", "vip"], + source: "shopify" + }) + + expect(global.fetch).toHaveBeenCalledTimes(2) + }) + + it("does not skip API call when the session changes", async () => { + global.fetch = jest.fn().mockResolvedValue({ + json: jest.fn().mockResolvedValue({received: "success"}), + status: 200, + ok: true + }) + + await Hellotext.identify("user_existing", { + email: "existing@example.com", + source: "shopify" + }) + + Session.session = "new_session" + global.fetch.mockClear() + + await Hellotext.identify("user_existing", { + email: "existing@example.com", + source: "shopify" + }) + + expect(global.fetch).toHaveBeenCalledTimes(1) + expect(JSON.parse(global.fetch.mock.calls[0][1].body)).toHaveProperty('session', 'new_session') + }) + + it("sends once for legacy cookies without a fingerprint and seeds it afterward", async () => { + global.fetch = jest.fn().mockResolvedValue({ + json: jest.fn().mockResolvedValue({received: "success"}), + status: 200, + ok: true + }) + + document.cookie = "hello_user_id=user_existing" + document.cookie = "hello_user_source=shopify" + + await Hellotext.identify("user_existing", { + email: "existing@example.com", + source: "shopify" + }) + + expect(global.fetch).toHaveBeenCalledTimes(1) + expect(getCookieValue("hello_user_identification_hash")).toMatch(/^v1:/) + }) }) }); diff --git a/__tests__/models/fingerprint_test.js b/__tests__/models/fingerprint_test.js new file mode 100644 index 0000000..4876875 --- /dev/null +++ b/__tests__/models/fingerprint_test.js @@ -0,0 +1,96 @@ +/** + * @jest-environment jsdom + */ + +import { Fingerprint } from '../../src/models' + +describe('Fingerprint', () => { + it('matches when nested object keys are reordered', async () => { + const storedFingerprint = await Fingerprint.generate('session_123', 'user_123', { + tags: ['vip', 'repeat'], + shopify: { + customer: { + email: 'customer@example.com', + phone: '+1234567890', + }, + domain: 'example.myshopify.com', + }, + }) + + const fingerprint = await Fingerprint.generate('session_123', 'user_123', { + shopify: { + domain: 'example.myshopify.com', + customer: { + phone: '+1234567890', + email: 'customer@example.com', + }, + }, + tags: ['vip', 'repeat'], + }) + + expect( + Fingerprint.matches(storedFingerprint, fingerprint), + ).toEqual(true) + }) + + it('does not match when array order changes', async () => { + const storedFingerprint = await Fingerprint.generate('session_123', 'user_123', { + tags: ['vip', 'repeat'], + }) + + const fingerprint = await Fingerprint.generate('session_123', 'user_123', { + tags: ['repeat', 'vip'], + }) + + expect( + Fingerprint.matches(storedFingerprint, fingerprint), + ).toEqual(false) + }) + + it('treats blank strings as omitted values', async () => { + const storedFingerprint = await Fingerprint.generate('session_123', 'user_123', { + email: 'customer@example.com', + phone: '', + shopify: { + domain: 'example.myshopify.com', + }, + }) + + const fingerprint = await Fingerprint.generate('session_123', 'user_123', { + shopify: { + domain: 'example.myshopify.com', + }, + email: 'customer@example.com', + }) + + expect( + Fingerprint.matches(storedFingerprint, fingerprint), + ).toEqual(true) + }) + + it('does not match when the session changes', async () => { + const storedFingerprint = await Fingerprint.generate('session_123', 'user_123', { + email: 'customer@example.com', + }) + + const fingerprint = await Fingerprint.generate('session_456', 'user_123', { + email: 'customer@example.com', + }) + + expect( + Fingerprint.matches(storedFingerprint, fingerprint), + ).toEqual(false) + }) + + it('does not match when the stored fingerprint is missing', async () => { + const fingerprint = await Fingerprint.generate('session_123', 'user_123', { + shopify: { + domain: 'example.myshopify.com', + }, + }) + + expect( + Fingerprint.matches(undefined, fingerprint), + ).toEqual(false) + }) +}) diff --git a/__tests__/models/user_test.js b/__tests__/models/user_test.js index 0b67700..b08122f 100644 --- a/__tests__/models/user_test.js +++ b/__tests__/models/user_test.js @@ -7,6 +7,7 @@ import { Cookies, User } from '../../src/models' beforeEach(() => { document.cookie = 'hello_user_id=;expires=Thu, 01 Jan 1970 00:00:00 GMT' document.cookie = 'hello_user_source=;expires=Thu, 01 Jan 1970 00:00:00 GMT' + document.cookie = 'hello_user_identification_hash=;expires=Thu, 01 Jan 1970 00:00:00 GMT' jest.clearAllMocks() }) @@ -33,12 +34,24 @@ describe('User', () => { }) }) + describe('fingerprint', () => { + it('returns undefined when not set', () => { + expect(User.fingerprint).toBeUndefined() + }) + + it('returns the fingerprint from cookie', () => { + Cookies.set('hello_user_identification_hash', 'v1:fingerprint') + expect(User.fingerprint).toEqual('v1:fingerprint') + }) + }) + describe('remember', () => { - it('sets both user_id and source when both provided', () => { - User.remember('user_123', 'shopify') + it('sets user_id, source, and fingerprint when all are provided', () => { + User.remember('user_123', 'shopify', 'v1:fingerprint') expect(User.id).toEqual('user_123') expect(User.source).toEqual('shopify') + expect(User.fingerprint).toEqual('v1:fingerprint') }) it('sets only user_id when source is falsy', () => { @@ -46,24 +59,27 @@ describe('User', () => { expect(User.id).toEqual('user_456') expect(User.source).toBeUndefined() + expect(User.fingerprint).toBeUndefined() }) it('updates existing cookies', () => { - User.remember('user_old', 'shopify') - User.remember('user_new', 'woocommerce') + User.remember('user_old', 'shopify', 'v1:old') + User.remember('user_new', 'woocommerce', 'v1:new') expect(User.id).toEqual('user_new') expect(User.source).toEqual('woocommerce') + expect(User.fingerprint).toEqual('v1:new') }) }) describe('forget', () => { it('removes user cookies', () => { - User.remember('user_789', 'shopify') + User.remember('user_789', 'shopify', 'v1:fingerprint') User.forget() expect(User.id).toBeUndefined() expect(User.source).toBeUndefined() + expect(User.fingerprint).toBeUndefined() }) it('does not throw when no cookies exist', () => { diff --git a/dist/hellotext.js b/dist/hellotext.js index 084c0b8..6276a84 100644 --- a/dist/hellotext.js +++ b/dist/hellotext.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hellotext=t():e.Hellotext=t()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={599:(e,t,n)=>{n.d(t,{Mx:()=>J,Qr:()=>ie});class r{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort(((e,t)=>{const n=e.index,r=t.index;return nr?1:0}))}}class i{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((e=>e.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((e=>e.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((e,t)=>e.concat(Array.from(t.values()))),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:r}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(n,r);i.delete(o),0==i.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:r}=e;return this.fetchEventListener(t,n,r)}fetchEventListener(e,t,n){const r=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,n);let o=r.get(i);return o||(o=this.createEventListener(e,t,n),r.set(i,o)),o}createEventListener(e,t,n){const i=new r(e,t,n);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach((e=>{n.push(`${t[e]?"":"!"}${e}`)})),n.join(":")}}const o={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},s=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function a(e){return e.replace(/(?:[_-])([a-z0-9])/g,((e,t)=>t.toUpperCase()))}function l(e){return a(e.replace(/--/g,"-").replace(/__/g,"_"))}function c(e){return e.charAt(0).toUpperCase()+e.slice(1)}function u(e){return e.replace(/([A-Z])/g,((e,t)=>`-${t.toLowerCase()}`))}function h(e){return null!=e}function d(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const f=["meta","ctrl","alt","shift"];class p{constructor(e,t,n,r){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in m)return m[t](e)}(e)||g("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||g("missing identifier"),this.methodName=n.methodName||g("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(s)||[];let n=t[2],r=t[3];return r&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${r}`,r=""),{eventTarget:(i=t[4],"window"==i?window:"document"==i?document:void 0),eventName:n,eventOptions:t[7]?(o=t[7],o.split(":").reduce(((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)})),{})):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||r};var i,o}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const n=t.filter((e=>!f.includes(e)))[0];return!!n&&(d(this.keyMappings,n)||g(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[n].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const i=n.match(t),o=i&&i[1];o&&(e[a(o)]=v(r))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[n,r,i,o]=f.map((e=>t.includes(e)));return e.metaKey!==n||e.ctrlKey!==r||e.altKey!==i||e.shiftKey!==o}}const m={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function g(e){throw new Error(e)}function v(e){try{return JSON.parse(e)}catch(t){return e}}class y{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application,{controller:r}=this.context;let i=!0;for(const[o,s]of Object.entries(this.eventOptions))if(o in n){const a=n[o];i=i&&a({name:o,value:s,event:e,element:t,controller:r})}return i}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:r,element:i,index:o}=this,s={identifier:n,controller:r,element:i,index:o,event:e};this.context.handleError(t,`invoking action "${this.action}"`,s)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))&&!(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class b{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class w{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new b(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function _(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class k{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e.concat(Array.from(t))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e+t.size),0)}add(e,t){!function(e,t,n){_(e,t).add(n)}(this.valuesByKey,e,t)}delete(e,t){!function(e,t,n){_(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some((t=>t.has(e)))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter((([t,n])=>n.has(e))).map((([e,t])=>e))}}class C{constructor(e,t,n,r){this._selector=t,this.details=r,this.elementObserver=new b(e,this),this.delegate=n,this.matchesByElement=new k}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const n=e.matches(t);return this.delegate.selectorMatchElement?n&&this.delegate.selectorMatchElement(e,this.details):n}return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const n=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(t)).filter((e=>this.matchElement(e)));return n.concat(r)}return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const n of t)this.selectorUnmatched(e,n)}elementAttributeChanged(e,t){const{selector:n}=this;if(n){const t=this.matchElement(e),r=this.matchesByElement.has(n,e);t&&!r?this.selectorMatched(e,n):!t&&r&&this.selectorUnmatched(e,n)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class O{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r&&this.stringMapValueChanged(r,n,t),null==r){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((e=>e.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class x{constructor(e,t,n){this.attributeObserver=new w(e,t,this),this.delegate=n,this.tokensByElement=new k}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach((e=>this.tokenMatched(e)))}tokensUnmatched(e){e.forEach((e=>this.tokenUnmatched(e)))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},((n,r)=>[e[r],t[r]]))}(t,n).findIndex((([e,t])=>{return r=t,!((n=e)&&r&&n.index==r.index&&n.content==r.content);var n,r}));return-1==r?[[],[]]:[t.slice(r),n.slice(r)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter((e=>e.length)).map(((e,r)=>({element:t,attributeName:n,content:e,index:r})))}(e.getAttribute(t)||"",e,t)}}class S{constructor(e,t,n){this.tokenListObserver=new x(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class j{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new S(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new y(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach((e=>this.delegate.bindingDisconnected(e,!0))),this.bindingsByAction.clear()}parseValueForToken(e){const t=p.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class T{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new O(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const r=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const r=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,r.writer(this.receiver[e]),n):this.invokeChangedCallback(e,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,r(n),void 0)}invokeChangedCallback(e,t,n){const r=`${e}Changed`,i=this.receiver[r];if("function"==typeof i){const r=this.valueDescriptorNameMap[e];try{const e=r.reader(t);let o=n;n&&(o=r.reader(n)),i.call(this.receiver,e,o)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map((t=>e[t]))}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach((t=>{const n=this.valueDescriptorMap[t];e[n.name]=n})),e}hasValue(e){const t=`has${c(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class E{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new k}start(){this.tokenListObserver||(this.tokenListObserver=new x(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetConnected(e,t))))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetDisconnected(e,t))))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function P(e,t){const n=M(e);return Array.from(n.reduce(((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach((t=>e.add(t))),e)),new Set))}function M(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class A{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new k,this.outletElementsByName=new k,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach((e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)})),this.started=!0,this.dependentContexts.forEach((e=>e.refresh())))}refresh(){this.selectorObserverMap.forEach((e=>e.refresh())),this.attributeObserverMap.forEach((e=>e.refresh()))}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach((e=>e.stop())),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach((e=>e.stop())),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:n}){const r=this.getOutlet(e,n);r&&this.connectOutlet(r,e,n)}selectorUnmatched(e,t,{outletName:n}){const r=this.getOutletFromMap(e,n);r&&this.disconnectOutlet(r,e,n)}selectorMatchElement(e,{outletName:t}){const n=this.selector(t),r=this.hasOutlet(e,t),i=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!n&&r&&i&&e.matches(n)}elementMatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementAttributeValueChanged(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementUnmatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}connectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletConnected(e,t,n))))}disconnectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletDisconnected(e,t,n))))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),n=new C(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,n),n.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),n=new w(this.scope.element,t,this);this.attributeObserverMap.set(e,n),n.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find((t=>this.attributeNameForOutletName(t)===e))}get outletDependencies(){const e=new k;return this.router.modules.forEach((t=>{P(t.definition.controllerConstructor,"outlets").forEach((n=>e.add(n,t.identifier)))})),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter((t=>e.includes(t.identifier)))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find((t=>t.element===e))}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class L{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:r,element:i}=this;t=Object.assign({identifier:n,controller:r,element:i},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new j(this,this.dispatcher),this.valueObserver=new T(this,this.controller),this.targetObserver=new E(this,this),this.outletObserver=new A(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:r,controller:i,element:o}=this;n=Object.assign({identifier:r,controller:i,element:o},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${l(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${l(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}const I="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,R=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e((function(){this.a.call(this)}));t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class B{constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:(t=e.controllerConstructor,function(e,t){const n=R(e),r=function(e,t){return I(t).reduce(((n,r)=>{const i=function(e,t,n){const r=Object.getOwnPropertyDescriptor(e,n);if(!r||!("value"in r)){const e=Object.getOwnPropertyDescriptor(t,n).value;return r&&(e.get=r.get||e.get,e.set=r.set||e.set),e}}(e,t,r);return i&&Object.assign(n,{[r]:i}),n}),{})}(e.prototype,t);return Object.defineProperties(n.prototype,r),n}(t,function(e){return P(e,"blessings").reduce(((t,n)=>{const r=n(e);for(const e in r){const n=t[e]||{};t[e]=Object.assign(n,r[e])}return t}),{})}(t)))};var t}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new L(this,e),this.contextsByScope.set(e,t)),t}}class F{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){return(this.data.get(this.getDataKey(e))||"").match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class N{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${u(e)}`}}class D{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let r=this.warnedKeysByObject.get(e);r||(r=new Set,this.warnedKeysByObject.set(e,r)),r.has(t)||(r.add(t),this.logger.warn(n,e))}}function z(e,t){return`[${e}~="${t}"]`}class V{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)]),[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return z(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map((t=>this.deprecate(t,e)))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return z(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,r=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${n}.${t}" with ${i}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class ${constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findOutlet(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllOutlets(t)]),[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))}matchesElement(e,t,n){const r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(n)}}class H{constructor(e,t,n,r){this.targets=new V(this),this.classes=new F(this),this.data=new N(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new D(r),this.outlets=new $(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return z(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new H(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class q{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new S(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e;return this.parseValueForElementAndIdentifier(t,n)}parseValueForElementAndIdentifier(e,t){const n=this.fetchScopesByIdentifierForElement(e);let r=n.get(t);return r||(r=this.delegate.createScopeForElementAndIdentifier(e,t),n.set(t,r)),r}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class U{constructor(e){this.application=e,this.scopeObserver=new q(this.element,this.schema,this),this.scopesByIdentifier=new k,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((e,t)=>e.concat(t.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new B(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find((t=>t.element==e))}proposeToConnectScopeForElementAndIdentifier(e,t){const n=this.scopeObserver.parseValueForElementAndIdentifier(e,t);n?this.scopeObserver.elementMatchedValue(n.element,n):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new H(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.connectContextForScope(t)))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.disconnectContextForScope(t)))}}const K={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},W("abcdefghijklmnopqrstuvwxyz".split("").map((e=>[e,e])))),W("0123456789".split("").map((e=>[e,e]))))};function W(e){return e.reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n})),{})}class J{constructor(e=document.documentElement,t=K){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=t,this.dispatcher=new i(this),this.router=new U(this),this.actionDescriptorFilters=Object.assign({},o)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise((e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)}))}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>this.router.unloadIdentifier(e)))}get controllers(){return this.router.contexts.map((e=>e.controller))}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var r;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(r=window.onerror)||void 0===r||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}function Z(e,t,n){return e.application.getControllerForElementAndIdentifier(t,n)}function G(e,t,n){let r=Z(e,t,n);return r||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,n),r=Z(e,t,n),r||void 0)}function X([e,t],n){return function(e){const{token:t,typeDefinition:n}=e,r=`${u(t)}-value`,i=function(e){const{controller:t,token:n,typeDefinition:r}=e,i=function(e){const{controller:t,token:n,typeObject:r}=e,i=h(r.type),o=h(r.default),s=i&&o,a=i&&!o,l=!i&&o,c=Y(r.type),u=Q(e.typeObject.default);if(a)return c;if(l)return u;if(c!==u)throw new Error(`The specified default value for the Stimulus Value "${t?`${t}.${n}`:n}" must match the defined type "${c}". The provided default value of "${r.default}" is of type "${u}".`);return s?c:void 0}({controller:t,token:n,typeObject:r}),o=Q(r),s=Y(r),a=i||o||s;if(a)return a;throw new Error(`Unknown value type "${t?`${t}.${r}`:n}" for "${n}" value`)}(e);return{type:i,key:r,name:a(r),get defaultValue(){return function(e){const t=Y(e);if(t)return ee[t];const n=d(e,"default"),r=d(e,"type"),i=e;if(n)return i.default;if(r){const{type:e}=i,t=Y(e);if(t)return ee[t]}return e}(n)},get hasCustomDefaultValue(){return void 0!==Q(n)},reader:te[i],writer:ne[i]||ne.default}}({controller:n,token:e,typeDefinition:t})}function Y(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Q(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const ee={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},te={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${Q(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e.replace(/_/g,"")),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${Q(t)}"`);return t},string:e=>e},ne={default:function(e){return`${e}`},array:re,object:re};function re(e){return JSON.stringify(e)}class ie{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:r=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){const s=new CustomEvent(r?`${r}:${e}`:e,{detail:n,bubbles:i,cancelable:o});return t.dispatchEvent(s),s}}ie.blessings=[function(e){return P(e,"classes").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${c(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(e){return P(e,"targets").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${c(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(e){const t=function(e,t){return M(e).reduce(((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map((e=>[e,n[e]])):[]}(n,t)),e)),[])}(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=X(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=X(e,void 0),{key:r,name:i,reader:o,writer:s}=n;return{[i]:{get(){const e=this.data.get(r);return null!==e?o(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,s(e))}},[`has${c(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t))),n)},function(e){return P(e,"outlets").reduce(((e,t)=>Object.assign(e,function(e){const t=l(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t){const n=G(this,t,e);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map((t=>{const n=G(this,t,e);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,t)})).filter((e=>e)):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${c(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t))),{})}],ie.targets=[],ie.outlets=[],ie.values={}},272:(e,t,n)=>{n.d(t,{default:()=>Go});var r=n(379),i=n.n(r),o=n(795),s=n.n(o),a=n(569),l=n.n(a),c=n(565),u=n.n(c),h=n(216),d=n.n(h),f=n(589),p=n.n(f),m=n(989),g={};g.styleTagTransform=p(),g.setAttributes=u(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=d(),i()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals;var v=n(599);function y(e,t){for(var n=0;n{var[t,n]=e;this[t]=n})),this}},{key:"shouldShowSuccessMessage",get:function(){return this.successMessage}}],null&&y(t.prototype,null),n&&y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function w(e,t){for(var n=0;ne.trim())):this._classes},set:function(e){if(!Array.isArray(e)&&"string"!=typeof e)throw new Error("classes must be an array or a string");this._classes=e}},{key:"triggerClasses",get:function(){return"string"==typeof this._triggerClasses?this._triggerClasses.split(",").map((e=>e.trim())):this._triggerClasses},set:function(e){if(!Array.isArray(e)&&"string"!=typeof e)throw new Error("triggerClasses must be an array or a string");this._triggerClasses=e}},{key:"id",get:function(){return this._id},set:function(e){this._id=e}},{key:"isSet",get:function(){return!!this._id}},{key:"style",get:function(){return this._style},set:function(e){if("object"!=typeof e)throw new Error("Style must be an object");Object.entries(e).forEach((e=>{var[t,n]=e;if(!["primaryColor","secondaryColor","typography"].includes(t))throw new Error("Invalid style property: ".concat(t));if("typography"!==t&&!this.isHexOrRgba(n))throw new Error("Invalid color value: ".concat(n," for ").concat(t,". Colors must be hex or rgb/a."))})),this._style=e}},{key:"behaviour",get:function(){return this._behaviour},set:function(e){if(!Object.values(M).includes(e))throw new Error("Invalid behaviour value: ".concat(e));this._behaviour=e}},{key:"strategy",get:function(){return this._strategy?this._strategy:"body"==this.container?P.FIXED:P.ABSOLUTE},set:function(e){if(e&&!Object.values(P).includes(e))throw new Error("Invalid strategy value: ".concat(e));this._strategy=e}},{key:"assign",value:function(e){return e&&Object.entries(e).forEach((e=>{var[t,n]=e;this[t]=n})),this}},{key:"isHexOrRgba",value:function(e){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e)||/^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(e)}}],null&&T(t.prototype,null),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function L(e,t){for(var n=0;n{var[t,n]=e;"forms"===t?this.forms=b.assign(n):"webchat"===t?this.webchat=A.assign(n):this[t]=n})),this}},{key:"locale",get:function(){return j.toString()},set:function(e){j.identifier=e}},{key:"endpoint",value:function(e){return"".concat(this.apiRoot,"/").concat(e)}}],null&&L(t.prototype,null),n&&L(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function R(e){var t="function"==typeof Map?new Map:void 0;return R=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return B(e,arguments,D(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),N(r,e)},R(e)}function B(e,t,n){return B=F()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&N(i,n.prototype),i},B.apply(null,arguments)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},N(e,t)}function D(e){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},D(e)}I.apiRoot="https://api.hellotext.com/v1",I.actionCableUrl="wss://www.hellotext.com/cable",I.autoGenerateSession=!0,I.session=null,I.forms=b,I.webchat=A;var z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&N(e,t)}(o,e);var t,n,r,i=(n=o,r=F(),function(){var e,t=D(n);if(r){var i=D(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=i.call(this,"".concat(e," is not valid. Please provide a valid event name"))).name="InvalidEvent",t}return t=o,Object.defineProperty(t,"prototype",{writable:!1}),t}(R(Error));function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $(e){for(var t=1;tt===e))}}],(n=[{key:"addSubscriber",value:function(t,n){if(e.invalid(t))throw new z(t);this.subscribers=$($({},this.subscribers),{},{[t]:this.subscribers[t]?[...this.subscribers[t],n]:[n]})}},{key:"removeSubscriber",value:function(t,n){if(e.invalid(t))throw new z(t);this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter((e=>e!==n)))}},{key:"dispatch",value:function(e,t){var n;null===(n=this.subscribers[e])||void 0===n||n.forEach((e=>{e(t)}))}},{key:"listeners",get:function(){return 0!==Object.keys(this.subscribers).length}}])&&q(t.prototype,n),r&&q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function W(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function J(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=yield fetch(this.endpoint,{method:"POST",headers:Nt.headers,body:JSON.stringify(ve({session:Nt.session},e))});return new ie(t.ok,t)},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){be(o,n,i,s,a,"next",e)}function a(e){be(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})}],null&&we(t.prototype,null),n&&we(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ce(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function Oe(e,t){for(var n=0;n{var[n,r]=e;t.searchParams.append("style[".concat(n,"]"),r)})),t.searchParams.append("placement",I.webchat.placement);var n=yield fetch(t,{method:"GET",headers:Nt.headers}),r=yield n.json();return Nt.business.data||(Nt.business.setData(r.business),Nt.business.setLocale(r.locale)),(new DOMParser).parseFromString(r.html,"text/html").querySelector("article")},function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){Ce(o,r,i,s,a,"next",e)}function a(e){Ce(o,r,i,s,a,"throw",e)}s(void 0)}))});return function(e){return t.apply(this,arguments)}}()}],n&&Oe(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();const Se=xe;function je(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function Te(e,t){for(var n=0;n{var[t,n]=e;return n})));ze.set("hello_utm",JSON.stringify(r))}}var t,n;return t=e,(n=[{key:"current",get:function(){try{return JSON.parse(ze.get("hello_utm"))||{}}catch(e){return{}}}}])&&Re(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Fe(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.utm=new Be,this._url=t}var t,n,r;return t=e,r=[{key:"getRootDomain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;try{if(!e){var t;if("undefined"==typeof window||null===(t=window.location)||void 0===t||!t.hostname)return null;e=window.location.hostname}var n=e.split(".");if(n.length<=1)return e;for(var r of["myshopify.com","vtexcommercestable.com.br","myvtex.com","wixsite.com"]){var i=r.split(".");if(n.slice(-i.length).join(".")===r&&n.length>i.length)return".".concat(n.slice(-(i.length+1)).join("."))}var o=n[n.length-1],s=n[n.length-2];return n.length>2&&2===o.length&&s.length<=3?".".concat(n.slice(-3).join(".")):".".concat(n.slice(-2).join("."))}catch(e){return null}}}],(n=[{key:"url",get:function(){return null!==this._url&&void 0!==this._url?this._url:window.location.href}},{key:"title",get:function(){return document.title}},{key:"path",get:function(){if(this._url)try{return new URL(this._url).pathname}catch(e){return"/"}return window.location.pathname}},{key:"utmParams",get:function(){return this.utm.current}},{key:"trackingData",get:function(){return{page:{url:this.url,title:this.title,path:this.path},utm_params:this.utmParams}}},{key:"domain",get:function(){try{var t=this.url;if(!t)return null;var n=new URL(t).hostname;return e.getRootDomain(n)}catch(e){return null}}}])&&Fe(t.prototype,n),r&&Fe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function De(e,t){for(var n=0;n\n ".concat(Nt.business.locale.white_label.powered_by,'\n\n \n \n Hellotext\n \n \n \n \n ')}});var at=0;function lt(e){return"__private_"+at+++"_"+e}var ct=lt("findOrCreateComponent"),ut=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,ct,{value:ht}),this.data=t,this.element=n||document.querySelector('[data-hello-form="'.concat(this.id,'"]'))||document.createElement("form")}var t,n,r,i;return t=e,n=[{key:"mount",value:(r=function*(){var e,{ifCompleted:t=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&this.hasBeenCompleted)return null===(e=this.element)||void 0===e||e.remove(),Nt.eventEmitter.dispatch("form:completed",function(e){for(var t=1;t{this.element.setAttribute(e.name,e.value)})),document.contains(this.element)||document.body.appendChild(this.element),Nt.business.features.white_label||this.element.prepend(et.build())},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){rt(o,n,i,s,a,"next",e)}function a(e){rt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})},{key:"buildHeader",value:function(e){var t=st(this,ct)[ct]("[data-form-header]","header");t.innerHTML=e.content,this.element.querySelector("[data-form-header]")?this.element.querySelector("[data-form-header]").replaceWith(t):this.element.prepend(t)}},{key:"buildInputs",value:function(e){var t=st(this,ct)[ct]("[data-form-inputs]","main");e.map((e=>Ze.build(e))).forEach((e=>t.appendChild(e))),this.element.querySelector("[data-form-inputs]")?this.element.querySelector("[data-form-inputs]").replaceWith(t):this.element.querySelector("[data-form-header]").insertAdjacentHTML("afterend",t.outerHTML)}},{key:"buildButton",value:function(e){var t=st(this,ct)[ct]("[data-form-button]","button");t.innerText=e.text,t.setAttribute("data-action","click->hellotext--form#submit"),t.setAttribute("data-hellotext--form-target","button"),this.element.querySelector("[data-form-button]")?this.element.querySelector("[data-form-button]").replaceWith(t):this.element.querySelector("[data-form-inputs]").insertAdjacentHTML("afterend",t.outerHTML)}},{key:"buildFooter",value:function(e){var t=st(this,ct)[ct]("[data-form-footer]","footer");t.innerHTML=e.content,this.element.querySelector("[data-form-footer]")?this.element.querySelector("[data-form-footer]").replaceWith(t):this.element.appendChild(t)}},{key:"markAsCompleted",value:function(e){var t={state:"completed",id:this.id,data:e,completedAt:(new Date).getTime()};localStorage.setItem("hello-form-".concat(this.id),JSON.stringify(t)),Nt.eventEmitter.dispatch("form:completed",t)}},{key:"hasBeenCompleted",get:function(){return null!==localStorage.getItem("hello-form-".concat(this.id))}},{key:"id",get:function(){return this.data.id}},{key:"localeAuthKey",get:function(){var e=this.data.steps[0];return e.inputs.some((e=>"email"===e.kind))&&e.inputs.some((e=>"phone"===e.kind))?"phone_and_email":e.inputs.some((e=>"email"===e.kind))?"email":e.inputs.some((e=>"phone"===e.kind))?"phone":"none"}},{key:"elementAttributes",get:function(){return[{name:"data-controller",value:"hellotext--form"},{name:"data-hello-form",value:this.id},{name:"data-hellotext--form-data-value",value:JSON.stringify(this.data)}]}}],n&&it(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function ht(e,t){var n=this.element.querySelector(e);if(n)return n.cloneNode(!0);var r=document.createElement(t);return r.setAttribute(e.replace("[","").replace("]",""),""),r}function dt(e){var t="function"==typeof Map?new Map:void 0;return dt=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ft(e,arguments,gt(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),mt(r,e)},dt(e)}function ft(e,t,n){return ft=pt()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&mt(i,n.prototype),i},ft.apply(null,arguments)}function pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function mt(e,t){return mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},mt(e,t)}function gt(e){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},gt(e)}var vt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&mt(e,t)}(o,e);var t,n,r,i=(n=o,r=pt(),function(){var e,t=gt(n);if(r){var i=gt(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function o(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(e=i.call(this,"You need to initialize before tracking events. Call Hellotext.initialize and pass your public business id")).name="NotInitializedError",e}return t=o,Object.defineProperty(t,"prototype",{writable:!1}),t}(dt(Error));function yt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function bt(e,t){for(var n=0;n0&&this.collect()}},{key:"formMutationObserver",value:function(e){e.find((e=>"childList"===e.type&&e.addedNodes.length>0))&&Array.from(document.querySelectorAll("[data-hello-form]")).length>0&&this.collect()}},{key:"collect",value:(r=function*(){if(Nt.notInitialized)throw new vt;if(!this.fetching){if("undefined"==typeof document||!("querySelectorAll"in document))return console.warn("Document is not defined, collection is not possible. Please make sure to initialize the library after the document is loaded.");var e=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(this,kt)[kt];if(0!==e.length){var t=e.map((e=>me.get(e).then((e=>e.json()))));this.fetching=!0,yield Promise.all(t).then((e=>e.forEach(this.add))).then((()=>Nt.eventEmitter.dispatch("forms:collected",this))).then((()=>this.fetching=!1)),I.forms.autoMount&&this.forms.forEach((e=>e.mount()))}}},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){yt(o,n,i,s,a,"next",e)}function a(e){yt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})},{key:"forEach",value:function(e){this.forms.forEach(e)}},{key:"map",value:function(e){return this.forms.map(e)}},{key:"add",value:function(e){this.includes(e.id)||(Nt.business.data||(Nt.business.setData(e.business),Nt.business.setLocale(j.toString())),Nt.business.enabledWhitelist||console.warn("No whitelist has been configured. It is advised to whitelist the domain to avoid bots from submitting forms."),this.forms.push(new ut(e)))}},{key:"getById",value:function(e){return this.forms.find((t=>t.id===e))}},{key:"getByIndex",value:function(e){return this.forms[e]}},{key:"includes",value:function(e){return this.forms.some((t=>t.id===e))}},{key:"excludes",value:function(e){return!this.includes(e)}},{key:"length",get:function(){return this.forms.length}}],n&&bt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ot(){return Array.from(document.querySelectorAll("[data-hello-form]")).map((e=>e.dataset.helloForm)).filter(this.excludes)}function xt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function St(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(this.notInitialized)throw new vt;var n=Mt(Mt({},t&&t.headers||{}),this.headers),r=Mt(Mt({},Et.identificationData),t.user_parameters||{}),i=t&&t.url?new Ne(t.url):this.page,o=Mt(Mt({session:this.session,user_parameters:r,action:e},t),i.trackingData);return delete o.headers,yield Me.events.create({headers:n,body:o})})),function(e){return i.apply(this,arguments)})},{key:"identify",value:(r=It((function*(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Et.id===e)return new ie(!0,{json:(t=It((function*(){})),function(){return t.apply(this,arguments)})});var r=yield Me.identifications.create(Mt({user_id:e},n));return r.succeeded&&Et.remember(e,n.source),r})),function(e){return r.apply(this,arguments)})},{key:"forget",value:function(){Et.forget()}},{key:"on",value:function(e,t){this.eventEmitter.addSubscriber(e,t)}},{key:"removeEventListener",value:function(e,t){this.eventEmitter.removeSubscriber(e,t)}},{key:"session",get:function(){return We.session}},{key:"isInitialized",get:function(){return void 0!==We.session}},{key:"notInitialized",get:function(){return!this.business||void 0===this.business.id}},{key:"headers",get:function(){if(this.notInitialized)throw new vt;return{Authorization:"Bearer ".concat(this.business.id),Accept:"application/json","Content-Type":"application/json"}}}],n&&Rt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();Ft.eventEmitter=new K,Ft.forms=void 0,Ft.business=void 0,Ft.webchat=void 0;const Nt=Ft;function Dt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function zt(e,t){for(var n=0;n{var{type:t,parameter:n}=e,r=this.inputTargets.find((e=>e.name===n));r.setCustomValidity(Nt.business.locale.errors[t]),r.reportValidity(),r.addEventListener("input",(()=>{r.setCustomValidity(""),r.reportValidity()}))})),this.showErrorMessages();this.buttonTarget.style.display="none",this.element.querySelectorAll("input").forEach((e=>e.disabled=!0)),this.completed()},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){Dt(o,n,i,s,a,"next",e)}function a(e){Dt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(e){return i.apply(this,arguments)})},{key:"completed",value:function(){if(this.form.markAsCompleted(this.formData),!I.forms.shouldShowSuccessMessage)return this.element.remove();"string"==typeof I.forms.successMessage?this.element.innerHTML=I.forms.successMessage:this.element.innerHTML=Nt.business.locale.forms[this.form.localeAuthKey]}},{key:"showErrorMessages",value:function(){this.inputTargets.forEach((e=>{var t=e.closest("article").querySelector("[data-error-container]");e.validity.valid?t.innerText="":t.innerText=e.validationMessage}))}},{key:"clearErrorMessages",value:function(){this.inputTargets.forEach((e=>{e.setCustomValidity(""),e.closest("article").querySelector("[data-error-container]").innerText=""}))}},{key:"inputTargetConnected",value:function(e){e.getAttribute("data-default-value")&&(e.value=e.getAttribute("data-default-value"))}},{key:"requiredInputs",get:function(){return this.inputTargets.filter((e=>e.required))}},{key:"invalid",get:function(){return!this.element.checkValidity()}}],n&&zt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),l}(v.Qr);function Ut(e,t){for(var n=0;n0?this.leftFadeTarget.classList.remove("hidden"):this.leftFadeTarget.classList.add("hidden"),ee.concat(t,t+"-"+Zt[0],t+"-"+Zt[1])),[]),Xt=Math.min,Yt=Math.max,Qt=Math.round,en=Math.floor,tn=e=>({x:e,y:e}),nn={left:"right",right:"left",bottom:"top",top:"bottom"},rn={start:"end",end:"start"};function on(e,t,n){return Yt(e,Xt(t,n))}function sn(e,t){return"function"==typeof e?e(t):e}function an(e){return e.split("-")[0]}function ln(e){return e.split("-")[1]}function cn(e){return"x"===e?"y":"x"}function un(e){return"y"===e?"height":"width"}const hn=new Set(["top","bottom"]);function dn(e){return hn.has(an(e))?"y":"x"}function fn(e){return cn(dn(e))}function pn(e,t,n){void 0===n&&(n=!1);const r=ln(e),i=fn(e),o=un(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=wn(s)),[s,wn(s)]}function mn(e){return e.replace(/start|end/g,(e=>rn[e]))}const gn=["left","right"],vn=["right","left"],yn=["top","bottom"],bn=["bottom","top"];function wn(e){return e.replace(/left|right|bottom|top/g,(e=>nn[e]))}function _n(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function kn(e,t,n){let{reference:r,floating:i}=e;const o=dn(t),s=fn(t),a=un(s),l=an(t),c="y"===o,u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:u,y:r.y-i.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-i.width,y:h};break;default:f={x:r.x,y:r.y}}switch(ln(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Cn(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:f=0}=sn(t,e),p=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(f),m=a[d?"floating"===h?"reference":"floating":h],g=_n(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v="floating"===h?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},w=_n(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(g.top-w.top+p.top)/b.y,bottom:(w.bottom-g.bottom+p.bottom)/b.y,left:(g.left-w.left+p.left)/b.x,right:(w.right-g.right+p.right)/b.x}}const On=new Set(["left","top"]);function xn(){return"undefined"!=typeof window}function Sn(e){return En(e)?(e.nodeName||"").toLowerCase():"#document"}function jn(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Tn(e){var t;return null==(t=(En(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function En(e){return!!xn()&&(e instanceof Node||e instanceof jn(e).Node)}function Pn(e){return!!xn()&&(e instanceof Element||e instanceof jn(e).Element)}function Mn(e){return!!xn()&&(e instanceof HTMLElement||e instanceof jn(e).HTMLElement)}function An(e){return!(!xn()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof jn(e).ShadowRoot)}const Ln=new Set(["inline","contents"]);function In(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Kn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Ln.has(i)}const Rn=new Set(["table","td","th"]);function Bn(e){return Rn.has(Sn(e))}const Fn=[":popover-open",":modal"];function Nn(e){return Fn.some((t=>{try{return e.matches(t)}catch(e){return!1}}))}const Dn=["transform","translate","scale","rotate","perspective"],zn=["transform","translate","scale","rotate","perspective","filter"],Vn=["paint","layout","strict","content"];function $n(e){const t=Hn(),n=Pn(e)?Kn(e):e;return Dn.some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||zn.some((e=>(n.willChange||"").includes(e)))||Vn.some((e=>(n.contain||"").includes(e)))}function Hn(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const qn=new Set(["html","body","#document"]);function Un(e){return qn.has(Sn(e))}function Kn(e){return jn(e).getComputedStyle(e)}function Wn(e){return Pn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jn(e){if("html"===Sn(e))return e;const t=e.assignedSlot||e.parentNode||An(e)&&e.host||Tn(e);return An(t)?t.host:t}function Zn(e){const t=Jn(e);return Un(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mn(t)&&In(t)?t:Zn(t)}function Gn(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=Zn(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=jn(i);if(o){const e=Xn(s);return t.concat(s,s.visualViewport||[],In(i)?i:[],e&&n?Gn(e):[])}return t.concat(i,Gn(i,[],n))}function Xn(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yn(e){const t=Kn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Mn(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=Qt(n)!==o||Qt(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function Qn(e){return Pn(e)?e:e.contextElement}function er(e){const t=Qn(e);if(!Mn(t))return tn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Yn(t);let s=(o?Qt(n.width):n.width)/r,a=(o?Qt(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const tr=tn(0);function nr(e){const t=jn(e);return Hn()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:tr}function rr(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=Qn(e);let s=tn(1);t&&(r?Pn(r)&&(s=er(r)):s=er(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==jn(e))&&t}(o,n,r)?nr(o):tn(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,h=i.height/s.y;if(o){const e=jn(o),t=r&&Pn(r)?jn(r):r;let n=e,i=Xn(n);for(;i&&r&&t!==n;){const e=er(i),t=i.getBoundingClientRect(),r=Kn(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,h*=e.y,l+=o,c+=s,n=jn(i),i=Xn(n)}}return _n({width:u,height:h,x:l,y:c})}function ir(e,t){const n=Wn(e).scrollLeft;return t?t.left+n:rr(Tn(e)).left+n}function or(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:ir(e,r)),y:r.top+t.scrollTop}}const sr=new Set(["absolute","fixed"]);function ar(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=jn(e),r=Tn(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=Hn();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=Tn(e),n=Wn(e),r=e.ownerDocument.body,i=Yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+ir(e);const a=-n.scrollTop;return"rtl"===Kn(r).direction&&(s+=Yt(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Tn(e));else if(Pn(t))r=function(e,t){const n=rr(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Mn(e)?er(e):tn(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=nr(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _n(r)}function lr(e,t){const n=Jn(e);return!(n===t||!Pn(n)||Un(n))&&("fixed"===Kn(n).position||lr(n,t))}function cr(e,t,n){const r=Mn(t),i=Tn(t),o="fixed"===n,s=rr(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=tn(0);function c(){l.x=ir(i)}if(r||!r&&!o)if(("body"!==Sn(t)||In(i))&&(a=Wn(t)),r){const e=rr(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const u=!i||r||o?tn(0):or(i,a);return{x:s.left+a.scrollLeft-l.x-u.x,y:s.top+a.scrollTop-l.y-u.y,width:s.width,height:s.height}}function ur(e){return"static"===Kn(e).position}function hr(e,t){if(!Mn(e)||"fixed"===Kn(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Tn(e)===n&&(n=n.ownerDocument.body),n}function dr(e,t){const n=jn(e);if(Nn(e))return n;if(!Mn(e)){let t=Jn(e);for(;t&&!Un(t);){if(Pn(t)&&!ur(t))return t;t=Jn(t)}return n}let r=hr(e,t);for(;r&&Bn(r)&&ur(r);)r=hr(r,t);return r&&Un(r)&&ur(r)&&!$n(r)?n:r||function(e){let t=Jn(e);for(;Mn(t)&&!Un(t);){if($n(t))return t;if(Nn(t))return null;t=Jn(t)}return null}(e)||n}const fr={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Tn(r),a=!!t&&Nn(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=tn(1);const u=tn(0),h=Mn(r);if((h||!h&&!o)&&(("body"!==Sn(r)||In(s))&&(l=Wn(r)),Mn(r))){const e=rr(r);c=er(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const d=!s||h||o?tn(0):or(s,l,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:n.y*c.y-l.scrollTop*c.y+u.y+d.y}},getDocumentElement:Tn,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?Nn(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=Gn(e,[],!1).filter((e=>Pn(e)&&"body"!==Sn(e))),i=null;const o="fixed"===Kn(e).position;let s=o?Jn(e):e;for(;Pn(s)&&!Un(s);){const t=Kn(s),n=$n(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&sr.has(i.position)||In(s)&&!n&&lr(e,s))?r=r.filter((e=>e!==s)):i=t,s=Jn(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce(((e,n)=>{const r=ar(t,n,i);return e.top=Yt(r.top,e.top),e.right=Xt(r.right,e.right),e.bottom=Xt(r.bottom,e.bottom),e.left=Yt(r.left,e.left),e}),ar(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:dr,getElementRects:async function(e){const t=this.getOffsetParent||dr,n=this.getDimensions,r=await n(e.floating);return{reference:cr(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Yn(e);return{width:t,height:n}},getScale:er,isElement:Pn,isRTL:function(e){return"rtl"===Kn(e).direction}};function pr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}const mr=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=an(n),a=ln(n),l="y"===dn(n),c=On.has(s)?-1:1,u=o&&l?-1:1,h=sn(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*u,y:d*c}:{x:d*c,y:f*u}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},gr=function(e){return void 0===e&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:o,middlewareData:s,placement:a,platform:l,elements:c}=t,{crossAxis:u=!1,alignment:h,allowedPlacements:d=Gt,autoAlignment:f=!0,...p}=sn(e,t),m=void 0!==h||d===Gt?function(e,t,n){return(e?[...n.filter((t=>ln(t)===e)),...n.filter((t=>ln(t)!==e))]:n.filter((e=>an(e)===e))).filter((n=>!e||ln(n)===e||!!t&&mn(n)!==n))}(h||null,f,d):d,g=await Cn(t,p),v=(null==(n=s.autoPlacement)?void 0:n.index)||0,y=m[v];if(null==y)return{};const b=pn(y,o,await(null==l.isRTL?void 0:l.isRTL(c.floating)));if(a!==y)return{reset:{placement:m[0]}};const w=[g[an(y)],g[b[0]],g[b[1]]],_=[...(null==(r=s.autoPlacement)?void 0:r.overflows)||[],{placement:y,overflows:w}],k=m[v+1];if(k)return{data:{index:v+1,overflows:_},reset:{placement:k}};const C=_.map((e=>{const t=ln(e.placement);return[e.placement,t&&u?e.overflows.slice(0,2).reduce(((e,t)=>e+t),0):e.overflows[0],e.overflows]})).sort(((e,t)=>e[1]-t[1])),O=(null==(i=C.filter((e=>e[2].slice(0,ln(e[0])?2:3).every((e=>e<=0))))[0])?void 0:i[0])||C[0][0];return O!==a?{data:{index:v+1,overflows:_},reset:{placement:O}}:{}}}},vr=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=sn(e,t),c={x:n,y:r},u=await Cn(t,l),h=dn(an(i)),d=cn(h);let f=c[d],p=c[h];if(o){const e="y"===d?"bottom":"right";f=on(f+u["y"===d?"top":"left"],f,f-u[e])}if(s){const e="y"===h?"bottom":"right";p=on(p+u["y"===h?"top":"left"],p,p-u[e])}const m=a.fn({...t,[d]:f,[h]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[h]:s}}}}}},yr=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=sn(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=an(i),y=dn(a),b=an(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),_=d||(b||!m?[wn(a)]:function(e){const t=wn(e);return[mn(e),t,mn(t)]}(a)),k="none"!==p;!d&&k&&_.push(...function(e,t,n,r){const i=ln(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?vn:gn:t?gn:vn;case"left":case"right":return t?yn:bn;default:return[]}}(an(e),"start"===n,r);return i&&(o=o.map((e=>e+"-"+i)),t&&(o=o.concat(o.map(mn)))),o}(a,m,p,w));const C=[a,..._],O=await Cn(t,g),x=[];let S=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&x.push(O[v]),h){const e=pn(i,s,w);x.push(O[e[0]],O[e[1]])}if(S=[...S,{placement:i,overflows:x}],!x.every((e=>e<=0))){var j,T;const e=((null==(j=o.flip)?void 0:j.index)||0)+1,t=C[e];if(t&&("alignment"!==h||y===dn(t)||S.every((e=>dn(e.placement)!==y||e.overflows[0]>0))))return{data:{index:e,overflows:S},reset:{placement:t}};let n=null==(T=S.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:T.placement;if(!n)switch(f){case"bestFit":{var E;const e=null==(E=S.filter((e=>{if(k){const t=dn(e.placement);return t===y||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:E[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},br=JSON.parse('{"search":"Search","search_no_results_1":"Oh no!","search_no_results_2":"That emoji couldn’t be found","pick":"Pick an emoji…","add_custom":"Add custom emoji","categories":{"activity":"Activity","custom":"Custom","flags":"Flags","foods":"Food & Drink","frequent":"Frequently used","nature":"Animals & Nature","objects":"Objects","people":"Smileys & People","places":"Travel & Places","search":"Search Results","symbols":"Symbols"},"skins":{"1":"Default","2":"Light","3":"Medium-Light","4":"Medium","5":"Medium-Dark","6":"Dark","choose":"Choose default skin tone"}}'),wr=JSON.parse('{"search":"Buscar","search_no_results_1":"Vaya!","search_no_results_2":"Ese emoji no se pudo encontrar","pick":"Elige un emoji…","add_custom":"Añadir emoji personalizado","categories":{"activity":"Actividades","custom":"Personalizados","flags":"Banderas","foods":"Comida y Bebida","frequent":"Usados con frecuencia","nature":"Animales y Naturaleza","objects":"Objetos","people":"Emoticonos y Personas","places":"Viajes y Destinos","search":"Resultados de la búsqueda","symbols":"Símbolos"},"skins":{"1":"Sin tono","2":"Claro","3":"Medio-Claro","4":"Medio","5":"Medio-Oscuro","6":"Oscuro","choose":"Elige el tono de piel predeterminado"}}');function _r(e){return e&&e.__esModule?e.default:e}function kr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Cr,Or,xr,Sr,jr,Tr,Er={},Pr=[],Mr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function Ar(e,t){for(var n in t)e[n]=t[n];return e}function Lr(e){var t=e.parentNode;t&&t.removeChild(e)}function Ir(e,t,n){var r,i,o,s={};for(o in t)"key"==o?r=t[o]:"ref"==o?i=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?Cr.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return Rr(e,s,r,i,null)}function Rr(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++xr:i};return null==i&&null!=Or.vnode&&Or.vnode(o),o}function Br(e){return e.children}function Fr(e,t){this.props=e,this.context=t}function Nr(e,t){if(null==t)return e.__?Nr(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?Rr(f.type,f.props,f.key,null,f.__v):f)){if(f.__=n,f.__b=n.__b+1,null===(d=v[u])||d&&f.key==d.key&&f.type===d.type)v[u]=void 0;else for(h=0;h{let e=null;try{navigator.userAgent.includes("jsdom")||(e=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}))}catch{}if(!e)return()=>!1;const t=20,n=Math.floor(12.5);return e.font=n+"px Arial, Sans-Serif",e.textBaseline="top",e.canvas.width=40,e.canvas.height=25,n=>{e.clearRect(0,0,40,25),e.fillStyle="#FF0000",e.fillText(n,0,22),e.fillStyle="#0000FF",e.fillText(n,t,22);const r=e.getImageData(0,0,t,25).data,i=r.length;let o=0;for(;o=i)return!1;const s=t+o/4%t,a=Math.floor(o/4/t),l=e.getImageData(s,a,1,1).data;return r[o]===l[0]&&r[o+2]===l[2]&&!(e.measureText(n).width>=t)}})();var ui={latestVersion:function(){for(const{v:e,emoji:t}of ai)if(li(t))return e},noCountryFlags:function(){return!li("🇨🇦")}};const hi=["+1","grinning","kissing_heart","heart_eyes","laughing","stuck_out_tongue_winking_eye","sweat_smile","joy","scream","disappointed","unamused","weary","sob","sunglasses","heart"];let di=null;var fi={add:function(e){di||(di=oi("frequently")||{});const t=e.id||e;t&&(di[t]||(di[t]=0),di[t]+=1,ii("last",t),ii("frequently",di))},get:function({maxFrequentRows:e,perLine:t}){if(!e)return[];di||(di=oi("frequently"));let n=[];if(!di){di={};for(let e in hi.slice(0,t)){const r=hi[e];di[r]=t-e,n.push(r)}return n}const r=e*t,i=oi("last");for(let e in di)n.push(e);if(n.sort(((e,t)=>{const n=di[t],r=di[e];return n==r?e.localeCompare(t):n-r})),n.length>r){const e=n.slice(r);n=n.slice(0,r);for(let t of e)t!=i&&delete di[t];i&&-1==n.indexOf(i)&&(delete di[n[n.length-1]],n.splice(-1,1,i)),ii("frequently",di)}return n},DEFAULTS:hi},pi={};pi=JSON.parse('{"search":"Search","search_no_results_1":"Oh no!","search_no_results_2":"That emoji couldn’t be found","pick":"Pick an emoji…","add_custom":"Add custom emoji","categories":{"activity":"Activity","custom":"Custom","flags":"Flags","foods":"Food & Drink","frequent":"Frequently used","nature":"Animals & Nature","objects":"Objects","people":"Smileys & People","places":"Travel & Places","search":"Search Results","symbols":"Symbols"},"skins":{"1":"Default","2":"Light","3":"Medium-Light","4":"Medium","5":"Medium-Dark","6":"Dark","choose":"Choose default skin tone"}}');var mi={autoFocus:{value:!1},dynamicWidth:{value:!1},emojiButtonColors:{value:null},emojiButtonRadius:{value:"100%"},emojiButtonSize:{value:36},emojiSize:{value:24},emojiVersion:{value:15,choices:[1,2,3,4,5,11,12,12.1,13,13.1,14,15]},exceptEmojis:{value:[]},icons:{value:"auto",choices:["auto","outline","solid"]},locale:{value:"en",choices:["en","ar","be","cs","de","es","fa","fi","fr","hi","it","ja","ko","nl","pl","pt","ru","sa","tr","uk","vi","zh"]},maxFrequentRows:{value:4},navPosition:{value:"top",choices:["top","bottom","none"]},noCountryFlags:{value:!1},noResultsEmoji:{value:null},perLine:{value:9},previewEmoji:{value:null},previewPosition:{value:"bottom",choices:["top","bottom","none"]},searchPosition:{value:"sticky",choices:["sticky","static","none"]},set:{value:"native",choices:["native","apple","facebook","google","twitter"]},skin:{value:1,choices:[1,2,3,4,5,6]},skinTonePosition:{value:"preview",choices:["preview","search","none"]},theme:{value:"auto",choices:["auto","light","dark"]},categories:null,categoryIcons:null,custom:null,data:null,i18n:null,getImageURL:null,getSpritesheetURL:null,onAddCustomEmoji:null,onClickOutside:null,onEmojiSelect:null,stickySearch:{deprecated:!0,value:!0}};let gi=null,vi=null;const yi={};async function bi(e){if(yi[e])return yi[e];const t=await fetch(e),n=await t.json();return yi[e]=n,n}let wi=null,_i=null,ki=!1;function Ci(e,{caller:t}={}){return wi||(wi=new Promise((e=>{_i=e}))),e?async function(e){ki=!0;let{emojiVersion:t,set:n,locale:r}=e;if(t||(t=mi.emojiVersion.value),n||(n=mi.set.value),r||(r=mi.locale.value),vi)vi.categories=vi.categories.filter((e=>!e.name));else{vi=("function"==typeof e.data?await e.data():e.data)||await bi(`https://cdn.jsdelivr.net/npm/@emoji-mart/data@latest/sets/${t}/${n}.json`),vi.emoticons={},vi.natives={},vi.categories.unshift({id:"frequent",emojis:[]});for(const e in vi.aliases){const t=vi.aliases[e],n=vi.emojis[t];n&&(n.aliases||(n.aliases=[]),n.aliases.push(e))}vi.originalCategories=vi.categories}if(gi=("function"==typeof e.i18n?await e.i18n():e.i18n)||("en"==r?_r(pi):await bi(`https://cdn.jsdelivr.net/npm/@emoji-mart/data@latest/i18n/${r}.json`)),e.custom)for(let t in e.custom){t=parseInt(t);const n=e.custom[t],r=e.custom[t-1];if(n.emojis&&n.emojis.length){n.id||(n.id=`custom_${t+1}`),n.name||(n.name=gi.categories.custom),r&&!n.icon&&(n.target=r.target||r),vi.categories.push(n);for(const e of n.emojis)vi.emojis[e.id]=e}}e.categories&&(vi.categories=vi.originalCategories.filter((t=>-1!=e.categories.indexOf(t.id))).sort(((t,n)=>e.categories.indexOf(t.id)-e.categories.indexOf(n.id))));let i=null,o=null;"native"==n&&(i=ui.latestVersion(),o=e.noCountryFlags||ui.noCountryFlags());let s=vi.categories.length,a=!1;for(;s--;){const t=vi.categories[s];if("frequent"==t.id){let{maxFrequentRows:n,perLine:r}=e;n=n>=0?n:mi.maxFrequentRows.value,r||(r=mi.perLine.value),t.emojis=fi.get({maxFrequentRows:n,perLine:r})}if(!t.emojis||!t.emojis.length){vi.categories.splice(s,1);continue}const{categoryIcons:n}=e;if(n){const e=n[t.id];e&&!t.icon&&(t.icon=e)}let r=t.emojis.length;for(;r--;){const n=t.emojis[r],s=n.id?n:vi.emojis[n],l=()=>{t.emojis.splice(r,1)};if(!s||e.exceptEmojis&&e.exceptEmojis.includes(s.id))l();else if(i&&s.version>i)l();else if(!o||"flags"!=t.id||Ti.includes(s.id)){if(!s.search){if(a=!0,s.search=","+[[s.id,!1],[s.name,!0],[s.keywords,!1],[s.emoticons,!1]].map((([e,t])=>{if(e)return(Array.isArray(e)?e:[e]).map((e=>(t?e.split(/[-|_|\s]+/):[e]).map((e=>e.toLowerCase())))).flat()})).flat().filter((e=>e&&e.trim())).join(","),s.emoticons)for(const e of s.emoticons)vi.emoticons[e]||(vi.emoticons[e]=s.id);let e=0;for(const t of s.skins){if(!t)continue;e++;const{native:n}=t;n&&(vi.natives[n]=s.id,s.search+=`,${n}`);const r=1==e?"":`:skin-tone-${e}:`;t.shortcodes=`:${s.id}:${r}`}}}else l()}}a&&ji.reset(),_i()}(e):t&&!ki&&console.warn(`\`${t}\` requires data to be initialized first. Promise will be pending until \`init\` is called.`),wi}function Oi(e,t,n){e||(e={});const r={};for(let i in t)r[i]=xi(i,e,t,n);return r}function xi(e,t,n,r){const i=n[e];let o=r&&r.getAttribute(e)||(null!=t[e]&&null!=t[e]?t[e]:null);return i?(null!=o&&i.value&&typeof i.value!=typeof o&&(o="boolean"==typeof i.value?"false"!=o:i.value.constructor(o)),i.transform&&o&&(o=i.transform(o)),(null==o||i.choices&&-1==i.choices.indexOf(o))&&(o=i.value),o):o}let Si=null;var ji={search:async function(e,{maxResults:t,caller:n}={}){if(!e||!e.trim().length)return null;t||(t=90),await Ci(null,{caller:n||"SearchIndex.search"});const r=e.toLowerCase().replace(/(\w)-/,"$1 ").split(/[\s|,]+/).filter(((e,t,n)=>e.trim()&&n.indexOf(e)==t));if(!r.length)return;let i,o,s=Si||(Si=Object.values(vi.emojis));for(const e of r){if(!s.length)break;i=[],o={};for(const t of s){if(!t.search)continue;const n=t.search.indexOf(`,${e}`);-1!=n&&(i.push(t),o[t.id]||(o[t.id]=0),o[t.id]+=t.id==e?0:n+1)}s=i}return i.length<2||(i.sort(((e,t)=>{const n=o[e.id],r=o[t.id];return n==r?e.id.localeCompare(t.id):n-r})),i.length>t&&(i=i.slice(0,t))),i},get:function(e){return e.id?e:vi.emojis[e]||vi.emojis[vi.aliases[e]]||vi.emojis[vi.natives[e]]},reset:function(){Si=null},SHORTCODES_REGEX:/^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/};const Ti=["checkered_flag","crossed_flags","pirate_flag","rainbow-flag","transgender_flag","triangular_flag_on_post","waving_black_flag","waving_white_flag"];var Ei={categories:{activity:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ri("path",{d:"M12 0C5.373 0 0 5.372 0 12c0 6.627 5.373 12 12 12 6.628 0 12-5.373 12-12 0-6.628-5.372-12-12-12m9.949 11H17.05c.224-2.527 1.232-4.773 1.968-6.113A9.966 9.966 0 0 1 21.949 11M13 11V2.051a9.945 9.945 0 0 1 4.432 1.564c-.858 1.491-2.156 4.22-2.392 7.385H13zm-2 0H8.961c-.238-3.165-1.536-5.894-2.393-7.385A9.95 9.95 0 0 1 11 2.051V11zm0 2v8.949a9.937 9.937 0 0 1-4.432-1.564c.857-1.492 2.155-4.221 2.393-7.385H11zm4.04 0c.236 3.164 1.534 5.893 2.392 7.385A9.92 9.92 0 0 1 13 21.949V13h2.04zM4.982 4.887C5.718 6.227 6.726 8.473 6.951 11h-4.9a9.977 9.977 0 0 1 2.931-6.113M2.051 13h4.9c-.226 2.527-1.233 4.771-1.969 6.113A9.972 9.972 0 0 1 2.051 13m16.967 6.113c-.735-1.342-1.744-3.586-1.968-6.113h4.899a9.961 9.961 0 0 1-2.931 6.113"})}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M16.17 337.5c0 44.98 7.565 83.54 13.98 107.9C35.22 464.3 50.46 496 174.9 496c9.566 0 19.59-.4707 29.84-1.271L17.33 307.3C16.53 317.6 16.17 327.7 16.17 337.5zM495.8 174.5c0-44.98-7.565-83.53-13.98-107.9c-4.688-17.54-18.34-31.23-36.04-35.95C435.5 27.91 392.9 16 337 16c-9.564 0-19.59 .4707-29.84 1.271l187.5 187.5C495.5 194.4 495.8 184.3 495.8 174.5zM26.77 248.8l236.3 236.3c142-36.1 203.9-150.4 222.2-221.1L248.9 26.87C106.9 62.96 45.07 177.2 26.77 248.8zM256 335.1c0 9.141-7.474 16-16 16c-4.094 0-8.188-1.564-11.31-4.689L164.7 283.3C161.6 280.2 160 276.1 160 271.1c0-8.529 6.865-16 16-16c4.095 0 8.189 1.562 11.31 4.688l64.01 64C254.4 327.8 256 331.9 256 335.1zM304 287.1c0 9.141-7.474 16-16 16c-4.094 0-8.188-1.564-11.31-4.689L212.7 235.3C209.6 232.2 208 228.1 208 223.1c0-9.141 7.473-16 16-16c4.094 0 8.188 1.562 11.31 4.688l64.01 64.01C302.5 279.8 304 283.9 304 287.1zM256 175.1c0-9.141 7.473-16 16-16c4.094 0 8.188 1.562 11.31 4.688l64.01 64.01c3.125 3.125 4.688 7.219 4.688 11.31c0 9.133-7.468 16-16 16c-4.094 0-8.189-1.562-11.31-4.688l-64.01-64.01C257.6 184.2 256 180.1 256 175.1z"})})},custom:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:ri("path",{d:"M417.1 368c-5.937 10.27-16.69 16-27.75 16c-5.422 0-10.92-1.375-15.97-4.281L256 311.4V448c0 17.67-14.33 32-31.1 32S192 465.7 192 448V311.4l-118.3 68.29C68.67 382.6 63.17 384 57.75 384c-11.06 0-21.81-5.734-27.75-16c-8.828-15.31-3.594-34.88 11.72-43.72L159.1 256L41.72 187.7C26.41 178.9 21.17 159.3 29.1 144C36.63 132.5 49.26 126.7 61.65 128.2C65.78 128.7 69.88 130.1 73.72 132.3L192 200.6V64c0-17.67 14.33-32 32-32S256 46.33 256 64v136.6l118.3-68.29c3.838-2.213 7.939-3.539 12.07-4.051C398.7 126.7 411.4 132.5 417.1 144c8.828 15.31 3.594 34.88-11.72 43.72L288 256l118.3 68.28C421.6 333.1 426.8 352.7 417.1 368z"})}),flags:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ri("path",{d:"M0 0l6.084 24H8L1.916 0zM21 5h-4l-1-4H4l3 12h3l1 4h13L21 5zM6.563 3h7.875l2 8H8.563l-2-8zm8.832 10l-2.856 1.904L12.063 13h3.332zM19 13l-1.5-6h1.938l2 8H16l3-2z"})}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M64 496C64 504.8 56.75 512 48 512h-32C7.25 512 0 504.8 0 496V32c0-17.75 14.25-32 32-32s32 14.25 32 32V496zM476.3 0c-6.365 0-13.01 1.35-19.34 4.233c-45.69 20.86-79.56 27.94-107.8 27.94c-59.96 0-94.81-31.86-163.9-31.87C160.9 .3055 131.6 4.867 96 15.75v350.5c32-9.984 59.87-14.1 84.85-14.1c73.63 0 124.9 31.78 198.6 31.78c31.91 0 68.02-5.971 111.1-23.09C504.1 355.9 512 344.4 512 332.1V30.73C512 11.1 495.3 0 476.3 0z"})})},foods:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ri("path",{d:"M17 4.978c-1.838 0-2.876.396-3.68.934.513-1.172 1.768-2.934 4.68-2.934a1 1 0 0 0 0-2c-2.921 0-4.629 1.365-5.547 2.512-.064.078-.119.162-.18.244C11.73 1.838 10.798.023 9.207.023 8.579.022 7.85.306 7 .978 5.027 2.54 5.329 3.902 6.492 4.999 3.609 5.222 0 7.352 0 12.969c0 4.582 4.961 11.009 9 11.009 1.975 0 2.371-.486 3-1 .629.514 1.025 1 3 1 4.039 0 9-6.418 9-11 0-5.953-4.055-8-7-8M8.242 2.546c.641-.508.943-.523.965-.523.426.169.975 1.405 1.357 3.055-1.527-.629-2.741-1.352-2.98-1.846.059-.112.241-.356.658-.686M15 21.978c-1.08 0-1.21-.109-1.559-.402l-.176-.146c-.367-.302-.816-.452-1.266-.452s-.898.15-1.266.452l-.176.146c-.347.292-.477.402-1.557.402-2.813 0-7-5.389-7-9.009 0-5.823 4.488-5.991 5-5.991 1.939 0 2.484.471 3.387 1.251l.323.276a1.995 1.995 0 0 0 2.58 0l.323-.276c.902-.78 1.447-1.251 3.387-1.251.512 0 5 .168 5 6 0 3.617-4.187 9-7 9"})}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M481.9 270.1C490.9 279.1 496 291.3 496 304C496 316.7 490.9 328.9 481.9 337.9C472.9 346.9 460.7 352 448 352H64C51.27 352 39.06 346.9 30.06 337.9C21.06 328.9 16 316.7 16 304C16 291.3 21.06 279.1 30.06 270.1C39.06 261.1 51.27 256 64 256H448C460.7 256 472.9 261.1 481.9 270.1zM475.3 388.7C478.3 391.7 480 395.8 480 400V416C480 432.1 473.3 449.3 461.3 461.3C449.3 473.3 432.1 480 416 480H96C79.03 480 62.75 473.3 50.75 461.3C38.74 449.3 32 432.1 32 416V400C32 395.8 33.69 391.7 36.69 388.7C39.69 385.7 43.76 384 48 384H464C468.2 384 472.3 385.7 475.3 388.7zM50.39 220.8C45.93 218.6 42.03 215.5 38.97 211.6C35.91 207.7 33.79 203.2 32.75 198.4C31.71 193.5 31.8 188.5 32.99 183.7C54.98 97.02 146.5 32 256 32C365.5 32 457 97.02 479 183.7C480.2 188.5 480.3 193.5 479.2 198.4C478.2 203.2 476.1 207.7 473 211.6C469.1 215.5 466.1 218.6 461.6 220.8C457.2 222.9 452.3 224 447.3 224H64.67C59.73 224 54.84 222.9 50.39 220.8zM372.7 116.7C369.7 119.7 368 123.8 368 128C368 131.2 368.9 134.3 370.7 136.9C372.5 139.5 374.1 141.6 377.9 142.8C380.8 143.1 384 144.3 387.1 143.7C390.2 143.1 393.1 141.6 395.3 139.3C397.6 137.1 399.1 134.2 399.7 131.1C400.3 128 399.1 124.8 398.8 121.9C397.6 118.1 395.5 116.5 392.9 114.7C390.3 112.9 387.2 111.1 384 111.1C379.8 111.1 375.7 113.7 372.7 116.7V116.7zM244.7 84.69C241.7 87.69 240 91.76 240 96C240 99.16 240.9 102.3 242.7 104.9C244.5 107.5 246.1 109.6 249.9 110.8C252.8 111.1 256 112.3 259.1 111.7C262.2 111.1 265.1 109.6 267.3 107.3C269.6 105.1 271.1 102.2 271.7 99.12C272.3 96.02 271.1 92.8 270.8 89.88C269.6 86.95 267.5 84.45 264.9 82.7C262.3 80.94 259.2 79.1 256 79.1C251.8 79.1 247.7 81.69 244.7 84.69V84.69zM116.7 116.7C113.7 119.7 112 123.8 112 128C112 131.2 112.9 134.3 114.7 136.9C116.5 139.5 118.1 141.6 121.9 142.8C124.8 143.1 128 144.3 131.1 143.7C134.2 143.1 137.1 141.6 139.3 139.3C141.6 137.1 143.1 134.2 143.7 131.1C144.3 128 143.1 124.8 142.8 121.9C141.6 118.1 139.5 116.5 136.9 114.7C134.3 112.9 131.2 111.1 128 111.1C123.8 111.1 119.7 113.7 116.7 116.7L116.7 116.7z"})})},frequent:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ri("path",{d:"M13 4h-2l-.001 7H9v2h2v2h2v-2h4v-2h-4z"}),ri("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0m0 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10"})]}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512zM232 256C232 264 236 271.5 242.7 275.1L338.7 339.1C349.7 347.3 364.6 344.3 371.1 333.3C379.3 322.3 376.3 307.4 365.3 300L280 243.2V120C280 106.7 269.3 96 255.1 96C242.7 96 231.1 106.7 231.1 120L232 256z"})})},nature:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ri("path",{d:"M15.5 8a1.5 1.5 0 1 0 .001 3.001A1.5 1.5 0 0 0 15.5 8M8.5 8a1.5 1.5 0 1 0 .001 3.001A1.5 1.5 0 0 0 8.5 8"}),ri("path",{d:"M18.933 0h-.027c-.97 0-2.138.787-3.018 1.497-1.274-.374-2.612-.51-3.887-.51-1.285 0-2.616.133-3.874.517C7.245.79 6.069 0 5.093 0h-.027C3.352 0 .07 2.67.002 7.026c-.039 2.479.276 4.238 1.04 5.013.254.258.882.677 1.295.882.191 3.177.922 5.238 2.536 6.38.897.637 2.187.949 3.2 1.102C8.04 20.6 8 20.795 8 21c0 1.773 2.35 3 4 3 1.648 0 4-1.227 4-3 0-.201-.038-.393-.072-.586 2.573-.385 5.435-1.877 5.925-7.587.396-.22.887-.568 1.104-.788.763-.774 1.079-2.534 1.04-5.013C23.929 2.67 20.646 0 18.933 0M3.223 9.135c-.237.281-.837 1.155-.884 1.238-.15-.41-.368-1.349-.337-3.291.051-3.281 2.478-4.972 3.091-5.031.256.015.731.27 1.265.646-1.11 1.171-2.275 2.915-2.352 5.125-.133.546-.398.858-.783 1.313M12 22c-.901 0-1.954-.693-2-1 0-.654.475-1.236 1-1.602V20a1 1 0 1 0 2 0v-.602c.524.365 1 .947 1 1.602-.046.307-1.099 1-2 1m3-3.48v.02a4.752 4.752 0 0 0-1.262-1.02c1.092-.516 2.239-1.334 2.239-2.217 0-1.842-1.781-2.195-3.977-2.195-2.196 0-3.978.354-3.978 2.195 0 .883 1.148 1.701 2.238 2.217A4.8 4.8 0 0 0 9 18.539v-.025c-1-.076-2.182-.281-2.973-.842-1.301-.92-1.838-3.045-1.853-6.478l.023-.041c.496-.826 1.49-1.45 1.804-3.102 0-2.047 1.357-3.631 2.362-4.522C9.37 3.178 10.555 3 11.948 3c1.447 0 2.685.192 3.733.57 1 .9 2.316 2.465 2.316 4.48.313 1.651 1.307 2.275 1.803 3.102.035.058.068.117.102.178-.059 5.967-1.949 7.01-4.902 7.19m6.628-8.202c-.037-.065-.074-.13-.113-.195a7.587 7.587 0 0 0-.739-.987c-.385-.455-.648-.768-.782-1.313-.076-2.209-1.241-3.954-2.353-5.124.531-.376 1.004-.63 1.261-.647.636.071 3.044 1.764 3.096 5.031.027 1.81-.347 3.218-.37 3.235"})]}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:ri("path",{d:"M332.7 19.85C334.6 8.395 344.5 0 356.1 0C363.6 0 370.6 3.52 375.1 9.502L392 32H444.1C456.8 32 469.1 37.06 478.1 46.06L496 64H552C565.3 64 576 74.75 576 88V112C576 156.2 540.2 192 496 192H426.7L421.6 222.5L309.6 158.5L332.7 19.85zM448 64C439.2 64 432 71.16 432 80C432 88.84 439.2 96 448 96C456.8 96 464 88.84 464 80C464 71.16 456.8 64 448 64zM416 256.1V480C416 497.7 401.7 512 384 512H352C334.3 512 320 497.7 320 480V364.8C295.1 377.1 268.8 384 240 384C211.2 384 184 377.1 160 364.8V480C160 497.7 145.7 512 128 512H96C78.33 512 64 497.7 64 480V249.8C35.23 238.9 12.64 214.5 4.836 183.3L.9558 167.8C-3.331 150.6 7.094 133.2 24.24 128.1C41.38 124.7 58.76 135.1 63.05 152.2L66.93 167.8C70.49 182 83.29 191.1 97.97 191.1H303.8L416 256.1z"})})},objects:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ri("path",{d:"M12 0a9 9 0 0 0-5 16.482V21s2.035 3 5 3 5-3 5-3v-4.518A9 9 0 0 0 12 0zm0 2c3.86 0 7 3.141 7 7s-3.14 7-7 7-7-3.141-7-7 3.14-7 7-7zM9 17.477c.94.332 1.946.523 3 .523s2.06-.19 3-.523v.834c-.91.436-1.925.689-3 .689a6.924 6.924 0 0 1-3-.69v-.833zm.236 3.07A8.854 8.854 0 0 0 12 21c.965 0 1.888-.167 2.758-.451C14.155 21.173 13.153 22 12 22c-1.102 0-2.117-.789-2.764-1.453z"}),ri("path",{d:"M14.745 12.449h-.004c-.852-.024-1.188-.858-1.577-1.824-.421-1.061-.703-1.561-1.182-1.566h-.009c-.481 0-.783.497-1.235 1.537-.436.982-.801 1.811-1.636 1.791l-.276-.043c-.565-.171-.853-.691-1.284-1.794-.125-.313-.202-.632-.27-.913-.051-.213-.127-.53-.195-.634C7.067 9.004 7.039 9 6.99 9A1 1 0 0 1 7 7h.01c1.662.017 2.015 1.373 2.198 2.134.486-.981 1.304-2.058 2.797-2.075 1.531.018 2.28 1.153 2.731 2.141l.002-.008C14.944 8.424 15.327 7 16.979 7h.032A1 1 0 1 1 17 9h-.011c-.149.076-.256.474-.319.709a6.484 6.484 0 0 1-.311.951c-.429.973-.79 1.789-1.614 1.789"})]}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",children:ri("path",{d:"M112.1 454.3c0 6.297 1.816 12.44 5.284 17.69l17.14 25.69c5.25 7.875 17.17 14.28 26.64 14.28h61.67c9.438 0 21.36-6.401 26.61-14.28l17.08-25.68c2.938-4.438 5.348-12.37 5.348-17.7L272 415.1h-160L112.1 454.3zM191.4 .0132C89.44 .3257 16 82.97 16 175.1c0 44.38 16.44 84.84 43.56 115.8c16.53 18.84 42.34 58.23 52.22 91.45c.0313 .25 .0938 .5166 .125 .7823h160.2c.0313-.2656 .0938-.5166 .125-.7823c9.875-33.22 35.69-72.61 52.22-91.45C351.6 260.8 368 220.4 368 175.1C368 78.61 288.9-.2837 191.4 .0132zM192 96.01c-44.13 0-80 35.89-80 79.1C112 184.8 104.8 192 96 192S80 184.8 80 176c0-61.76 50.25-111.1 112-111.1c8.844 0 16 7.159 16 16S200.8 96.01 192 96.01z"})})},people:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ri("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0m0 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10"}),ri("path",{d:"M8 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 8 7M16 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 16 7M15.232 15c-.693 1.195-1.87 2-3.349 2-1.477 0-2.655-.805-3.347-2H15m3-2H6a6 6 0 1 0 12 0"})]}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256zM256 432C332.1 432 396.2 382 415.2 314.1C419.1 300.4 407.8 288 393.6 288H118.4C104.2 288 92.92 300.4 96.76 314.1C115.8 382 179.9 432 256 432V432zM176.4 160C158.7 160 144.4 174.3 144.4 192C144.4 209.7 158.7 224 176.4 224C194 224 208.4 209.7 208.4 192C208.4 174.3 194 160 176.4 160zM336.4 224C354 224 368.4 209.7 368.4 192C368.4 174.3 354 160 336.4 160C318.7 160 304.4 174.3 304.4 192C304.4 209.7 318.7 224 336.4 224z"})})},places:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[ri("path",{d:"M6.5 12C5.122 12 4 13.121 4 14.5S5.122 17 6.5 17 9 15.879 9 14.5 7.878 12 6.5 12m0 3c-.275 0-.5-.225-.5-.5s.225-.5.5-.5.5.225.5.5-.225.5-.5.5M17.5 12c-1.378 0-2.5 1.121-2.5 2.5s1.122 2.5 2.5 2.5 2.5-1.121 2.5-2.5-1.122-2.5-2.5-2.5m0 3c-.275 0-.5-.225-.5-.5s.225-.5.5-.5.5.225.5.5-.225.5-.5.5"}),ri("path",{d:"M22.482 9.494l-1.039-.346L21.4 9h.6c.552 0 1-.439 1-.992 0-.006-.003-.008-.003-.008H23c0-1-.889-2-1.984-2h-.642l-.731-1.717C19.262 3.012 18.091 2 16.764 2H7.236C5.909 2 4.738 3.012 4.357 4.283L3.626 6h-.642C1.889 6 1 7 1 8h.003S1 8.002 1 8.008C1 8.561 1.448 9 2 9h.6l-.043.148-1.039.346a2.001 2.001 0 0 0-1.359 2.097l.751 7.508a1 1 0 0 0 .994.901H3v1c0 1.103.896 2 2 2h2c1.104 0 2-.897 2-2v-1h6v1c0 1.103.896 2 2 2h2c1.104 0 2-.897 2-2v-1h1.096a.999.999 0 0 0 .994-.901l.751-7.508a2.001 2.001 0 0 0-1.359-2.097M6.273 4.857C6.402 4.43 6.788 4 7.236 4h9.527c.448 0 .834.43.963.857L19.313 9H4.688l1.585-4.143zM7 21H5v-1h2v1zm12 0h-2v-1h2v1zm2.189-3H2.811l-.662-6.607L3 11h18l.852.393L21.189 18z"})]}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M39.61 196.8L74.8 96.29C88.27 57.78 124.6 32 165.4 32H346.6C387.4 32 423.7 57.78 437.2 96.29L472.4 196.8C495.6 206.4 512 229.3 512 256V448C512 465.7 497.7 480 480 480H448C430.3 480 416 465.7 416 448V400H96V448C96 465.7 81.67 480 64 480H32C14.33 480 0 465.7 0 448V256C0 229.3 16.36 206.4 39.61 196.8V196.8zM109.1 192H402.9L376.8 117.4C372.3 104.6 360.2 96 346.6 96H165.4C151.8 96 139.7 104.6 135.2 117.4L109.1 192zM96 256C78.33 256 64 270.3 64 288C64 305.7 78.33 320 96 320C113.7 320 128 305.7 128 288C128 270.3 113.7 256 96 256zM416 320C433.7 320 448 305.7 448 288C448 270.3 433.7 256 416 256C398.3 256 384 270.3 384 288C384 305.7 398.3 320 416 320z"})})},symbols:{outline:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:ri("path",{d:"M0 0h11v2H0zM4 11h3V6h4V4H0v2h4zM15.5 17c1.381 0 2.5-1.116 2.5-2.493s-1.119-2.493-2.5-2.493S13 13.13 13 14.507 14.119 17 15.5 17m0-2.986c.276 0 .5.222.5.493 0 .272-.224.493-.5.493s-.5-.221-.5-.493.224-.493.5-.493M21.5 19.014c-1.381 0-2.5 1.116-2.5 2.493S20.119 24 21.5 24s2.5-1.116 2.5-2.493-1.119-2.493-2.5-2.493m0 2.986a.497.497 0 0 1-.5-.493c0-.271.224-.493.5-.493s.5.222.5.493a.497.497 0 0 1-.5.493M22 13l-9 9 1.513 1.5 8.99-9.009zM17 11c2.209 0 4-1.119 4-2.5V2s.985-.161 1.498.949C23.01 4.055 23 6 23 6s1-1.119 1-3.135C24-.02 21 0 21 0h-2v6.347A5.853 5.853 0 0 0 17 6c-2.209 0-4 1.119-4 2.5s1.791 2.5 4 2.5M10.297 20.482l-1.475-1.585a47.54 47.54 0 0 1-1.442 1.129c-.307-.288-.989-1.016-2.045-2.183.902-.836 1.479-1.466 1.729-1.892s.376-.871.376-1.336c0-.592-.273-1.178-.818-1.759-.546-.581-1.329-.871-2.349-.871-1.008 0-1.79.293-2.344.879-.556.587-.832 1.181-.832 1.784 0 .813.419 1.748 1.256 2.805-.847.614-1.444 1.208-1.794 1.784a3.465 3.465 0 0 0-.523 1.833c0 .857.308 1.56.924 2.107.616.549 1.423.823 2.42.823 1.173 0 2.444-.379 3.813-1.137L8.235 24h2.819l-2.09-2.383 1.333-1.135zm-6.736-6.389a1.02 1.02 0 0 1 .73-.286c.31 0 .559.085.747.254a.849.849 0 0 1 .283.659c0 .518-.419 1.112-1.257 1.784-.536-.651-.805-1.231-.805-1.742a.901.901 0 0 1 .302-.669M3.74 22c-.427 0-.778-.116-1.057-.349-.279-.232-.418-.487-.418-.766 0-.594.509-1.288 1.527-2.083.968 1.134 1.717 1.946 2.248 2.438-.921.507-1.686.76-2.3.76"})}),solid:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:ri("path",{d:"M500.3 7.251C507.7 13.33 512 22.41 512 31.1V175.1C512 202.5 483.3 223.1 447.1 223.1C412.7 223.1 383.1 202.5 383.1 175.1C383.1 149.5 412.7 127.1 447.1 127.1V71.03L351.1 90.23V207.1C351.1 234.5 323.3 255.1 287.1 255.1C252.7 255.1 223.1 234.5 223.1 207.1C223.1 181.5 252.7 159.1 287.1 159.1V63.1C287.1 48.74 298.8 35.61 313.7 32.62L473.7 .6198C483.1-1.261 492.9 1.173 500.3 7.251H500.3zM74.66 303.1L86.5 286.2C92.43 277.3 102.4 271.1 113.1 271.1H174.9C185.6 271.1 195.6 277.3 201.5 286.2L213.3 303.1H239.1C266.5 303.1 287.1 325.5 287.1 351.1V463.1C287.1 490.5 266.5 511.1 239.1 511.1H47.1C21.49 511.1-.0019 490.5-.0019 463.1V351.1C-.0019 325.5 21.49 303.1 47.1 303.1H74.66zM143.1 359.1C117.5 359.1 95.1 381.5 95.1 407.1C95.1 434.5 117.5 455.1 143.1 455.1C170.5 455.1 191.1 434.5 191.1 407.1C191.1 381.5 170.5 359.1 143.1 359.1zM440.3 367.1H496C502.7 367.1 508.6 372.1 510.1 378.4C513.3 384.6 511.6 391.7 506.5 396L378.5 508C372.9 512.1 364.6 513.3 358.6 508.9C352.6 504.6 350.3 496.6 353.3 489.7L391.7 399.1H336C329.3 399.1 323.4 395.9 321 389.6C318.7 383.4 320.4 376.3 325.5 371.1L453.5 259.1C459.1 255 467.4 254.7 473.4 259.1C479.4 263.4 481.6 271.4 478.7 278.3L440.3 367.1zM116.7 219.1L19.85 119.2C-8.112 90.26-6.614 42.31 24.85 15.34C51.82-8.137 93.26-3.642 118.2 21.83L128.2 32.32L137.7 21.83C162.7-3.642 203.6-8.137 231.6 15.34C262.6 42.31 264.1 90.26 236.1 119.2L139.7 219.1C133.2 225.6 122.7 225.6 116.7 219.1H116.7z"})})}},search:{loupe:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:ri("path",{d:"M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z"})}),delete:ri("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:ri("path",{d:"M10 8.586L2.929 1.515 1.515 2.929 8.586 10l-7.071 7.071 1.414 1.414L10 11.414l7.071 7.071 1.414-1.414L11.414 10l7.071-7.071-1.414-1.414L10 8.586z"})})}};function Pi(e){let{id:t,skin:n,emoji:r}=e;if(e.shortcodes){const r=e.shortcodes.match(ji.SHORTCODES_REGEX);r&&(t=r[1],r[2]&&(n=r[2]))}if(r||(r=ji.get(t||e.native)),!r)return e.fallback;const i=r.skins[n-1]||r.skins[0],o=i.src||("native"==e.set||e.spritesheet?void 0:"function"==typeof e.getImageURL?e.getImageURL(e.set,i.unified):`https://cdn.jsdelivr.net/npm/emoji-datasource-${e.set}@15.0.1/img/${e.set}/64/${i.unified}.png`),s="function"==typeof e.getSpritesheetURL?e.getSpritesheetURL(e.set):`https://cdn.jsdelivr.net/npm/emoji-datasource-${e.set}@15.0.1/img/${e.set}/sheets-256/64.png`;return ri("span",{class:"emoji-mart-emoji","data-emoji-set":e.set,children:o?ri("img",{style:{maxWidth:e.size||"1em",maxHeight:e.size||"1em",display:"inline-block"},alt:i.native||i.shortcodes,src:o}):"native"==e.set?ri("span",{style:{fontSize:e.size,fontFamily:'"EmojiMart", "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "Android Emoji"'},children:i.native}):ri("span",{style:{display:"block",width:e.size,height:e.size,backgroundImage:`url(${s})`,backgroundSize:`${100*vi.sheet.cols}% ${100*vi.sheet.rows}%`,backgroundPosition:`${100/(vi.sheet.cols-1)*i.x}% ${100/(vi.sheet.rows-1)*i.y}%`}})})}const Mi="undefined"!=typeof window&&window.HTMLElement?window.HTMLElement:Object;class Ai extends Mi{static get observedAttributes(){return Object.keys(this.Props)}update(e={}){for(let t in e)this.attributeChangedCallback(t,null,e[t])}attributeChangedCallback(e,t,n){if(!this.component)return;const r=xi(e,{[e]:n},this.constructor.Props,this);this.component.componentWillReceiveProps?this.component.componentWillReceiveProps({[e]:r}):(this.component.props[e]=r,this.component.forceUpdate())}disconnectedCallback(){this.disconnected=!0,this.component&&this.component.unregister&&this.component.unregister()}constructor(e={}){if(super(),this.props=e,e.parent||e.ref){let t=null;const n=e.parent||(t=e.ref&&e.ref.current);t&&(t.innerHTML=""),n&&n.appendChild(this)}}}class Li extends Ai{setShadow(){this.attachShadow({mode:"open"})}injectStyles(e){if(!e)return;const t=document.createElement("style");t.textContent=e,this.shadowRoot.insertBefore(t,this.shadowRoot.firstChild)}constructor(e,{styles:t}={}){super(e),this.setShadow(),this.injectStyles(t)}}var Ii={fallback:"",id:"",native:"",shortcodes:"",size:{value:"",transform:e=>/\D/.test(e)?e:`${e}px`},set:mi.set,skin:mi.skin};class Ri extends Ai{async connectedCallback(){const e=Oi(this.props,Ii,this);e.element=this,e.ref=e=>{this.component=e},await Ci(),this.disconnected||ti(ri(Pi,{...e}),this)}constructor(e){super(e)}}kr(Ri,"Props",Ii),"undefined"==typeof customElements||customElements.get("em-emoji")||customElements.define("em-emoji",Ri);var Bi,Fi,Ni=[],Di=Or.__b,zi=Or.__r,Vi=Or.diffed,$i=Or.__c,Hi=Or.unmount;function qi(){var e;for(Ni.sort((function(e,t){return e.__v.__b-t.__v.__b}));e=Ni.pop();)if(e.__P)try{e.__H.__h.forEach(Ki),e.__H.__h.forEach(Wi),e.__H.__h=[]}catch(t){e.__H.__h=[],Or.__e(t,e.__v)}}Or.__b=function(e){Bi=null,Di&&Di(e)},Or.__r=function(e){zi&&zi(e);var t=(Bi=e.__c).__H;t&&(t.__h.forEach(Ki),t.__h.forEach(Wi),t.__h=[])},Or.diffed=function(e){Vi&&Vi(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==Ni.push(t)&&Fi===Or.requestAnimationFrame||((Fi=Or.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),Ui&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);Ui&&(t=requestAnimationFrame(n))})(qi)),Bi=null},Or.__c=function(e,t){t.some((function(e){try{e.__h.forEach(Ki),e.__h=e.__h.filter((function(e){return!e.__||Wi(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],Or.__e(n,e.__v)}})),$i&&$i(e,t)},Or.unmount=function(e){Hi&&Hi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{Ki(e)}catch(e){t=e}})),t&&Or.__e(t,n.__v))};var Ui="function"==typeof requestAnimationFrame;function Ki(e){var t=Bi,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Bi=t}function Wi(e){var t=Bi;e.__c=e.__(),Bi=t}function Ji(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function Zi(e){this.props=e}(Zi.prototype=new Fr).isPureReactComponent=!0,Zi.prototype.shouldComponentUpdate=function(e,t){return Ji(this.props,e)||Ji(this.state,t)};var Gi=Or.__b;Or.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Gi&&Gi(e)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var Xi=Or.__e;Or.__e=function(e,t,n){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);Xi(e,t,n)};var Yi=Or.unmount;function Qi(){this.__u=0,this.t=null,this.__b=null}function eo(e){var t=e.__.__c;return t&&t.__e&&t.__e(e)}function to(){this.u=null,this.o=null}Or.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&!0===e.__h&&(e.type=null),Yi&&Yi(e)},(Qi.prototype=new Fr).__c=function(e,t){var n=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(n);var i=eo(r.__v),o=!1,s=function(){o||(o=!0,n.__R=null,i?i(a):a())};n.__R=s;var a=function(){if(!--r.__u){if(r.state.__e){var e=r.state.__e;r.__v.__k[0]=function e(t,n,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map((function(t){return e(t,n,r)})),t.__c&&t.__c.__P===n&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate()}},l=!0===t.__h;r.__u++||l||r.setState({__e:r.__b=r.__v.__k[0]}),e.then(s,s)},Qi.prototype.componentWillUnmount=function(){this.t=[]},Qi.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function e(t,n,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),t.__c.__H=null),null!=(t=function(e,t){for(var n in t)e[n]=t[n];return e}({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=n),t.__c=null),t.__k=t.__k&&t.__k.map((function(t){return e(t,n,r)}))),t}(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__e&&Ir(Br,null,e.fallback);return i&&(i.__h=null),[Ir(Br,null,t.__e?null:e.children),i]};var no=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]{const r=t.name||gi.categories[t.id],i=!this.props.unfocused&&t.id==this.state.categoryId;return i&&(e=n),ri("button",{"aria-label":r,"aria-selected":i||void 0,title:r,type:"button",class:"flex flex-grow flex-center",onMouseDown:e=>e.preventDefault(),onClick:()=>{this.props.onClick({category:t,i:n})},children:this.renderIcon(t)})})),ri("div",{class:"bar",style:{width:100/this.categories.length+"%",opacity:null==e?0:1,transform:"rtl"===this.props.dir?`scaleX(-1) translateX(${100*e}%)`:`translateX(${100*e}%)`}})]})})}constructor(){super(),this.categories=vi.categories.filter((e=>!e.target)),this.state={categoryId:this.categories[0].id}}}class go extends Zi{shouldComponentUpdate(e){for(let t in e)if("children"!=t&&e[t]!=this.props[t])return!0;return!1}render(){return this.props.children}}class vo extends Fr{getInitialState(e=this.props){return{skin:oi("skin")||e.skin,theme:this.initTheme(e.theme)}}componentWillMount(){this.dir=gi.rtl?"rtl":"ltr",this.refs={menu:{current:null},navigation:{current:null},scroll:{current:null},search:{current:null},searchInput:{current:null},skinToneButton:{current:null},skinToneRadio:{current:null}},this.initGrid(),0==this.props.stickySearch&&"sticky"==this.props.searchPosition&&(console.warn("[EmojiMart] Deprecation warning: `stickySearch` has been renamed `searchPosition`."),this.props.searchPosition="static")}componentDidMount(){if(this.register(),this.shadowRoot=this.base.parentNode,this.props.autoFocus){const{searchInput:e}=this.refs;e.current&&e.current.focus()}}componentWillReceiveProps(e){this.nextState||(this.nextState={});for(const t in e)this.nextState[t]=e[t];clearTimeout(this.nextStateTimer),this.nextStateTimer=setTimeout((()=>{let e=!1;for(const t in this.nextState)this.props[t]=this.nextState[t],"custom"!==t&&"categories"!==t||(e=!0);delete this.nextState;const t=this.getInitialState();if(e)return this.reset(t);this.setState(t)}))}componentWillUnmount(){this.unregister()}async reset(e={}){await Ci(this.props),this.initGrid(),this.unobserve(),this.setState(e,(()=>{this.observeCategories(),this.observeRows()}))}register(){document.addEventListener("click",this.handleClickOutside),this.observe()}unregister(){document.removeEventListener("click",this.handleClickOutside),this.darkMedia?.removeEventListener("change",this.darkMediaCallback),this.unobserve()}observe(){this.observeCategories(),this.observeRows()}unobserve({except:e=[]}={}){Array.isArray(e)||(e=[e]);for(const t of this.observers)e.includes(t)||t.disconnect();this.observers=[].concat(e)}initGrid(){const{categories:e}=vi;this.refs.categories=new Map;const t=vi.categories.map((e=>e.id)).join(",");this.navKey&&this.navKey!=t&&this.refs.scroll.current&&(this.refs.scroll.current.scrollTop=0),this.navKey=t,this.grid=[],this.grid.setsize=0;const n=(e,t)=>{const n=[];n.__categoryId=t.id,n.__index=e.length,this.grid.push(n);const r=this.grid.length-1,i=r%10?{}:{current:null};return i.index=r,i.posinset=this.grid.setsize+1,e.push(i),n};for(let t of e){const e=[];let r=n(e,t);for(let i of t.emojis)r.length==this.getPerLine()&&(r=n(e,t)),this.grid.setsize+=1,r.push(i);this.refs.categories.set(t.id,{root:{current:null},rows:e})}}initTheme(e){if("auto"!=e)return e;if(!this.darkMedia){if(this.darkMedia=matchMedia("(prefers-color-scheme: dark)"),this.darkMedia.media.match(/^not/))return"light";this.darkMedia.addEventListener("change",this.darkMediaCallback)}return this.darkMedia.matches?"dark":"light"}initDynamicPerLine(e=this.props){if(!e.dynamicWidth)return;const{element:t,emojiButtonSize:n}=e,r=()=>{const{width:e}=t.getBoundingClientRect();return Math.floor(e/n)},i=new ResizeObserver((()=>{this.unobserve({except:i}),this.setState({perLine:r()},(()=>{this.initGrid(),this.forceUpdate((()=>{this.observeCategories(),this.observeRows()}))}))}));return i.observe(t),this.observers.push(i),r()}getPerLine(){return this.state.perLine||this.props.perLine}getEmojiByPos([e,t]){const n=this.state.searchResults||this.grid,r=n[e]&&n[e][t];if(r)return ji.get(r)}observeCategories(){const e=this.refs.navigation.current;if(!e)return;const t=new Map,n={root:this.refs.scroll.current,threshold:[0,1]},r=new IntersectionObserver((n=>{for(const e of n){const n=e.target.dataset.id;t.set(n,e.intersectionRatio)}const r=[...t];for(const[t,n]of r)if(n){(i=t)!=e.state.categoryId&&e.setState({categoryId:i});break}var i}),n);for(const{root:e}of this.refs.categories.values())r.observe(e.current);this.observers.push(r)}observeRows(){const e={...this.state.visibleRows},t=new IntersectionObserver((t=>{for(const n of t){const t=parseInt(n.target.dataset.index);n.isIntersecting?e[t]=!0:delete e[t]}this.setState({visibleRows:e})}),{root:this.refs.scroll.current,rootMargin:`${15*this.props.emojiButtonSize}px 0px ${10*this.props.emojiButtonSize}px`});for(const{rows:e}of this.refs.categories.values())for(const n of e)n.current&&t.observe(n.current);this.observers.push(t)}preventDefault(e){e.preventDefault()}unfocusSearch(){const e=this.refs.searchInput.current;e&&e.blur()}navigate({e,input:t,left:n,right:r,up:i,down:o}){const s=this.state.searchResults||this.grid;if(!s.length)return;let[a,l]=this.state.pos;const c=(()=>{if(0==a&&0==l&&!e.repeat&&(n||i))return null;if(-1==a)return e.repeat||!r&&!o||t.selectionStart!=t.value.length?null:[0,0];if(n||r){let e=s[a];const t=n?-1:1;if(l+=t,!e[l]){if(a+=t,e=s[a],!e)return a=n?0:s.length-1,l=n?0:s[a].length-1,[a,l];l=n?e.length-1:0}return[a,l]}if(i||o){a+=i?-1:1;const e=s[a];return e?(e[l]||(l=e.length-1),[a,l]):(a=i?0:s.length-1,l=i?0:s[a].length-1,[a,l])}})();c?(e.preventDefault(),this.setState({pos:c,keyboard:!0},(()=>{this.scrollTo({row:c[0]})}))):this.state.pos[0]>-1&&this.setState({pos:[-1,-1]})}scrollTo({categoryId:e,row:t}){const n=this.state.searchResults||this.grid;if(!n.length)return;const r=this.refs.scroll.current,i=r.getBoundingClientRect();let o=0;if(t>=0&&(e=n[t].__categoryId),e&&(o=(this.refs[e]||this.refs.categories.get(e).root).current.getBoundingClientRect().top-(i.top-r.scrollTop)+1),t>=0)if(t){const e=o+n[t].__index*this.props.emojiButtonSize,s=e+this.props.emojiButtonSize+.88*this.props.emojiButtonSize;if(er.scrollTop+i.height))return;o=s-i.height}}else o=0;this.ignoreMouse(),r.scrollTop=o}ignoreMouse(){this.mouseIsIgnored=!0,clearTimeout(this.ignoreMouseTimer),this.ignoreMouseTimer=setTimeout((()=>{delete this.mouseIsIgnored}),100)}handleEmojiOver(e){this.mouseIsIgnored||this.state.showSkins||this.setState({pos:e||[-1,-1],keyboard:!1})}handleEmojiClick({e,emoji:t,pos:n}){if(this.props.onEmojiSelect&&(!t&&n&&(t=this.getEmojiByPos(n)),t)){const n=function(e,{skinIndex:t=0}={}){const n=e.skins[t]||(t=0,e.skins[t]),r={id:e.id,name:e.name,native:n.native,unified:n.unified,keywords:e.keywords,shortcodes:n.shortcodes||e.shortcodes};return e.skins.length>1&&(r.skin=t+1),n.src&&(r.src=n.src),e.aliases&&e.aliases.length&&(r.aliases=e.aliases),e.emoticons&&e.emoticons.length&&(r.emoticons=e.emoticons),r}(t,{skinIndex:this.state.skin-1});this.props.maxFrequentRows&&fi.add(n,this.props),this.props.onEmojiSelect(n,e)}}closeSkins(){this.state.showSkins&&(this.setState({showSkins:null,tempSkin:null}),this.base.removeEventListener("click",this.handleBaseClick),this.base.removeEventListener("keydown",this.handleBaseKeydown))}handleSkinMouseOver(e){this.setState({tempSkin:e})}handleSkinClick(e){this.ignoreMouse(),this.closeSkins(),this.setState({skin:e,tempSkin:null}),ii("skin",e)}renderNav(){return ri(mo,{ref:this.refs.navigation,icons:this.props.icons,theme:this.state.theme,dir:this.dir,unfocused:!!this.state.searchResults,position:this.props.navPosition,onClick:this.handleCategoryClick},this.navKey)}renderPreview(){const e=this.getEmojiByPos(this.state.pos),t=this.state.searchResults&&!this.state.searchResults.length;return ri("div",{id:"preview",class:"flex flex-middle",dir:this.dir,"data-position":this.props.previewPosition,children:[ri("div",{class:"flex flex-middle flex-grow",children:[ri("div",{class:"flex flex-auto flex-middle flex-center",style:{height:this.props.emojiButtonSize,fontSize:this.props.emojiButtonSize},children:ri(Pi,{emoji:e,id:t?this.props.noResultsEmoji||"cry":this.props.previewEmoji||("top"==this.props.previewPosition?"point_down":"point_up"),set:this.props.set,size:this.props.emojiButtonSize,skin:this.state.tempSkin||this.state.skin,spritesheet:!0,getSpritesheetURL:this.props.getSpritesheetURL})}),ri("div",{class:`margin-${this.dir[0]}`,children:ri("div",e||t?{class:`padding-${this.dir[2]} align-${this.dir[0]}`,children:[ri("div",{class:"preview-title ellipsis",children:e?e.name:gi.search_no_results_1}),ri("div",{class:"preview-subtitle ellipsis color-c",children:e?e.skins[0].shortcodes:gi.search_no_results_2})]}:{class:"preview-placeholder color-c",children:gi.pick})})]}),!e&&"preview"==this.props.skinTonePosition&&this.renderSkinToneButton()]})}renderEmojiButton(e,{pos:t,posinset:n,grid:r}){const i=this.props.emojiButtonSize,o=this.state.tempSkin||this.state.skin,s=(e.skins[o-1]||e.skins[0]).native,a=(l=this.state.pos,c=t,Array.isArray(l)&&Array.isArray(c)&&l.length===c.length&&l.every(((e,t)=>e==c[t])));var l,c;const u=t.concat(e.id).join("");return ri(go,{selected:a,skin:o,size:i,children:ri("button",{"aria-label":s,"aria-selected":a||void 0,"aria-posinset":n,"aria-setsize":r.setsize,"data-keyboard":this.state.keyboard,title:"none"==this.props.previewPosition?e.name:void 0,type:"button",class:"flex flex-center flex-middle",tabindex:"-1",onClick:t=>this.handleEmojiClick({e:t,emoji:e}),onMouseEnter:()=>this.handleEmojiOver(t),onMouseLeave:()=>this.handleEmojiOver(),style:{width:this.props.emojiButtonSize,height:this.props.emojiButtonSize,fontSize:this.props.emojiSize,lineHeight:0},children:[ri("div",{"aria-hidden":"true",class:"background",style:{borderRadius:this.props.emojiButtonRadius,backgroundColor:this.props.emojiButtonColors?this.props.emojiButtonColors[(n-1)%this.props.emojiButtonColors.length]:void 0}}),ri(Pi,{emoji:e,set:this.props.set,size:this.props.emojiSize,skin:o,spritesheet:!0,getSpritesheetURL:this.props.getSpritesheetURL})]})},u)}renderSearch(){const e="none"==this.props.previewPosition||"search"==this.props.skinTonePosition;return ri("div",{children:[ri("div",{class:"spacer"}),ri("div",{class:"flex flex-middle",children:[ri("div",{class:"search relative flex-grow",children:[ri("input",{type:"search",ref:this.refs.searchInput,placeholder:gi.search,onClick:this.handleSearchClick,onInput:this.handleSearchInput,onKeyDown:this.handleSearchKeyDown,autoComplete:"off"}),ri("span",{class:"icon loupe flex",children:Ei.search.loupe}),this.state.searchResults&&ri("button",{title:"Clear","aria-label":"Clear",type:"button",class:"icon delete flex",onClick:this.clearSearch,onMouseDown:this.preventDefault,children:Ei.search.delete})]}),e&&this.renderSkinToneButton()]})]})}renderSearchResults(){const{searchResults:e}=this.state;return e?ri("div",{class:"category",ref:this.refs.search,children:[ri("div",{class:`sticky padding-small align-${this.dir[0]}`,children:gi.categories.search}),ri("div",{children:e.length?e.map(((t,n)=>ri("div",{class:"flex",children:t.map(((t,r)=>this.renderEmojiButton(t,{pos:[n,r],posinset:n*this.props.perLine+r+1,grid:e})))}))):ri("div",{class:`padding-small align-${this.dir[0]}`,children:this.props.onAddCustomEmoji&&ri("a",{onClick:this.props.onAddCustomEmoji,children:gi.add_custom})})})]}):null}renderCategories(){const{categories:e}=vi,t=!!this.state.searchResults,n=this.getPerLine();return ri("div",{style:{visibility:t?"hidden":void 0,display:t?"none":void 0,height:"100%"},children:e.map((e=>{const{root:t,rows:r}=this.refs.categories.get(e.id);return ri("div",{"data-id":e.target?e.target.id:e.id,class:"category",ref:t,children:[ri("div",{class:`sticky padding-small align-${this.dir[0]}`,children:e.name||gi.categories[e.id]}),ri("div",{class:"relative",style:{height:r.length*this.props.emojiButtonSize},children:r.map(((t,r)=>{const i=t.index-t.index%10,o=this.state.visibleRows[i],s="current"in t?t:void 0;if(!o&&!s)return null;const a=r*n,l=a+n,c=e.emojis.slice(a,l);return c.length{if(!e)return ri("div",{style:{width:this.props.emojiButtonSize,height:this.props.emojiButtonSize}});const r=ji.get(e);return this.renderEmojiButton(r,{pos:[t.index,n],posinset:t.posinset+n,grid:this.grid})}))},t.index)}))})]})}))})}renderSkinToneButton(){return"none"==this.props.skinTonePosition?null:ri("div",{class:"flex flex-auto flex-center flex-middle",style:{position:"relative",width:this.props.emojiButtonSize,height:this.props.emojiButtonSize},children:ri("button",{type:"button",ref:this.refs.skinToneButton,class:"skin-tone-button flex flex-auto flex-center flex-middle","aria-selected":this.state.showSkins?"":void 0,"aria-label":gi.skins.choose,title:gi.skins.choose,onClick:this.openSkins,style:{width:this.props.emojiSize,height:this.props.emojiSize},children:ri("span",{class:`skin-tone skin-tone-${this.state.skin}`})})})}renderLiveRegion(){const e=this.getEmojiByPos(this.state.pos);return ri("div",{"aria-live":"polite",class:"sr-only",children:e?e.name:""})}renderSkins(){const e=this.refs.skinToneButton.current.getBoundingClientRect(),t=this.base.getBoundingClientRect(),n={};return"ltr"==this.dir?n.right=t.right-e.right-3:n.left=e.left-t.left-3,"bottom"==this.props.previewPosition&&"preview"==this.props.skinTonePosition?n.bottom=t.bottom-e.top+6:(n.top=e.bottom-t.top+3,n.bottom="auto"),ri("div",{ref:this.refs.menu,role:"radiogroup",dir:this.dir,"aria-label":gi.skins.choose,class:"menu hidden","data-position":n.top?"top":"bottom",style:n,children:[...Array(6).keys()].map((e=>{const t=e+1,n=this.state.skin==t;return ri("div",{children:[ri("input",{type:"radio",name:"skin-tone",value:t,"aria-label":gi.skins[t],ref:n?this.refs.skinToneRadio:null,defaultChecked:n,onChange:()=>this.handleSkinMouseOver(t),onKeyDown:e=>{"Enter"!=e.code&&"Space"!=e.code&&"Tab"!=e.code||(e.preventDefault(),this.handleSkinClick(t))}}),ri("button",{"aria-hidden":"true",tabindex:"-1",onClick:()=>this.handleSkinClick(t),onMouseEnter:()=>this.handleSkinMouseOver(t),onMouseLeave:()=>this.handleSkinMouseOver(),class:"option flex flex-grow flex-middle",children:[ri("span",{class:`skin-tone skin-tone-${t}`}),ri("span",{class:"margin-small-lr",children:gi.skins[t]})]})]})}))})}render(){const e=this.props.perLine*this.props.emojiButtonSize;return ri("section",{id:"root",class:"flex flex-column",dir:this.dir,style:{width:this.props.dynamicWidth?"100%":`calc(${e}px + (var(--padding) + var(--sidebar-width)))`},"data-emoji-set":this.props.set,"data-theme":this.state.theme,"data-menu":this.state.showSkins?"":void 0,children:["top"==this.props.previewPosition&&this.renderPreview(),"top"==this.props.navPosition&&this.renderNav(),"sticky"==this.props.searchPosition&&ri("div",{class:"padding-lr",children:this.renderSearch()}),ri("div",{ref:this.refs.scroll,class:"scroll flex-grow padding-lr",children:ri("div",{style:{width:this.props.dynamicWidth?"100%":e,height:"100%"},children:["static"==this.props.searchPosition&&this.renderSearch(),this.renderSearchResults(),this.renderCategories()]})}),"bottom"==this.props.navPosition&&this.renderNav(),"bottom"==this.props.previewPosition&&this.renderPreview(),this.state.showSkins&&this.renderSkins(),this.renderLiveRegion()]})}constructor(e){super(),kr(this,"darkMediaCallback",(()=>{"auto"==this.props.theme&&this.setState({theme:this.darkMedia.matches?"dark":"light"})})),kr(this,"handleClickOutside",(e=>{const{element:t}=this.props;e.target!=t&&(this.state.showSkins&&this.closeSkins(),this.props.onClickOutside&&this.props.onClickOutside(e))})),kr(this,"handleBaseClick",(e=>{this.state.showSkins&&(e.target.closest(".menu")||(e.preventDefault(),e.stopImmediatePropagation(),this.closeSkins()))})),kr(this,"handleBaseKeydown",(e=>{this.state.showSkins&&"Escape"==e.key&&(e.preventDefault(),e.stopImmediatePropagation(),this.closeSkins())})),kr(this,"handleSearchClick",(()=>{this.getEmojiByPos(this.state.pos)&&this.setState({pos:[-1,-1]})})),kr(this,"handleSearchInput",(async()=>{const e=this.refs.searchInput.current;if(!e)return;const{value:t}=e,n=await ji.search(t),r=()=>{this.refs.scroll.current&&(this.refs.scroll.current.scrollTop=0)};if(!n)return this.setState({searchResults:n,pos:[-1,-1]},r);const i=e.selectionStart==e.value.length?[0,0]:[-1,-1],o=[];o.setsize=n.length;let s=null;for(let e of n)o.length&&s.length!=this.getPerLine()||(s=[],s.__categoryId="search",s.__index=o.length,o.push(s)),s.push(e);this.ignoreMouse(),this.setState({searchResults:o,pos:i},r)})),kr(this,"handleSearchKeyDown",(e=>{const t=e.currentTarget;switch(e.stopImmediatePropagation(),e.key){case"ArrowLeft":this.navigate({e,input:t,left:!0});break;case"ArrowRight":this.navigate({e,input:t,right:!0});break;case"ArrowUp":this.navigate({e,input:t,up:!0});break;case"ArrowDown":this.navigate({e,input:t,down:!0});break;case"Enter":e.preventDefault(),this.handleEmojiClick({e,pos:this.state.pos});break;case"Escape":e.preventDefault(),this.state.searchResults?this.clearSearch():this.unfocusSearch()}})),kr(this,"clearSearch",(()=>{const e=this.refs.searchInput.current;e&&(e.value="",e.focus(),this.handleSearchInput())})),kr(this,"handleCategoryClick",(({category:e,i:t})=>{this.scrollTo(0==t?{row:-1}:{categoryId:e.id})})),kr(this,"openSkins",(e=>{const{currentTarget:t}=e,n=t.getBoundingClientRect();this.setState({showSkins:n},(async()=>{await async function(e=1){for(let t in[...Array(e).keys()])await new Promise(requestAnimationFrame)}(2);const e=this.refs.menu.current;e&&(e.classList.remove("hidden"),this.refs.skinToneRadio.current.focus(),this.base.addEventListener("click",this.handleBaseClick,!0),this.base.addEventListener("keydown",this.handleBaseKeydown,!0))}))})),this.observers=[],this.state={pos:[-1,-1],perLine:this.initDynamicPerLine(e),visibleRows:{0:!0},...this.getInitialState(e)}}}class yo extends Li{async connectedCallback(){const e=Oi(this.props,mi,this);e.element=this,e.ref=e=>{this.component=e},await Ci(e),this.disconnected||ti(ri(vo,{...e}),this.shadowRoot)}constructor(e){super(e,{styles:_r(bo)})}}kr(yo,"Props",mi),"undefined"==typeof customElements||customElements.get("em-emoji-picker")||customElements.define("em-emoji-picker",yo);var bo={};bo=':host {\n width: min-content;\n height: 435px;\n min-height: 230px;\n border-radius: var(--border-radius);\n box-shadow: var(--shadow);\n --border-radius: 10px;\n --category-icon-size: 18px;\n --font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;\n --font-size: 15px;\n --preview-placeholder-size: 21px;\n --preview-title-size: 1.1em;\n --preview-subtitle-size: .9em;\n --shadow-color: 0deg 0% 0%;\n --shadow: .3px .5px 2.7px hsl(var(--shadow-color) / .14), .4px .8px 1px -3.2px hsl(var(--shadow-color) / .14), 1px 2px 2.5px -4.5px hsl(var(--shadow-color) / .14);\n display: flex;\n}\n\n[data-theme="light"] {\n --em-rgb-color: var(--rgb-color, 34, 36, 39);\n --em-rgb-accent: var(--rgb-accent, 34, 102, 237);\n --em-rgb-background: var(--rgb-background, 255, 255, 255);\n --em-rgb-input: var(--rgb-input, 255, 255, 255);\n --em-color-border: var(--color-border, rgba(0, 0, 0, .05));\n --em-color-border-over: var(--color-border-over, rgba(0, 0, 0, .1));\n}\n\n[data-theme="dark"] {\n --em-rgb-color: var(--rgb-color, 222, 222, 221);\n --em-rgb-accent: var(--rgb-accent, 58, 130, 247);\n --em-rgb-background: var(--rgb-background, 21, 22, 23);\n --em-rgb-input: var(--rgb-input, 0, 0, 0);\n --em-color-border: var(--color-border, rgba(255, 255, 255, .1));\n --em-color-border-over: var(--color-border-over, rgba(255, 255, 255, .2));\n}\n\n#root {\n --color-a: rgb(var(--em-rgb-color));\n --color-b: rgba(var(--em-rgb-color), .65);\n --color-c: rgba(var(--em-rgb-color), .45);\n --padding: 12px;\n --padding-small: calc(var(--padding) / 2);\n --sidebar-width: 16px;\n --duration: 225ms;\n --duration-fast: 125ms;\n --duration-instant: 50ms;\n --easing: cubic-bezier(.4, 0, .2, 1);\n width: 100%;\n text-align: left;\n border-radius: var(--border-radius);\n background-color: rgb(var(--em-rgb-background));\n position: relative;\n}\n\n@media (prefers-reduced-motion) {\n #root {\n --duration: 0;\n --duration-fast: 0;\n --duration-instant: 0;\n }\n}\n\n#root[data-menu] button {\n cursor: auto;\n}\n\n#root[data-menu] .menu button {\n cursor: pointer;\n}\n\n:host, #root, input, button {\n color: rgb(var(--em-rgb-color));\n font-family: var(--font-family);\n font-size: var(--font-size);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n line-height: normal;\n}\n\n*, :before, :after {\n box-sizing: border-box;\n min-width: 0;\n margin: 0;\n padding: 0;\n}\n\n.relative {\n position: relative;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-auto {\n flex: none;\n}\n\n.flex-center {\n justify-content: center;\n}\n\n.flex-column {\n flex-direction: column;\n}\n\n.flex-grow {\n flex: auto;\n}\n\n.flex-middle {\n align-items: center;\n}\n\n.flex-wrap {\n flex-wrap: wrap;\n}\n\n.padding {\n padding: var(--padding);\n}\n\n.padding-t {\n padding-top: var(--padding);\n}\n\n.padding-lr {\n padding-left: var(--padding);\n padding-right: var(--padding);\n}\n\n.padding-r {\n padding-right: var(--padding);\n}\n\n.padding-small {\n padding: var(--padding-small);\n}\n\n.padding-small-b {\n padding-bottom: var(--padding-small);\n}\n\n.padding-small-lr {\n padding-left: var(--padding-small);\n padding-right: var(--padding-small);\n}\n\n.margin {\n margin: var(--padding);\n}\n\n.margin-r {\n margin-right: var(--padding);\n}\n\n.margin-l {\n margin-left: var(--padding);\n}\n\n.margin-small-l {\n margin-left: var(--padding-small);\n}\n\n.margin-small-lr {\n margin-left: var(--padding-small);\n margin-right: var(--padding-small);\n}\n\n.align-l {\n text-align: left;\n}\n\n.align-r {\n text-align: right;\n}\n\n.color-a {\n color: var(--color-a);\n}\n\n.color-b {\n color: var(--color-b);\n}\n\n.color-c {\n color: var(--color-c);\n}\n\n.ellipsis {\n white-space: nowrap;\n max-width: 100%;\n width: auto;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.sr-only {\n width: 1px;\n height: 1px;\n position: absolute;\n top: auto;\n left: -10000px;\n overflow: hidden;\n}\n\na {\n cursor: pointer;\n color: rgb(var(--em-rgb-accent));\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.spacer {\n height: 10px;\n}\n\n[dir="rtl"] .scroll {\n padding-left: 0;\n padding-right: var(--padding);\n}\n\n.scroll {\n padding-right: 0;\n overflow-x: hidden;\n overflow-y: auto;\n}\n\n.scroll::-webkit-scrollbar {\n width: var(--sidebar-width);\n height: var(--sidebar-width);\n}\n\n.scroll::-webkit-scrollbar-track {\n border: 0;\n}\n\n.scroll::-webkit-scrollbar-button {\n width: 0;\n height: 0;\n display: none;\n}\n\n.scroll::-webkit-scrollbar-corner {\n background-color: rgba(0, 0, 0, 0);\n}\n\n.scroll::-webkit-scrollbar-thumb {\n min-height: 20%;\n min-height: 65px;\n border: 4px solid rgb(var(--em-rgb-background));\n border-radius: 8px;\n}\n\n.scroll::-webkit-scrollbar-thumb:hover {\n background-color: var(--em-color-border-over) !important;\n}\n\n.scroll:hover::-webkit-scrollbar-thumb {\n background-color: var(--em-color-border);\n}\n\n.sticky {\n z-index: 1;\n background-color: rgba(var(--em-rgb-background), .9);\n -webkit-backdrop-filter: blur(4px);\n backdrop-filter: blur(4px);\n font-weight: 500;\n position: sticky;\n top: -1px;\n}\n\n[dir="rtl"] .search input[type="search"] {\n padding: 10px 2.2em 10px 2em;\n}\n\n[dir="rtl"] .search .loupe {\n left: auto;\n right: .7em;\n}\n\n[dir="rtl"] .search .delete {\n left: .7em;\n right: auto;\n}\n\n.search {\n z-index: 2;\n position: relative;\n}\n\n.search input, .search button {\n font-size: calc(var(--font-size) - 1px);\n}\n\n.search input[type="search"] {\n width: 100%;\n background-color: var(--em-color-border);\n transition-duration: var(--duration);\n transition-property: background-color, box-shadow;\n transition-timing-function: var(--easing);\n border: 0;\n border-radius: 10px;\n outline: 0;\n padding: 10px 2em 10px 2.2em;\n display: block;\n}\n\n.search input[type="search"]::-ms-input-placeholder {\n color: inherit;\n opacity: .6;\n}\n\n.search input[type="search"]::placeholder {\n color: inherit;\n opacity: .6;\n}\n\n.search input[type="search"], .search input[type="search"]::-webkit-search-decoration, .search input[type="search"]::-webkit-search-cancel-button, .search input[type="search"]::-webkit-search-results-button, .search input[type="search"]::-webkit-search-results-decoration {\n -webkit-appearance: none;\n -ms-appearance: none;\n appearance: none;\n}\n\n.search input[type="search"]:focus {\n background-color: rgb(var(--em-rgb-input));\n box-shadow: inset 0 0 0 1px rgb(var(--em-rgb-accent)), 0 1px 3px rgba(65, 69, 73, .2);\n}\n\n.search .icon {\n z-index: 1;\n color: rgba(var(--em-rgb-color), .7);\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.search .loupe {\n pointer-events: none;\n left: .7em;\n}\n\n.search .delete {\n right: .7em;\n}\n\nsvg {\n fill: currentColor;\n width: 1em;\n height: 1em;\n}\n\nbutton {\n -webkit-appearance: none;\n -ms-appearance: none;\n appearance: none;\n cursor: pointer;\n color: currentColor;\n background-color: rgba(0, 0, 0, 0);\n border: 0;\n}\n\n#nav {\n z-index: 2;\n padding-top: 12px;\n padding-bottom: 12px;\n padding-right: var(--sidebar-width);\n position: relative;\n}\n\n#nav button {\n color: var(--color-b);\n transition: color var(--duration) var(--easing);\n}\n\n#nav button:hover {\n color: var(--color-a);\n}\n\n#nav svg, #nav img {\n width: var(--category-icon-size);\n height: var(--category-icon-size);\n}\n\n#nav[dir="rtl"] .bar {\n left: auto;\n right: 0;\n}\n\n#nav .bar {\n width: 100%;\n height: 3px;\n background-color: rgb(var(--em-rgb-accent));\n transition: transform var(--duration) var(--easing);\n border-radius: 3px 3px 0 0;\n position: absolute;\n bottom: -12px;\n left: 0;\n}\n\n#nav button[aria-selected] {\n color: rgb(var(--em-rgb-accent));\n}\n\n#preview {\n z-index: 2;\n padding: calc(var(--padding) + 4px) var(--padding);\n padding-right: var(--sidebar-width);\n position: relative;\n}\n\n#preview .preview-placeholder {\n font-size: var(--preview-placeholder-size);\n}\n\n#preview .preview-title {\n font-size: var(--preview-title-size);\n}\n\n#preview .preview-subtitle {\n font-size: var(--preview-subtitle-size);\n}\n\n#nav:before, #preview:before {\n content: "";\n height: 2px;\n position: absolute;\n left: 0;\n right: 0;\n}\n\n#nav[data-position="top"]:before, #preview[data-position="top"]:before {\n background: linear-gradient(to bottom, var(--em-color-border), transparent);\n top: 100%;\n}\n\n#nav[data-position="bottom"]:before, #preview[data-position="bottom"]:before {\n background: linear-gradient(to top, var(--em-color-border), transparent);\n bottom: 100%;\n}\n\n.category:last-child {\n min-height: calc(100% + 1px);\n}\n\n.category button {\n font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, sans-serif;\n position: relative;\n}\n\n.category button > * {\n position: relative;\n}\n\n.category button .background {\n opacity: 0;\n background-color: var(--em-color-border);\n transition: opacity var(--duration-fast) var(--easing) var(--duration-instant);\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n\n.category button:hover .background {\n transition-duration: var(--duration-instant);\n transition-delay: 0s;\n}\n\n.category button[aria-selected] .background {\n opacity: 1;\n}\n\n.category button[data-keyboard] .background {\n transition: none;\n}\n\n.row {\n width: 100%;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.skin-tone-button {\n border: 1px solid rgba(0, 0, 0, 0);\n border-radius: 100%;\n}\n\n.skin-tone-button:hover {\n border-color: var(--em-color-border);\n}\n\n.skin-tone-button:active .skin-tone {\n transform: scale(.85) !important;\n}\n\n.skin-tone-button .skin-tone {\n transition: transform var(--duration) var(--easing);\n}\n\n.skin-tone-button[aria-selected] {\n background-color: var(--em-color-border);\n border-top-color: rgba(0, 0, 0, .05);\n border-bottom-color: rgba(0, 0, 0, 0);\n border-left-width: 0;\n border-right-width: 0;\n}\n\n.skin-tone-button[aria-selected] .skin-tone {\n transform: scale(.9);\n}\n\n.menu {\n z-index: 2;\n white-space: nowrap;\n border: 1px solid var(--em-color-border);\n background-color: rgba(var(--em-rgb-background), .9);\n -webkit-backdrop-filter: blur(4px);\n backdrop-filter: blur(4px);\n transition-property: opacity, transform;\n transition-duration: var(--duration);\n transition-timing-function: var(--easing);\n border-radius: 10px;\n padding: 4px;\n position: absolute;\n box-shadow: 1px 1px 5px rgba(0, 0, 0, .05);\n}\n\n.menu.hidden {\n opacity: 0;\n}\n\n.menu[data-position="bottom"] {\n transform-origin: 100% 100%;\n}\n\n.menu[data-position="bottom"].hidden {\n transform: scale(.9)rotate(-3deg)translateY(5%);\n}\n\n.menu[data-position="top"] {\n transform-origin: 100% 0;\n}\n\n.menu[data-position="top"].hidden {\n transform: scale(.9)rotate(3deg)translateY(-5%);\n}\n\n.menu input[type="radio"] {\n clip: rect(0 0 0 0);\n width: 1px;\n height: 1px;\n border: 0;\n margin: 0;\n padding: 0;\n position: absolute;\n overflow: hidden;\n}\n\n.menu input[type="radio"]:checked + .option {\n box-shadow: 0 0 0 2px rgb(var(--em-rgb-accent));\n}\n\n.option {\n width: 100%;\n border-radius: 6px;\n padding: 4px 6px;\n}\n\n.option:hover {\n color: #fff;\n background-color: rgb(var(--em-rgb-accent));\n}\n\n.skin-tone {\n width: 16px;\n height: 16px;\n border-radius: 100%;\n display: inline-block;\n position: relative;\n overflow: hidden;\n}\n\n.skin-tone:after {\n content: "";\n mix-blend-mode: overlay;\n background: linear-gradient(rgba(255, 255, 255, .2), rgba(0, 0, 0, 0));\n border: 1px solid rgba(0, 0, 0, .8);\n border-radius: 100%;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n box-shadow: inset 0 -2px 3px #000, inset 0 1px 2px #fff;\n}\n\n.skin-tone-1 {\n background-color: #ffc93a;\n}\n\n.skin-tone-2 {\n background-color: #ffdab7;\n}\n\n.skin-tone-3 {\n background-color: #e7b98f;\n}\n\n.skin-tone-4 {\n background-color: #c88c61;\n}\n\n.skin-tone-5 {\n background-color: #a46134;\n}\n\n.skin-tone-6 {\n background-color: #5d4437;\n}\n\n[data-index] {\n justify-content: space-between;\n}\n\n[data-emoji-set="twitter"] .skin-tone:after {\n box-shadow: none;\n border-color: rgba(0, 0, 0, .5);\n}\n\n[data-emoji-set="twitter"] .skin-tone-1 {\n background-color: #fade72;\n}\n\n[data-emoji-set="twitter"] .skin-tone-2 {\n background-color: #f3dfd0;\n}\n\n[data-emoji-set="twitter"] .skin-tone-3 {\n background-color: #eed3a8;\n}\n\n[data-emoji-set="twitter"] .skin-tone-4 {\n background-color: #cfad8d;\n}\n\n[data-emoji-set="twitter"] .skin-tone-5 {\n background-color: #a8805d;\n}\n\n[data-emoji-set="twitter"] .skin-tone-6 {\n background-color: #765542;\n}\n\n[data-emoji-set="google"] .skin-tone:after {\n box-shadow: inset 0 0 2px 2px rgba(0, 0, 0, .4);\n}\n\n[data-emoji-set="google"] .skin-tone-1 {\n background-color: #f5c748;\n}\n\n[data-emoji-set="google"] .skin-tone-2 {\n background-color: #f1d5aa;\n}\n\n[data-emoji-set="google"] .skin-tone-3 {\n background-color: #d4b48d;\n}\n\n[data-emoji-set="google"] .skin-tone-4 {\n background-color: #aa876b;\n}\n\n[data-emoji-set="google"] .skin-tone-5 {\n background-color: #916544;\n}\n\n[data-emoji-set="google"] .skin-tone-6 {\n background-color: #61493f;\n}\n\n[data-emoji-set="facebook"] .skin-tone:after {\n border-color: rgba(0, 0, 0, .4);\n box-shadow: inset 0 -2px 3px #000, inset 0 1px 4px #fff;\n}\n\n[data-emoji-set="facebook"] .skin-tone-1 {\n background-color: #f5c748;\n}\n\n[data-emoji-set="facebook"] .skin-tone-2 {\n background-color: #f1d5aa;\n}\n\n[data-emoji-set="facebook"] .skin-tone-3 {\n background-color: #d4b48d;\n}\n\n[data-emoji-set="facebook"] .skin-tone-4 {\n background-color: #aa876b;\n}\n\n[data-emoji-set="facebook"] .skin-tone-5 {\n background-color: #916544;\n}\n\n[data-emoji-set="facebook"] .skin-tone-6 {\n background-color: #61493f;\n}\n\n';var wo=e=>{Object.assign(e,{show(){this.openValue=!0},hide(){this.openValue=!1},toggle(){this.openValue=!this.openValue},setupFloatingUI(e){var{trigger:t,popover:n}=e;this.floatingUICleanup=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=Qn(e),u=i||o?[...c?Gn(c):[],...Gn(t)]:[];u.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)}));const h=c&&a?function(e,t){let n,r=null;const i=Tn(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:h,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-en(h)+"px "+-en(i.clientWidth-(u+d))+"px "+-en(i.clientHeight-(h+f))+"px "+-en(u)+"px",threshold:Yt(0,Xt(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==r||pr(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver((e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(t)}))),n()})),c&&!l&&p.observe(c),p.observe(t));let m=l?rr(e):null;return l&&function t(){const r=rr(e);m&&!pr(m,r)&&n(),m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach((e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)})),null==h||h(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}(t,n,(()=>{((e,t,n)=>{const r=new Map,i={platform:fr,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=kn(c,r,l),d=r,f={},p=0;for(let n=0;n{var{x:t,y:r,strategy:i}=e,o={left:"".concat(t,"px"),top:"".concat(r,"px"),position:i};Object.assign(n.style,o)}))}))},openValueChanged(){this.disabledValue||(this.openValue?(this.popoverTarget.showPopover(),this.popoverTarget.setAttribute("aria-expanded","true"),this.onPopoverOpened&&this.onPopoverOpened()):(this.popoverTarget.hidePopover(),this.popoverTarget.removeAttribute("aria-expanded"),this.onPopoverClosed&&this.onPopoverClosed()))}})};function _o(e,t){for(var n=0;n{var[n,r]=e;t.searchParams.append(n,r)})),yield fetch(t,{method:"GET",headers:Nt.headers})})),function(e){return o.apply(this,arguments)})},{key:"create",value:(i=jo((function*(e){var t=yield fetch(this.url,{method:"POST",headers:{Authorization:"Bearer ".concat(Nt.business.id)},body:e});return new ie(t.ok,t)})),function(e){return i.apply(this,arguments)})},{key:"markAsSeen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=e?this.url+"/".concat(e):this.url+"/seen";fetch(t,{method:"PATCH",headers:Nt.headers,body:JSON.stringify({session:Nt.session})})}},{key:"url",get:function(){return e.endpoint.replace(":id",this.webchatId)}}],r=[{key:"endpoint",get:function(){return I.endpoint("public/webchats/:id/messages")}}],n&&To(t.prototype,n),r&&To(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Po(e,t){for(var n=0;n{this.webSocket.send(JSON.stringify(i))}))}},{key:"onMessage",value:function(e){this.webSocket.addEventListener("message",(t=>{var n=JSON.parse(t.data),{type:r,message:i}=n;this.ignoredEvents.includes(r)||e(i)}))}},{key:"webSocket",get:function(){return e.webSocket?e.webSocket:e.webSocket=new WebSocket(I.actionCableUrl)}},{key:"ignoredEvents",get:function(){return["ping","confirm_subscription","welcome"]}}])&&Po(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ao(e,t){for(var n=0;n{"message"===t.type&&e(t)}))}},{key:"onReaction",value:function(e){Lo(Ro(s.prototype),"onMessage",this).call(this,(t=>{"reaction.create"!==t.type&&"reaction.destroy"!==t.type||e(t)}))}},{key:"onTypingStart",value:function(e){Lo(Ro(s.prototype),"onMessage",this).call(this,(t=>{"started_typing"===t.type&&e(t)}))}},{key:"updateSubscriptionWith",value:function(e){this.unsubscribe(),setTimeout((()=>{this.conversation=e,this.subscribe()}),1e3)}}])&&Ao(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),s}(Mo);const Fo=Bo;function No(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Do(e){for(var t=1;t{this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight,behavior:"instant"})}));var t=this.typingIndicatorKeepAliveValue;this.incomingTypingIndicatorTimeout=setTimeout((()=>{this.clearTypingIndicator()}),t)}},{key:"resetTypingIndicatorTimer",value:function(){if(this.typingIndicatorVisible){clearTimeout(this.incomingTypingIndicatorTimeout),clearTimeout(this.optimisticTypingTimeout);var e=this.typingIndicatorKeepAliveValue;this.incomingTypingIndicatorTimeout=setTimeout((()=>{this.clearTypingIndicator()}),e)}}},{key:"clearTypingIndicator",value:function(){this.hasTypingIndicatorTarget&&this.typingIndicatorTarget.remove(),this.typingIndicatorVisible=!1,clearTimeout(this.incomingTypingIndicatorTimeout),clearTimeout(this.optimisticTypingTimeout)}},{key:"onMessageInputChange",value:function(){this.resizeInput(),clearTimeout(this.typingIndicatorTimeout),this.hasSentTypingIndicator||(this.webChatChannel.startTypingIndicator(),this.hasSentTypingIndicator=!0),this.typingIndicatorTimeout=setTimeout((()=>{this.hasSentTypingIndicator=!1}),3e3)}},{key:"onOutboundMessageSent",value:function(e){var{data:t}=e,n={"message:sent":e=>{var t=(new DOMParser).parseFromString(e.element,"text/html").body.firstElementChild;this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(t,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(t),t.scrollIntoView({behavior:"instant"})},"message:failed":e=>{var t;null===(t=this.messagesContainerTarget.querySelector("#".concat(e.id)))||void 0===t||t.classList.add("failed")}};n[t.type]?n[t.type](t):console.log("Unhandled message event: ".concat(t.type))}},{key:"onScroll",value:(o=$o((function*(){if(!(this.messagesContainerTarget.scrollTop>300||!this.nextPageValue||this.fetchingNextPage)){this.fetchingNextPage=!0;var e=yield this.messagesAPI.index({page:this.nextPageValue,session:Nt.session}),{next:t,messages:n}=yield e.json();this.nextPageValue=t,this.oldScrollHeight=this.messagesContainerTarget.scrollHeight,n.forEach((e=>{var{body:t,attachments:n}=e,r=document.createElement("div");r.innerHTML=t;var i=this.messageTemplateTarget.cloneNode(!0);i.setAttribute("data-hellotext--webchat-target","message"),i.style.removeProperty("display"),i.querySelector("[data-body]").innerHTML=r.innerHTML,"received"===e.state?i.classList.add("received"):i.classList.remove("received"),n&&n.forEach((e=>{var t=this.attachmentImageTarget.cloneNode(!0);t.removeAttribute("data-hellotext--webchat-target"),t.src=e,t.style.display="block",i.querySelector("[data-attachment-container]").appendChild(t)})),i.setAttribute("data-body",t),this.messagesContainerTarget.prepend(i)})),this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight-this.oldScrollHeight,behavior:"instant"}),this.fetchingNextPage=!1}})),function(){return o.apply(this,arguments)})},{key:"onClickOutside",value:function(e){A.behaviour===M.POPOVER&&this.openValue&&e.target.nodeType&&!1===this.element.contains(e.target)&&(this.openValue=!1)}},{key:"closePopover",value:function(){this.popoverTarget.classList.add(...this.fadeOutClasses),setTimeout((()=>{this.openValue=!1}),250)}},{key:"onPopoverOpened",value:function(){this.popoverTarget.classList.remove(...this.fadeOutClasses),this.onMobile||this.inputTarget.focus(),this.scrolled||(requestAnimationFrame((()=>{this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight,behavior:"instant"})})),this.scrolled=!0),Nt.eventEmitter.dispatch("webchat:opened"),localStorage.setItem("hellotext--webchat--".concat(this.idValue),"opened"),"none"!==this.unreadCounterTarget.style.display&&(this.unreadCounterTarget.style.display="none",this.unreadCounterTarget.innerText="0",this.messagesAPI.markAsSeen())}},{key:"onPopoverClosed",value:function(){Nt.eventEmitter.dispatch("webchat:closed"),localStorage.setItem("hellotext--webchat--".concat(this.idValue),"closed")}},{key:"onMessageReaction",value:function(e){var{message:t,reaction:n,type:r}=e,i=this.messageTargets.find((e=>e.dataset.id===t)).querySelector("[data-reactions]");if("reaction.destroy"===r)return i.querySelector('[data-id="'.concat(n.id,'"]')).remove();if(i.querySelector('[data-id="'.concat(n.id,'"]')))i.querySelector('[data-id="'.concat(n.id,'"]')).innerText=n.emoji;else{var o=document.createElement("span");o.innerText=n.emoji,o.setAttribute("data-id",n.id),i.appendChild(o)}}},{key:"onMessageReceived",value:function(e){var{id:t,body:n,attachments:r}=e;if(e.carousel)return this.insertCarouselMessage(e);var i=document.createElement("div");i.innerHTML=n;var o=this.messageTemplateTarget.cloneNode(!0);if(o.style.display="flex",o.querySelector("[data-body]").innerHTML=i.innerHTML,o.setAttribute("data-hellotext--webchat-target","message"),r&&r.forEach((e=>{var t=this.attachmentImageTarget.cloneNode(!0);t.src=e,t.style.display="block",o.querySelector("[data-attachment-container]").appendChild(t)})),this.clearTypingIndicator(),this.messagesContainerTarget.appendChild(o),Nt.eventEmitter.dispatch("webchat:message:received",Do(Do({},e),{},{body:o.querySelector("[data-body]").innerText})),o.scrollIntoView({behavior:"smooth"}),this.openValue)this.messagesAPI.markAsSeen(t);else{this.unreadCounterTarget.style.display="flex";var s=(parseInt(this.unreadCounterTarget.innerText)||0)+1;this.unreadCounterTarget.innerText=s>99?"99+":s}}},{key:"insertCarouselMessage",value:function(e){var t,n=e.html,r=(new DOMParser).parseFromString(n,"text/html").body.firstElementChild;if(this.clearTypingIndicator(),this.messagesContainerTarget.appendChild(r),r.scrollIntoView({behavior:"smooth"}),Nt.eventEmitter.dispatch("webchat:message:received",Do(Do({},e),{},{body:(null===(t=r.querySelector("[data-body]"))||void 0===t?void 0:t.innerText)||""})),this.openValue)this.messagesAPI.markAsSeen(e.id);else{this.unreadCounterTarget.style.display="flex";var i=(parseInt(this.unreadCounterTarget.innerText)||0)+1;this.unreadCounterTarget.innerText=i>99?"99+":i}}},{key:"resizeInput",value:function(){this.inputTarget.style.height="auto";var e=this.inputTarget.scrollHeight;this.inputTarget.style.height="".concat(Math.min(e,96),"px")}},{key:"sendQuickReplyMessage",value:(i=$o((function*(e){var t,{detail:{id:n,product:r,buttonId:i,body:o,cardElement:s}}=e,a=new FormData;a.append("message[body]",o),a.append("message[replied_to]",n),a.append("message[product]",r),a.append("message[button]",i),a.append("session",Nt.session),a.append("locale",j.toString());var l=this.buildMessageElement(),c=null===(t=s.querySelector("img"))||void 0===t?void 0:t.cloneNode(!0);l.querySelector("[data-body]").innerText=o,c&&(c.removeAttribute("width"),c.removeAttribute("height"),l.querySelector("[data-attachment-container]").appendChild(c)),this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(l,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(l),l.scrollIntoView({behavior:"smooth"}),this.broadcastChannel.postMessage({type:"message:sent",element:l.outerHTML});var u=yield this.messagesAPI.create(a);if(u.failed)return clearTimeout(this.optimisticTypingTimeout),this.broadcastChannel.postMessage({type:"message:failed",id:l.id}),l.classList.add("failed");var h=yield u.json();this.dispatch("set:id",{target:l,detail:h.id});var d={id:h.id,body:o,attachments:c?[c.src]:[],replied_to:n,product:r,button:i,type:"quick_reply"};Nt.eventEmitter.dispatch("webchat:message:sent",d)})),function(e){return i.apply(this,arguments)})},{key:"sendMessage",value:(r=$o((function*(e){var t=new FormData,n={body:this.inputTarget.value,attachments:this.files};if(0!==this.inputTarget.value.trim().length||0!==this.files.length){this.inputTarget.value.trim().length>0?t.append("message[body]",this.inputTarget.value):delete n.body,this.files.forEach((e=>{t.append("message[attachments][]",e)})),t.append("session",Nt.session),t.append("locale",j.toString());var r=this.buildMessageElement();this.inputTarget.value.trim().length>0?r.querySelector("[data-body]").innerText=this.inputTarget.value:r.querySelector("[data-message-bubble]").remove();var i=this.attachmentContainerTarget.querySelectorAll("img");i.length>0&&i.forEach((e=>{r.querySelector("[data-attachment-container]").appendChild(e.cloneNode(!0))})),this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(r,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(r),r.scrollIntoView({behavior:"smooth"}),this.broadcastChannel.postMessage({type:"message:sent",element:r.outerHTML}),this.inputTarget.value="",this.resizeInput(),this.files=[],this.attachmentInputTarget.value="",this.attachmentContainerTarget.innerHTML="",this.attachmentContainerTarget.style.display="none",this.errorMessageContainerTarget.style.display="none",this.inputTarget.focus(),this.typingIndicatorVisible||(clearTimeout(this.optimisticTypingTimeout),this.optimisticTypingTimeout=setTimeout((()=>{this.showOptimisticTypingIndicator()}),this.optimisticTypingIndicatorWaitValue));var o=yield this.messagesAPI.create(t);if(o.failed)return clearTimeout(this.optimisticTypingTimeout),this.broadcastChannel.postMessage({type:"message:failed",id:r.id}),r.classList.add("failed");var s=yield o.json();r.setAttribute("data-id",s.id),n.id=s.id,Nt.eventEmitter.dispatch("webchat:message:sent",n),s.conversation!==this.conversationIdValue&&(this.conversationIdValue=s.conversation,this.webChatChannel.updateSubscriptionWith(this.conversationIdValue)),this.typingIndicatorVisible&&this.resetTypingIndicatorTimer(),this.attachmentContainerTarget.style.display=""}else e&&e.target&&e.preventDefault()})),function(e){return r.apply(this,arguments)})},{key:"buildMessageElement",value:function(){var e=this.messageTemplateTarget.cloneNode(!0);return e.id="hellotext--webchat--".concat(this.idValue,"--message--").concat(Date.now()),e.classList.add("received"),e.style.removeProperty("display"),e.setAttribute("data-controller","hellotext--message"),e.setAttribute("data-hellotext--webchat-target","message"),e}},{key:"openAttachment",value:function(){this.attachmentInputTarget.click()}},{key:"onFileInputChange",value:function(){this.errorMessageContainerTarget.style.display="none";var e=Array.from(this.attachmentInputTarget.files);this.attachmentInputTarget.value="";var t=e.find((e=>{var t=e.type.split("/")[0];return["image","video","audio"].includes(t)?this.mediaValue[t].max_sizethis.createAttachmentElement(e))),this.inputTarget.focus()}},{key:"createAttachmentElement",value:function(e){var t=this.attachmentElement();if(this.attachmentContainerTarget.style.display="",t.setAttribute("data-name",e.name),e.type.startsWith("image/")){var n=this.attachmentImageTarget.cloneNode(!0);n.src=URL.createObjectURL(e),n.style.display="block",t.appendChild(n),this.attachmentContainerTarget.appendChild(t),this.attachmentContainerTarget.style.display="flex"}else{var r=t.querySelector("main");r.style.height="5rem",r.style.borderRadius="0.375rem",r.style.backgroundColor="#e5e7eb",r.style.padding="0.25rem",t.querySelector("p[data-attachment-name]").innerText=e.name,this.attachmentContainerTarget.appendChild(t),this.attachmentContainerTarget.style.display="flex"}}},{key:"removeAttachment",value:function(e){var{currentTarget:t}=e,n=t.closest("[data-hellotext--webchat-target='attachment']");this.files=this.files.filter((e=>e.name!==n.dataset.name)),this.attachmentInputTarget.value="",n.remove(),this.inputTarget.focus()}},{key:"attachmentTargetDisconnected",value:function(){0===this.attachmentTargets.length&&(this.attachmentContainerTarget.innerHTML="",this.attachmentContainerTarget.style.display="none")}},{key:"attachmentElement",value:function(){var e=this.attachmentTemplateTarget.cloneNode(!0);return e.removeAttribute("hidden"),e.style.display="flex",e.setAttribute("data-hellotext--webchat-target","attachment"),e}},{key:"onEmojiSelect",value:function(e){var{detail:t}=e,n=this.inputTarget.value,r=this.inputTarget.selectionStart,i=this.inputTarget.selectionEnd;this.inputTarget.value=n.slice(0,r)+t+n.slice(i),this.inputTarget.selectionStart=this.inputTarget.selectionEnd=r+t.length,this.inputTarget.focus()}},{key:"byteToMegabyte",value:function(e){return Math.ceil(e/1024/1024)}},{key:"middlewares",get:function(){return[mr(this.offsetValue),vr({padding:this.paddingValue}),yr()]}},{key:"shouldOpenOnMount",get:function(){return"opened"===localStorage.getItem("hellotext--webchat--".concat(this.idValue))&&!this.onMobile}},{key:"onMobile",get:function(){return window.matchMedia("(max-width: ".concat(this.fullScreenThresholdValue,"px)")).matches}}],n&&Ho(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),c}(v.Qr);Jo.values={id:String,conversationId:String,media:Object,fileSizeErrorMessage:String,placement:{type:String,default:"bottom-end"},open:{type:Boolean,default:!1},autoPlacement:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},nextPage:{type:Number,default:void 0},fullScreenThreshold:{type:Number,default:1024},typingIndicatorKeepAlive:{type:Number,default:3e4},offset:{type:Number,default:24},padding:{type:Number,default:24},optimisticTypingIndicatorWait:{type:Number,default:1e3}},Jo.classes=["fadeOut"],Jo.targets=["trigger","popover","input","attachmentInput","attachmentButton","errorMessageContainer","attachmentTemplate","attachmentContainer","attachment","messageTemplate","messagesContainer","title","attachmentImage","footer","toolbar","message","unreadCounter","typingIndicator","typingIndicatorTemplate"];var Zo=v.Mx.start();Zo.register("hellotext--form",qt),Zo.register("hellotext--webchat",Jo),Zo.register("hellotext--webchat--emoji",xo),Zo.register("hellotext--message",Jt),window.Hellotext=Nt;const Go=Nt},989:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(81),i=n.n(r),o=n(645),s=n.n(o)()(i());s.push([e.id,"form[data-hello-form] {\n position: relative;\n}\n\nform[data-hello-form] article [data-error-container] {\n font-size: 0.875rem;\n line-height: 1.25rem;\n display: none;\n}\n\nform[data-hello-form] article:has(input:invalid) [data-error-container] {\n display: block;\n}\n\nform[data-hello-form] [data-logo-container] {\n display: flex;\n justify-content: center;\n align-items: flex-end;\n position: absolute;\n right: 1rem;\n bottom: 1rem;\n}\n\nform[data-hello-form] [data-logo-container] small {\n margin: 0 0.3rem;\n}\n\nform[data-hello-form] [data-logo-container] [data-hello-brand] {\n width: 4rem;\n}\n",""]);const a=s},645:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,i,o){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(r)for(var a=0;a0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=o),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),t.push(u))}},t}},81:e=>{e.exports=function(e){return e[1]}},379:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},216:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},795:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nc=void 0,n(599);var r=n(272);return r.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hellotext=t():e.Hellotext=t()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={599:(e,t,n)=>{n.d(t,{Mx:()=>J,Qr:()=>ie});class r{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort(((e,t)=>{const n=e.index,r=t.index;return nr?1:0}))}}class i{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((e=>e.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((e=>e.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((e,t)=>e.concat(Array.from(t.values()))),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:r}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(n,r);i.delete(o),0==i.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:r}=e;return this.fetchEventListener(t,n,r)}fetchEventListener(e,t,n){const r=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,n);let o=r.get(i);return o||(o=this.createEventListener(e,t,n),r.set(i,o)),o}createEventListener(e,t,n){const i=new r(e,t,n);return this.started&&i.connect(),i}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach((e=>{n.push(`${t[e]?"":"!"}${e}`)})),n.join(":")}}const o={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},s=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function a(e){return e.replace(/(?:[_-])([a-z0-9])/g,((e,t)=>t.toUpperCase()))}function l(e){return a(e.replace(/--/g,"-").replace(/__/g,"_"))}function c(e){return e.charAt(0).toUpperCase()+e.slice(1)}function u(e){return e.replace(/([A-Z])/g,((e,t)=>`-${t.toLowerCase()}`))}function h(e){return null!=e}function d(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const f=["meta","ctrl","alt","shift"];class p{constructor(e,t,n,r){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in m)return m[t](e)}(e)||g("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||g("missing identifier"),this.methodName=n.methodName||g("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(s)||[];let n=t[2],r=t[3];return r&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${r}`,r=""),{eventTarget:(i=t[4],"window"==i?window:"document"==i?document:void 0),eventName:n,eventOptions:t[7]?(o=t[7],o.split(":").reduce(((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)})),{})):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||r};var i,o}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const n=t.filter((e=>!f.includes(e)))[0];return!!n&&(d(this.keyMappings,n)||g(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[n].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const i=n.match(t),o=i&&i[1];o&&(e[a(o)]=v(r))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[n,r,i,o]=f.map((e=>t.includes(e)));return e.metaKey!==n||e.ctrlKey!==r||e.altKey!==i||e.shiftKey!==o}}const m={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function g(e){throw new Error(e)}function v(e){try{return JSON.parse(e)}catch(t){return e}}class y{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application,{controller:r}=this.context;let i=!0;for(const[o,s]of Object.entries(this.eventOptions))if(o in n){const a=n[o];i=i&&a({name:o,value:s,event:e,element:t,controller:r})}return i}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:r,element:i,index:o}=this,s={identifier:n,controller:r,element:i,index:o,event:e};this.context.handleError(t,`invoking action "${this.action}"`,s)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))&&!(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class b{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class w{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new b(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function _(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class k{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e.concat(Array.from(t))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((e,t)=>e+t.size),0)}add(e,t){!function(e,t,n){_(e,t).add(n)}(this.valuesByKey,e,t)}delete(e,t){!function(e,t,n){_(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some((t=>t.has(e)))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter((([t,n])=>n.has(e))).map((([e,t])=>e))}}class O{constructor(e,t,n,r){this._selector=t,this.details=r,this.elementObserver=new b(e,this),this.delegate=n,this.matchesByElement=new k}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const n=e.matches(t);return this.delegate.selectorMatchElement?n&&this.delegate.selectorMatchElement(e,this.details):n}return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const n=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(t)).filter((e=>this.matchElement(e)));return n.concat(r)}return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const n of t)this.selectorUnmatched(e,n)}elementAttributeChanged(e,t){const{selector:n}=this;if(n){const t=this.matchElement(e),r=this.matchesByElement.has(n,e);t&&!r?this.selectorMatched(e,n):!t&&r&&this.selectorUnmatched(e,n)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class C{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((e=>this.processMutations(e)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r&&this.stringMapValueChanged(r,n,t),null==r){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((e=>e.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class x{constructor(e,t,n){this.attributeObserver=new w(e,t,this),this.delegate=n,this.tokensByElement=new k}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach((e=>this.tokenMatched(e)))}tokensUnmatched(e){e.forEach((e=>this.tokenUnmatched(e)))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},((n,r)=>[e[r],t[r]]))}(t,n).findIndex((([e,t])=>{return r=t,!((n=e)&&r&&n.index==r.index&&n.content==r.content);var n,r}));return-1==r?[[],[]]:[t.slice(r),n.slice(r)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter((e=>e.length)).map(((e,r)=>({element:t,attributeName:n,content:e,index:r})))}(e.getAttribute(t)||"",e,t)}}class S{constructor(e,t,n){this.tokenListObserver=new x(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class j{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new S(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new y(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach((e=>this.delegate.bindingDisconnected(e,!0))),this.bindingsByAction.clear()}parseValueForToken(e){const t=p.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class T{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new C(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const r=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const r=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,r.writer(this.receiver[e]),n):this.invokeChangedCallback(e,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,r(n),void 0)}invokeChangedCallback(e,t,n){const r=`${e}Changed`,i=this.receiver[r];if("function"==typeof i){const r=this.valueDescriptorNameMap[e];try{const e=r.reader(t);let o=n;n&&(o=r.reader(n)),i.call(this.receiver,e,o)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map((t=>e[t]))}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach((t=>{const n=this.valueDescriptorMap[t];e[n.name]=n})),e}hasValue(e){const t=`has${c(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class E{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new k}start(){this.tokenListObserver||(this.tokenListObserver=new x(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetConnected(e,t))))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause((()=>this.delegate.targetDisconnected(e,t))))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function P(e,t){const n=M(e);return Array.from(n.reduce(((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach((t=>e.add(t))),e)),new Set))}function M(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class A{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new k,this.outletElementsByName=new k,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach((e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)})),this.started=!0,this.dependentContexts.forEach((e=>e.refresh())))}refresh(){this.selectorObserverMap.forEach((e=>e.refresh())),this.attributeObserverMap.forEach((e=>e.refresh()))}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach((e=>e.stop())),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach((e=>e.stop())),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:n}){const r=this.getOutlet(e,n);r&&this.connectOutlet(r,e,n)}selectorUnmatched(e,t,{outletName:n}){const r=this.getOutletFromMap(e,n);r&&this.disconnectOutlet(r,e,n)}selectorMatchElement(e,{outletName:t}){const n=this.selector(t),r=this.hasOutlet(e,t),i=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!n&&r&&i&&e.matches(n)}elementMatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementAttributeValueChanged(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementUnmatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}connectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletConnected(e,t,n))))}disconnectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause((()=>this.delegate.outletDisconnected(e,t,n))))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),n=new O(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,n),n.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),n=new w(this.scope.element,t,this);this.attributeObserverMap.set(e,n),n.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find((t=>this.attributeNameForOutletName(t)===e))}get outletDependencies(){const e=new k;return this.router.modules.forEach((t=>{P(t.definition.controllerConstructor,"outlets").forEach((n=>e.add(n,t.identifier)))})),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter((t=>e.includes(t.identifier)))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find((t=>t.element===e))}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class L{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:r,element:i}=this;t=Object.assign({identifier:n,controller:r,element:i},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new j(this,this.dispatcher),this.valueObserver=new T(this,this.controller),this.targetObserver=new E(this,this),this.outletObserver=new A(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:r,controller:i,element:o}=this;n=Object.assign({identifier:r,controller:i,element:o},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${l(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${l(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}const I="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,R=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e((function(){this.a.call(this)}));t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class B{constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:(t=e.controllerConstructor,function(e,t){const n=R(e),r=function(e,t){return I(t).reduce(((n,r)=>{const i=function(e,t,n){const r=Object.getOwnPropertyDescriptor(e,n);if(!r||!("value"in r)){const e=Object.getOwnPropertyDescriptor(t,n).value;return r&&(e.get=r.get||e.get,e.set=r.set||e.set),e}}(e,t,r);return i&&Object.assign(n,{[r]:i}),n}),{})}(e.prototype,t);return Object.defineProperties(n.prototype,r),n}(t,function(e){return P(e,"blessings").reduce(((t,n)=>{const r=n(e);for(const e in r){const n=t[e]||{};t[e]=Object.assign(n,r[e])}return t}),{})}(t)))};var t}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new L(this,e),this.contextsByScope.set(e,t)),t}}class F{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){return(this.data.get(this.getDataKey(e))||"").match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class D{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${u(e)}`}}class N{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let r=this.warnedKeysByObject.get(e);r||(r=new Set,this.warnedKeysByObject.set(e,r)),r.has(t)||(r.add(t),this.logger.warn(n,e))}}function z(e,t){return`[${e}~="${t}"]`}class V{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)]),[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return z(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map((t=>this.deprecate(t,e)))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return z(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,r=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${n}.${t}" with ${i}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class ${constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce(((e,t)=>e||this.findOutlet(t)),void 0)}findAll(...e){return e.reduce(((e,t)=>[...e,...this.findAllOutlets(t)]),[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter((n=>this.matchesElement(n,e,t)))}matchesElement(e,t,n){const r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(n)}}class H{constructor(e,t,n,r){this.targets=new V(this),this.classes=new F(this),this.data=new D(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new N(r),this.outlets=new $(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return z(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new H(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class q{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new S(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e;return this.parseValueForElementAndIdentifier(t,n)}parseValueForElementAndIdentifier(e,t){const n=this.fetchScopesByIdentifierForElement(e);let r=n.get(t);return r||(r=this.delegate.createScopeForElementAndIdentifier(e,t),n.set(t,r)),r}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class U{constructor(e){this.application=e,this.scopeObserver=new q(this.element,this.schema,this),this.scopesByIdentifier=new k,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((e,t)=>e.concat(t.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new B(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find((t=>t.element==e))}proposeToConnectScopeForElementAndIdentifier(e,t){const n=this.scopeObserver.parseValueForElementAndIdentifier(e,t);n?this.scopeObserver.elementMatchedValue(n.element,n):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new H(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.connectContextForScope(t)))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach((t=>e.disconnectContextForScope(t)))}}const K={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},W("abcdefghijklmnopqrstuvwxyz".split("").map((e=>[e,e])))),W("0123456789".split("").map((e=>[e,e]))))};function W(e){return e.reduce(((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n})),{})}class J{constructor(e=document.documentElement,t=K){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=t,this.dispatcher=new i(this),this.router=new U(this),this.actionDescriptorFilters=Object.assign({},o)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise((e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>e())):e()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)}))}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach((e=>this.router.unloadIdentifier(e)))}get controllers(){return this.router.contexts.map((e=>e.controller))}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var r;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(r=window.onerror)||void 0===r||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}function Z(e,t,n){return e.application.getControllerForElementAndIdentifier(t,n)}function G(e,t,n){let r=Z(e,t,n);return r||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,n),r=Z(e,t,n),r||void 0)}function X([e,t],n){return function(e){const{token:t,typeDefinition:n}=e,r=`${u(t)}-value`,i=function(e){const{controller:t,token:n,typeDefinition:r}=e,i=function(e){const{controller:t,token:n,typeObject:r}=e,i=h(r.type),o=h(r.default),s=i&&o,a=i&&!o,l=!i&&o,c=Y(r.type),u=Q(e.typeObject.default);if(a)return c;if(l)return u;if(c!==u)throw new Error(`The specified default value for the Stimulus Value "${t?`${t}.${n}`:n}" must match the defined type "${c}". The provided default value of "${r.default}" is of type "${u}".`);return s?c:void 0}({controller:t,token:n,typeObject:r}),o=Q(r),s=Y(r),a=i||o||s;if(a)return a;throw new Error(`Unknown value type "${t?`${t}.${r}`:n}" for "${n}" value`)}(e);return{type:i,key:r,name:a(r),get defaultValue(){return function(e){const t=Y(e);if(t)return ee[t];const n=d(e,"default"),r=d(e,"type"),i=e;if(n)return i.default;if(r){const{type:e}=i,t=Y(e);if(t)return ee[t]}return e}(n)},get hasCustomDefaultValue(){return void 0!==Q(n)},reader:te[i],writer:ne[i]||ne.default}}({controller:n,token:e,typeDefinition:t})}function Y(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function Q(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const ee={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},te={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${Q(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e.replace(/_/g,"")),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${Q(t)}"`);return t},string:e=>e},ne={default:function(e){return`${e}`},array:re,object:re};function re(e){return JSON.stringify(e)}class ie{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:r=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){const s=new CustomEvent(r?`${r}:${e}`:e,{detail:n,bubbles:i,cancelable:o});return t.dispatchEvent(s),s}}ie.blessings=[function(e){return P(e,"classes").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${c(n)}Class`]:{get(){return this.classes.has(n)}}});var n}),{})},function(e){return P(e,"targets").reduce(((e,t)=>{return Object.assign(e,{[`${n=t}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${c(n)}Target`]:{get(){return this.targets.has(n)}}});var n}),{})},function(e){const t=function(e,t){return M(e).reduce(((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map((e=>[e,n[e]])):[]}(n,t)),e)),[])}(e,"values"),n={valueDescriptorMap:{get(){return t.reduce(((e,t)=>{const n=X(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})}),{})}}};return t.reduce(((e,t)=>Object.assign(e,function(e,t){const n=X(e,void 0),{key:r,name:i,reader:o,writer:s}=n;return{[i]:{get(){const e=this.data.get(r);return null!==e?o(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,s(e))}},[`has${c(i)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t))),n)},function(e){return P(e,"outlets").reduce(((e,t)=>Object.assign(e,function(e){const t=l(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t){const n=G(this,t,e);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map((t=>{const n=G(this,t,e);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,t)})).filter((e=>e)):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${c(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t))),{})}],ie.targets=[],ie.outlets=[],ie.values={}},184:(e,t,n)=>{n.d(t,{default:()=>ss});var r=n(379),i=n.n(r),o=n(795),s=n.n(o),a=n(569),l=n.n(a),c=n(565),u=n.n(c),h=n(216),d=n.n(h),f=n(589),p=n.n(f),m=n(989),g={};g.styleTagTransform=p(),g.setAttributes=u(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=d(),i()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals;var v=n(599);function y(e,t){for(var n=0;n{var[t,n]=e;this[t]=n})),this}},{key:"shouldShowSuccessMessage",get:function(){return this.successMessage}}],null&&y(t.prototype,null),n&&y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function w(e,t){for(var n=0;ne.trim())):this._classes},set:function(e){if(!Array.isArray(e)&&"string"!=typeof e)throw new Error("classes must be an array or a string");this._classes=e}},{key:"triggerClasses",get:function(){return"string"==typeof this._triggerClasses?this._triggerClasses.split(",").map((e=>e.trim())):this._triggerClasses},set:function(e){if(!Array.isArray(e)&&"string"!=typeof e)throw new Error("triggerClasses must be an array or a string");this._triggerClasses=e}},{key:"id",get:function(){return this._id},set:function(e){this._id=e}},{key:"isSet",get:function(){return!!this._id}},{key:"style",get:function(){return this._style},set:function(e){if("object"!=typeof e)throw new Error("Style must be an object");Object.entries(e).forEach((e=>{var[t,n]=e;if(!["primaryColor","secondaryColor","typography"].includes(t))throw new Error("Invalid style property: ".concat(t));if("typography"!==t&&!this.isHexOrRgba(n))throw new Error("Invalid color value: ".concat(n," for ").concat(t,". Colors must be hex or rgb/a."))})),this._style=e}},{key:"behaviour",get:function(){return this._behaviour},set:function(e){if(!Object.values(M).includes(e))throw new Error("Invalid behaviour value: ".concat(e));this._behaviour=e}},{key:"strategy",get:function(){return this._strategy?this._strategy:"body"==this.container?P.FIXED:P.ABSOLUTE},set:function(e){if(e&&!Object.values(P).includes(e))throw new Error("Invalid strategy value: ".concat(e));this._strategy=e}},{key:"assign",value:function(e){return e&&Object.entries(e).forEach((e=>{var[t,n]=e;this[t]=n})),this}},{key:"isHexOrRgba",value:function(e){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(e)||/^rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3},?\s*(0|1|0?\.\d+)?\s*\)$/.test(e)}}],null&&T(t.prototype,null),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function L(e,t){for(var n=0;n{var[t,n]=e;"forms"===t?this.forms=b.assign(n):"webchat"===t?this.webchat=A.assign(n):this[t]=n})),this}},{key:"locale",get:function(){return j.toString()},set:function(e){j.identifier=e}},{key:"endpoint",value:function(e){return"".concat(this.apiRoot,"/").concat(e)}}],null&&L(t.prototype,null),n&&L(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function R(e){var t="function"==typeof Map?new Map:void 0;return R=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return B(e,arguments,N(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),D(r,e)},R(e)}function B(e,t,n){return B=F()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&D(i,n.prototype),i},B.apply(null,arguments)}function F(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function D(e,t){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},D(e,t)}function N(e){return N=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},N(e)}I.apiRoot="https://api.hellotext.com/v1",I.actionCableUrl="wss://www.hellotext.com/cable",I.autoGenerateSession=!0,I.session=null,I.forms=b,I.webchat=A;var z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&D(e,t)}(o,e);var t,n,r,i=(n=o,r=F(),function(){var e,t=N(n);if(r){var i=N(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function o(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(t=i.call(this,"".concat(e," is not valid. Please provide a valid event name"))).name="InvalidEvent",t}return t=o,Object.defineProperty(t,"prototype",{writable:!1}),t}(R(Error));function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $(e){for(var t=1;tt===e))}}],(n=[{key:"addSubscriber",value:function(t,n){if(e.invalid(t))throw new z(t);this.subscribers=$($({},this.subscribers),{},{[t]:this.subscribers[t]?[...this.subscribers[t],n]:[n]})}},{key:"removeSubscriber",value:function(t,n){if(e.invalid(t))throw new z(t);this.subscribers[t]&&(this.subscribers[t]=this.subscribers[t].filter((e=>e!==n)))}},{key:"dispatch",value:function(e,t){var n;null===(n=this.subscribers[e])||void 0===n||n.forEach((e=>{e(t)}))}},{key:"listeners",get:function(){return 0!==Object.keys(this.subscribers).length}}])&&q(t.prototype,n),r&&q(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function W(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function J(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=yield fetch(this.endpoint,{method:"POST",headers:Jt.headers,body:JSON.stringify(ve({session:Jt.session},e))});return new ie(t.ok,t)},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){be(o,n,i,s,a,"next",e)}function a(e){be(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})}],null&&we(t.prototype,null),n&&we(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Oe(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function Ce(e,t){for(var n=0;n{var[n,r]=e;t.searchParams.append("style[".concat(n,"]"),r)})),t.searchParams.append("placement",I.webchat.placement);var n=yield fetch(t,{method:"GET",headers:Jt.headers}),r=yield n.json();return Jt.business.data||(Jt.business.setData(r.business),Jt.business.setLocale(r.locale)),(new DOMParser).parseFromString(r.html,"text/html").querySelector("article")},function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){Oe(o,r,i,s,a,"next",e)}function a(e){Oe(o,r,i,s,a,"throw",e)}s(void 0)}))});return function(e){return t.apply(this,arguments)}}()}],n&&Ce(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();const Se=xe;function je(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function Te(e,t){for(var n=0;n{var[t,n]=e;return n})));ze.set("hello_utm",JSON.stringify(r))}}var t,n;return t=e,(n=[{key:"current",get:function(){try{return JSON.parse(ze.get("hello_utm"))||{}}catch(e){return{}}}}])&&Re(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Fe(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.utm=new Be,this._url=t}var t,n,r;return t=e,r=[{key:"getRootDomain",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;try{if(!e){var t;if("undefined"==typeof window||null===(t=window.location)||void 0===t||!t.hostname)return null;e=window.location.hostname}var n=e.split(".");if(n.length<=1)return e;for(var r of["myshopify.com","vtexcommercestable.com.br","myvtex.com","wixsite.com"]){var i=r.split(".");if(n.slice(-i.length).join(".")===r&&n.length>i.length)return".".concat(n.slice(-(i.length+1)).join("."))}var o=n[n.length-1],s=n[n.length-2];return n.length>2&&2===o.length&&s.length<=3?".".concat(n.slice(-3).join(".")):".".concat(n.slice(-2).join("."))}catch(e){return null}}}],(n=[{key:"url",get:function(){return null!==this._url&&void 0!==this._url?this._url:window.location.href}},{key:"title",get:function(){return document.title}},{key:"path",get:function(){if(this._url)try{return new URL(this._url).pathname}catch(e){return"/"}return window.location.pathname}},{key:"utmParams",get:function(){return this.utm.current}},{key:"trackingData",get:function(){return{page:{url:this.url,title:this.title,path:this.path},utm_params:this.utmParams}}},{key:"domain",get:function(){try{var t=this.url;if(!t)return null;var n=new URL(t).hostname;return e.getRootDomain(n)}catch(e){return null}}}])&&Fe(t.prototype,n),r&&Fe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ne(e,t){for(var n=0;n\n ".concat(Jt.business.locale.white_label.powered_by,'\n\n \n \n Hellotext\n \n \n \n \n ')}});var at=0;function lt(e){return"__private_"+at+++"_"+e}var ct=lt("findOrCreateComponent"),ut=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,ct,{value:ht}),this.data=t,this.element=n||document.querySelector('[data-hello-form="'.concat(this.id,'"]'))||document.createElement("form")}var t,n,r,i;return t=e,n=[{key:"mount",value:(r=function*(){var e,{ifCompleted:t=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&this.hasBeenCompleted)return null===(e=this.element)||void 0===e||e.remove(),Jt.eventEmitter.dispatch("form:completed",function(e){for(var t=1;t{this.element.setAttribute(e.name,e.value)})),document.contains(this.element)||document.body.appendChild(this.element),Jt.business.features.white_label||this.element.prepend(et.build())},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){rt(o,n,i,s,a,"next",e)}function a(e){rt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})},{key:"buildHeader",value:function(e){var t=st(this,ct)[ct]("[data-form-header]","header");t.innerHTML=e.content,this.element.querySelector("[data-form-header]")?this.element.querySelector("[data-form-header]").replaceWith(t):this.element.prepend(t)}},{key:"buildInputs",value:function(e){var t=st(this,ct)[ct]("[data-form-inputs]","main");e.map((e=>Ze.build(e))).forEach((e=>t.appendChild(e))),this.element.querySelector("[data-form-inputs]")?this.element.querySelector("[data-form-inputs]").replaceWith(t):this.element.querySelector("[data-form-header]").insertAdjacentHTML("afterend",t.outerHTML)}},{key:"buildButton",value:function(e){var t=st(this,ct)[ct]("[data-form-button]","button");t.innerText=e.text,t.setAttribute("data-action","click->hellotext--form#submit"),t.setAttribute("data-hellotext--form-target","button"),this.element.querySelector("[data-form-button]")?this.element.querySelector("[data-form-button]").replaceWith(t):this.element.querySelector("[data-form-inputs]").insertAdjacentHTML("afterend",t.outerHTML)}},{key:"buildFooter",value:function(e){var t=st(this,ct)[ct]("[data-form-footer]","footer");t.innerHTML=e.content,this.element.querySelector("[data-form-footer]")?this.element.querySelector("[data-form-footer]").replaceWith(t):this.element.appendChild(t)}},{key:"markAsCompleted",value:function(e){var t={state:"completed",id:this.id,data:e,completedAt:(new Date).getTime()};localStorage.setItem("hello-form-".concat(this.id),JSON.stringify(t)),Jt.eventEmitter.dispatch("form:completed",t)}},{key:"hasBeenCompleted",get:function(){return null!==localStorage.getItem("hello-form-".concat(this.id))}},{key:"id",get:function(){return this.data.id}},{key:"localeAuthKey",get:function(){var e=this.data.steps[0];return e.inputs.some((e=>"email"===e.kind))&&e.inputs.some((e=>"phone"===e.kind))?"phone_and_email":e.inputs.some((e=>"email"===e.kind))?"email":e.inputs.some((e=>"phone"===e.kind))?"phone":"none"}},{key:"elementAttributes",get:function(){return[{name:"data-controller",value:"hellotext--form"},{name:"data-hello-form",value:this.id},{name:"data-hellotext--form-data-value",value:JSON.stringify(this.data)}]}}],n&&it(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function ht(e,t){var n=this.element.querySelector(e);if(n)return n.cloneNode(!0);var r=document.createElement(t);return r.setAttribute(e.replace("[","").replace("]",""),""),r}function dt(e){var t="function"==typeof Map?new Map:void 0;return dt=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return ft(e,arguments,gt(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),mt(r,e)},dt(e)}function ft(e,t,n){return ft=pt()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&mt(i,n.prototype),i},ft.apply(null,arguments)}function pt(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function mt(e,t){return mt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},mt(e,t)}function gt(e){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},gt(e)}var vt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&mt(e,t)}(o,e);var t,n,r,i=(n=o,r=pt(),function(){var e,t=gt(n);if(r){var i=gt(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,e)});function o(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(e=i.call(this,"You need to initialize before tracking events. Call Hellotext.initialize and pass your public business id")).name="NotInitializedError",e}return t=o,Object.defineProperty(t,"prototype",{writable:!1}),t}(dt(Error));function yt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function bt(e,t){for(var n=0;n0&&this.collect()}},{key:"formMutationObserver",value:function(e){e.find((e=>"childList"===e.type&&e.addedNodes.length>0))&&Array.from(document.querySelectorAll("[data-hello-form]")).length>0&&this.collect()}},{key:"collect",value:(r=function*(){if(Jt.notInitialized)throw new vt;if(!this.fetching){if("undefined"==typeof document||!("querySelectorAll"in document))return console.warn("Document is not defined, collection is not possible. Please make sure to initialize the library after the document is loaded.");var e=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(this,kt)[kt];if(0!==e.length){var t=e.map((e=>me.get(e).then((e=>e.json()))));this.fetching=!0,yield Promise.all(t).then((e=>e.forEach(this.add))).then((()=>Jt.eventEmitter.dispatch("forms:collected",this))).then((()=>this.fetching=!1)),I.forms.autoMount&&this.forms.forEach((e=>e.mount()))}}},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){yt(o,n,i,s,a,"next",e)}function a(e){yt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(){return i.apply(this,arguments)})},{key:"forEach",value:function(e){this.forms.forEach(e)}},{key:"map",value:function(e){return this.forms.map(e)}},{key:"add",value:function(e){this.includes(e.id)||(Jt.business.data||(Jt.business.setData(e.business),Jt.business.setLocale(j.toString())),Jt.business.enabledWhitelist||console.warn("No whitelist has been configured. It is advised to whitelist the domain to avoid bots from submitting forms."),this.forms.push(new ut(e)))}},{key:"getById",value:function(e){return this.forms.find((t=>t.id===e))}},{key:"getByIndex",value:function(e){return this.forms[e]}},{key:"includes",value:function(e){return this.forms.some((t=>t.id===e))}},{key:"excludes",value:function(e){return!this.includes(e)}},{key:"length",get:function(){return this.forms.length}}],n&&bt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Ct(){return Array.from(document.querySelectorAll("[data-hello-form]")).map((e=>e.dataset.helloForm)).filter(this.excludes)}function xt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function St(e,t){for(var n=0;nBt(e))).filter((e=>void 0!==e));if(e instanceof Date)return e.toISOString();if("object"==typeof e){var n=Object.keys(e).sort(((e,t)=>e.localeCompare(t))).reduce(((t,n)=>{var r=Bt(e[n]);return void 0!==r&&(t[n]=r),t}),{});return Object.keys(n).length>0?n:void 0}return"number"==typeof e||"boolean"==typeof e?e:void 0}}function Ft(e,t){var n=Bt(function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:{}))||{};return JSON.stringify(n)}function Dt(){return(Dt=At((function*(e){var t;if(null===(t=globalThis.crypto)||void 0===t||!t.subtle||"undefined"==typeof TextEncoder)return function(e){for(var t=5381,n=0;n>>0).toString(16))}(e);var n=yield globalThis.crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e)),r=Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("");return"v1:".concat(r)}))).apply(this,arguments)}var Nt=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,r;return t=e,null,n=[{key:"matches",value:function(e,t){return!!e&&e===t}},{key:"generate",value:(r=At((function*(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return yield function(e){return Dt.apply(this,arguments)}(Ft(e,t,n))})),function(e,t){return r.apply(this,arguments)})}],n&&Pt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function zt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vt(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};if(this.notInitialized)throw new vt;var n=Vt(Vt({},t&&t.headers||{}),this.headers),r=Vt(Vt({},Et.identificationData),t.user_parameters||{}),i=t&&t.url?new De(t.url):this.page,o=Vt(Vt({session:this.session,user_parameters:r,action:e},t),i.trackingData);return delete o.headers,yield Me.events.create({headers:n,body:o})})),function(e){return i.apply(this,arguments)})},{key:"identify",value:(r=qt((function*(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=yield Nt.generate(this.session,e,n);if(Nt.matches(Et.fingerprint,r))return new ie(!0,{json:(t=qt((function*(){return{already_identified:!0}})),function(){return t.apply(this,arguments)})});var i=yield Me.identifications.create(Vt({user_id:e},n));return i.succeeded&&Et.remember(e,n.source,r),i})),function(e){return r.apply(this,arguments)})},{key:"forget",value:function(){Et.forget()}},{key:"on",value:function(e,t){this.eventEmitter.addSubscriber(e,t)}},{key:"removeEventListener",value:function(e,t){this.eventEmitter.removeSubscriber(e,t)}},{key:"session",get:function(){return We.session}},{key:"isInitialized",get:function(){return void 0!==We.session}},{key:"notInitialized",get:function(){return!this.business||void 0===this.business.id}},{key:"headers",get:function(){if(this.notInitialized)throw new vt;return{Authorization:"Bearer ".concat(this.business.id),Accept:"application/json","Content-Type":"application/json"}}}],n&&Ut(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();Wt.eventEmitter=new K,Wt.forms=void 0,Wt.business=void 0,Wt.webchat=void 0;const Jt=Wt;function Zt(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(e){return void n(e)}a.done?t(l):Promise.resolve(l).then(r,i)}function Gt(e,t){for(var n=0;n{var{type:t,parameter:n}=e,r=this.inputTargets.find((e=>e.name===n));r.setCustomValidity(Jt.business.locale.errors[t]),r.reportValidity(),r.addEventListener("input",(()=>{r.setCustomValidity(""),r.reportValidity()}))})),this.showErrorMessages();this.buttonTarget.style.display="none",this.element.querySelectorAll("input").forEach((e=>e.disabled=!0)),this.completed()},i=function(){var e=this,t=arguments;return new Promise((function(n,i){var o=r.apply(e,t);function s(e){Zt(o,n,i,s,a,"next",e)}function a(e){Zt(o,n,i,s,a,"throw",e)}s(void 0)}))},function(e){return i.apply(this,arguments)})},{key:"completed",value:function(){if(this.form.markAsCompleted(this.formData),!I.forms.shouldShowSuccessMessage)return this.element.remove();"string"==typeof I.forms.successMessage?this.element.innerHTML=I.forms.successMessage:this.element.innerHTML=Jt.business.locale.forms[this.form.localeAuthKey]}},{key:"showErrorMessages",value:function(){this.inputTargets.forEach((e=>{var t=e.closest("article").querySelector("[data-error-container]");e.validity.valid?t.innerText="":t.innerText=e.validationMessage}))}},{key:"clearErrorMessages",value:function(){this.inputTargets.forEach((e=>{e.setCustomValidity(""),e.closest("article").querySelector("[data-error-container]").innerText=""}))}},{key:"inputTargetConnected",value:function(e){e.getAttribute("data-default-value")&&(e.value=e.getAttribute("data-default-value"))}},{key:"requiredInputs",get:function(){return this.inputTargets.filter((e=>e.required))}},{key:"invalid",get:function(){return!this.element.checkValidity()}}],n&&Gt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),l}(v.Qr);function tn(e,t){for(var n=0;n0?this.leftFadeTarget.classList.remove("hidden"):this.leftFadeTarget.classList.add("hidden"),ee.concat(t,t+"-"+sn[0],t+"-"+sn[1])),[]),ln=Math.min,cn=Math.max,un=Math.round,hn=Math.floor,dn=e=>({x:e,y:e}),fn={left:"right",right:"left",bottom:"top",top:"bottom"},pn={start:"end",end:"start"};function mn(e,t,n){return cn(e,ln(t,n))}function gn(e,t){return"function"==typeof e?e(t):e}function vn(e){return e.split("-")[0]}function yn(e){return e.split("-")[1]}function bn(e){return"x"===e?"y":"x"}function wn(e){return"y"===e?"height":"width"}const _n=new Set(["top","bottom"]);function kn(e){return _n.has(vn(e))?"y":"x"}function On(e){return bn(kn(e))}function Cn(e,t,n){void 0===n&&(n=!1);const r=yn(e),i=On(e),o=wn(i);let s="x"===i?r===(n?"end":"start")?"right":"left":"start"===r?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=Pn(s)),[s,Pn(s)]}function xn(e){return e.replace(/start|end/g,(e=>pn[e]))}const Sn=["left","right"],jn=["right","left"],Tn=["top","bottom"],En=["bottom","top"];function Pn(e){return e.replace(/left|right|bottom|top/g,(e=>fn[e]))}function Mn(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function An(e,t,n){let{reference:r,floating:i}=e;const o=kn(t),s=On(t),a=wn(s),l=vn(t),c="y"===o,u=r.x+r.width/2-i.width/2,h=r.y+r.height/2-i.height/2,d=r[a]/2-i[a]/2;let f;switch(l){case"top":f={x:u,y:r.y-i.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-i.width,y:h};break;default:f={x:r.x,y:r.y}}switch(yn(t)){case"start":f[s]-=d*(n&&c?-1:1);break;case"end":f[s]+=d*(n&&c?-1:1)}return f}async function Ln(e,t){var n;void 0===t&&(t={});const{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:d=!1,padding:f=0}=gn(t,e),p=function(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}(f),m=a[d?"floating"===h?"reference":"floating":h],g=Mn(await o.getClippingRect({element:null==(n=await(null==o.isElement?void 0:o.isElement(m)))||n?m:m.contextElement||await(null==o.getDocumentElement?void 0:o.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v="floating"===h?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,y=await(null==o.getOffsetParent?void 0:o.getOffsetParent(a.floating)),b=await(null==o.isElement?void 0:o.isElement(y))&&await(null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},w=Mn(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:y,strategy:l}):v);return{top:(g.top-w.top+p.top)/b.y,bottom:(w.bottom-g.bottom+p.bottom)/b.y,left:(g.left-w.left+p.left)/b.x,right:(w.right-g.right+p.right)/b.x}}const In=new Set(["left","top"]);function Rn(){return"undefined"!=typeof window}function Bn(e){return Nn(e)?(e.nodeName||"").toLowerCase():"#document"}function Fn(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function Dn(e){var t;return null==(t=(Nn(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function Nn(e){return!!Rn()&&(e instanceof Node||e instanceof Fn(e).Node)}function zn(e){return!!Rn()&&(e instanceof Element||e instanceof Fn(e).Element)}function Vn(e){return!!Rn()&&(e instanceof HTMLElement||e instanceof Fn(e).HTMLElement)}function $n(e){return!(!Rn()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof Fn(e).ShadowRoot)}const Hn=new Set(["inline","contents"]);function qn(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=nr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Hn.has(i)}const Un=new Set(["table","td","th"]);function Kn(e){return Un.has(Bn(e))}const Wn=[":popover-open",":modal"];function Jn(e){return Wn.some((t=>{try{return e.matches(t)}catch(e){return!1}}))}const Zn=["transform","translate","scale","rotate","perspective"],Gn=["transform","translate","scale","rotate","perspective","filter"],Xn=["paint","layout","strict","content"];function Yn(e){const t=Qn(),n=zn(e)?nr(e):e;return Zn.some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||Gn.some((e=>(n.willChange||"").includes(e)))||Xn.some((e=>(n.contain||"").includes(e)))}function Qn(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const er=new Set(["html","body","#document"]);function tr(e){return er.has(Bn(e))}function nr(e){return Fn(e).getComputedStyle(e)}function rr(e){return zn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ir(e){if("html"===Bn(e))return e;const t=e.assignedSlot||e.parentNode||$n(e)&&e.host||Dn(e);return $n(t)?t.host:t}function or(e){const t=ir(e);return tr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Vn(t)&&qn(t)?t:or(t)}function sr(e,t,n){var r;void 0===t&&(t=[]),void 0===n&&(n=!0);const i=or(e),o=i===(null==(r=e.ownerDocument)?void 0:r.body),s=Fn(i);if(o){const e=ar(s);return t.concat(s,s.visualViewport||[],qn(i)?i:[],e&&n?sr(e):[])}return t.concat(i,sr(i,[],n))}function ar(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function lr(e){const t=nr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Vn(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=un(n)!==o||un(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function cr(e){return zn(e)?e:e.contextElement}function ur(e){const t=cr(e);if(!Vn(t))return dn(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=lr(t);let s=(o?un(n.width):n.width)/r,a=(o?un(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const hr=dn(0);function dr(e){const t=Fn(e);return Qn()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:hr}function fr(e,t,n,r){void 0===t&&(t=!1),void 0===n&&(n=!1);const i=e.getBoundingClientRect(),o=cr(e);let s=dn(1);t&&(r?zn(r)&&(s=ur(r)):s=ur(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==Fn(e))&&t}(o,n,r)?dr(o):dn(0);let l=(i.left+a.x)/s.x,c=(i.top+a.y)/s.y,u=i.width/s.x,h=i.height/s.y;if(o){const e=Fn(o),t=r&&zn(r)?Fn(r):r;let n=e,i=ar(n);for(;i&&r&&t!==n;){const e=ur(i),t=i.getBoundingClientRect(),r=nr(i),o=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,s=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;l*=e.x,c*=e.y,u*=e.x,h*=e.y,l+=o,c+=s,n=Fn(i),i=ar(n)}}return Mn({width:u,height:h,x:l,y:c})}function pr(e,t){const n=rr(e).scrollLeft;return t?t.left+n:fr(Dn(e)).left+n}function mr(e,t,n){void 0===n&&(n=!1);const r=e.getBoundingClientRect();return{x:r.left+t.scrollLeft-(n?0:pr(e,r)),y:r.top+t.scrollTop}}const gr=new Set(["absolute","fixed"]);function vr(e,t,n){let r;if("viewport"===t)r=function(e,t){const n=Fn(e),r=Dn(e),i=n.visualViewport;let o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;const e=Qn();(!e||e&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a,y:l}}(e,n);else if("document"===t)r=function(e){const t=Dn(e),n=rr(e),r=e.ownerDocument.body,i=cn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=cn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+pr(e);const a=-n.scrollTop;return"rtl"===nr(r).direction&&(s+=cn(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}(Dn(e));else if(zn(t))r=function(e,t){const n=fr(e,!0,"fixed"===t),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=Vn(e)?ur(e):dn(1);return{width:e.clientWidth*o.x,height:e.clientHeight*o.y,x:i*o.x,y:r*o.y}}(t,n);else{const n=dr(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Mn(r)}function yr(e,t){const n=ir(e);return!(n===t||!zn(n)||tr(n))&&("fixed"===nr(n).position||yr(n,t))}function br(e,t,n){const r=Vn(t),i=Dn(t),o="fixed"===n,s=fr(e,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=dn(0);function c(){l.x=pr(i)}if(r||!r&&!o)if(("body"!==Bn(t)||qn(i))&&(a=rr(t)),r){const e=fr(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}else i&&c();o&&!r&&i&&c();const u=!i||r||o?dn(0):mr(i,a);return{x:s.left+a.scrollLeft-l.x-u.x,y:s.top+a.scrollTop-l.y-u.y,width:s.width,height:s.height}}function wr(e){return"static"===nr(e).position}function _r(e,t){if(!Vn(e)||"fixed"===nr(e).position)return null;if(t)return t(e);let n=e.offsetParent;return Dn(e)===n&&(n=n.ownerDocument.body),n}function kr(e,t){const n=Fn(e);if(Jn(e))return n;if(!Vn(e)){let t=ir(e);for(;t&&!tr(t);){if(zn(t)&&!wr(t))return t;t=ir(t)}return n}let r=_r(e,t);for(;r&&Kn(r)&&wr(r);)r=_r(r,t);return r&&tr(r)&&wr(r)&&!Yn(r)?n:r||function(e){let t=ir(e);for(;Vn(t)&&!tr(t);){if(Yn(t))return t;if(Jn(t))return null;t=ir(t)}return null}(e)||n}const Or={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o="fixed"===i,s=Dn(r),a=!!t&&Jn(t.floating);if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},c=dn(1);const u=dn(0),h=Vn(r);if((h||!h&&!o)&&(("body"!==Bn(r)||qn(s))&&(l=rr(r)),Vn(r))){const e=fr(r);c=ur(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}const d=!s||h||o?dn(0):mr(s,l,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:n.y*c.y-l.scrollTop*c.y+u.y+d.y}},getDocumentElement:Dn,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[..."clippingAncestors"===n?Jn(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let r=sr(e,[],!1).filter((e=>zn(e)&&"body"!==Bn(e))),i=null;const o="fixed"===nr(e).position;let s=o?ir(e):e;for(;zn(s)&&!tr(s);){const t=nr(s),n=Yn(s);n||"fixed"!==t.position||(i=null),(o?!n&&!i:!n&&"static"===t.position&&i&&gr.has(i.position)||qn(s)&&!n&&yr(e,s))?r=r.filter((e=>e!==s)):i=t,s=ir(s)}return t.set(e,r),r}(t,this._c):[].concat(n),r],s=o[0],a=o.reduce(((e,n)=>{const r=vr(t,n,i);return e.top=cn(r.top,e.top),e.right=ln(r.right,e.right),e.bottom=ln(r.bottom,e.bottom),e.left=cn(r.left,e.left),e}),vr(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:kr,getElementRects:async function(e){const t=this.getOffsetParent||kr,n=this.getDimensions,r=await n(e.floating);return{reference:br(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=lr(e);return{width:t,height:n}},getScale:ur,isElement:zn,isRTL:function(e){return"rtl"===nr(e).direction}};function Cr(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}const xr=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:s,middlewareData:a}=t,l=await async function(e,t){const{placement:n,platform:r,elements:i}=e,o=await(null==r.isRTL?void 0:r.isRTL(i.floating)),s=vn(n),a=yn(n),l="y"===kn(n),c=In.has(s)?-1:1,u=o&&l?-1:1,h=gn(t,e);let{mainAxis:d,crossAxis:f,alignmentAxis:p}="number"==typeof h?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&"number"==typeof p&&(f="end"===a?-1*p:p),l?{x:f*u,y:d*c}:{x:d*c,y:f*u}}(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(r=a.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},Sr=function(e){return void 0===e&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:o,middlewareData:s,placement:a,platform:l,elements:c}=t,{crossAxis:u=!1,alignment:h,allowedPlacements:d=an,autoAlignment:f=!0,...p}=gn(e,t),m=void 0!==h||d===an?function(e,t,n){return(e?[...n.filter((t=>yn(t)===e)),...n.filter((t=>yn(t)!==e))]:n.filter((e=>vn(e)===e))).filter((n=>!e||yn(n)===e||!!t&&xn(n)!==n))}(h||null,f,d):d,g=await Ln(t,p),v=(null==(n=s.autoPlacement)?void 0:n.index)||0,y=m[v];if(null==y)return{};const b=Cn(y,o,await(null==l.isRTL?void 0:l.isRTL(c.floating)));if(a!==y)return{reset:{placement:m[0]}};const w=[g[vn(y)],g[b[0]],g[b[1]]],_=[...(null==(r=s.autoPlacement)?void 0:r.overflows)||[],{placement:y,overflows:w}],k=m[v+1];if(k)return{data:{index:v+1,overflows:_},reset:{placement:k}};const O=_.map((e=>{const t=yn(e.placement);return[e.placement,t&&u?e.overflows.slice(0,2).reduce(((e,t)=>e+t),0):e.overflows[0],e.overflows]})).sort(((e,t)=>e[1]-t[1])),C=(null==(i=O.filter((e=>e[2].slice(0,yn(e[0])?2:3).every((e=>e<=0))))[0])?void 0:i[0])||O[0][0];return C!==a?{data:{index:v+1,overflows:_},reset:{placement:C}}:{}}}},jr=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=gn(e,t),c={x:n,y:r},u=await Ln(t,l),h=kn(vn(i)),d=bn(h);let f=c[d],p=c[h];if(o){const e="y"===d?"bottom":"right";f=mn(f+u["y"===d?"top":"left"],f,f-u[e])}if(s){const e="y"===h?"bottom":"right";p=mn(p+u["y"===h?"top":"left"],p,p-u[e])}const m=a.fn({...t,[d]:f,[h]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[d]:o,[h]:s}}}}}},Tr=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:d,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=gn(e,t);if(null!=(n=o.arrow)&&n.alignmentOffset)return{};const v=vn(i),y=kn(a),b=vn(a)===a,w=await(null==l.isRTL?void 0:l.isRTL(c.floating)),_=d||(b||!m?[Pn(a)]:function(e){const t=Pn(e);return[xn(e),t,xn(t)]}(a)),k="none"!==p;!d&&k&&_.push(...function(e,t,n,r){const i=yn(e);let o=function(e,t,n){switch(e){case"top":case"bottom":return n?t?jn:Sn:t?Sn:jn;case"left":case"right":return t?Tn:En;default:return[]}}(vn(e),"start"===n,r);return i&&(o=o.map((e=>e+"-"+i)),t&&(o=o.concat(o.map(xn)))),o}(a,m,p,w));const O=[a,..._],C=await Ln(t,g),x=[];let S=(null==(r=o.flip)?void 0:r.overflows)||[];if(u&&x.push(C[v]),h){const e=Cn(i,s,w);x.push(C[e[0]],C[e[1]])}if(S=[...S,{placement:i,overflows:x}],!x.every((e=>e<=0))){var j,T;const e=((null==(j=o.flip)?void 0:j.index)||0)+1,t=O[e];if(t&&("alignment"!==h||y===kn(t)||S.every((e=>kn(e.placement)!==y||e.overflows[0]>0))))return{data:{index:e,overflows:S},reset:{placement:t}};let n=null==(T=S.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:T.placement;if(!n)switch(f){case"bestFit":{var E;const e=null==(E=S.filter((e=>{if(k){const t=kn(e.placement);return t===y||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:E[0];e&&(n=e);break}case"initialPlacement":n=a}if(i!==n)return{reset:{placement:n}}}return{}}}},Er=JSON.parse('{"search":"Search","search_no_results_1":"Oh no!","search_no_results_2":"That emoji couldn’t be found","pick":"Pick an emoji…","add_custom":"Add custom emoji","categories":{"activity":"Activity","custom":"Custom","flags":"Flags","foods":"Food & Drink","frequent":"Frequently used","nature":"Animals & Nature","objects":"Objects","people":"Smileys & People","places":"Travel & Places","search":"Search Results","symbols":"Symbols"},"skins":{"1":"Default","2":"Light","3":"Medium-Light","4":"Medium","5":"Medium-Dark","6":"Dark","choose":"Choose default skin tone"}}'),Pr=JSON.parse('{"search":"Buscar","search_no_results_1":"Vaya!","search_no_results_2":"Ese emoji no se pudo encontrar","pick":"Elige un emoji…","add_custom":"Añadir emoji personalizado","categories":{"activity":"Actividades","custom":"Personalizados","flags":"Banderas","foods":"Comida y Bebida","frequent":"Usados con frecuencia","nature":"Animales y Naturaleza","objects":"Objetos","people":"Emoticonos y Personas","places":"Viajes y Destinos","search":"Resultados de la búsqueda","symbols":"Símbolos"},"skins":{"1":"Sin tono","2":"Claro","3":"Medio-Claro","4":"Medio","5":"Medio-Oscuro","6":"Oscuro","choose":"Elige el tono de piel predeterminado"}}');function Mr(e){return e&&e.__esModule?e.default:e}function Ar(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Lr,Ir,Rr,Br,Fr,Dr,Nr={},zr=[],Vr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function $r(e,t){for(var n in t)e[n]=t[n];return e}function Hr(e){var t=e.parentNode;t&&t.removeChild(e)}function qr(e,t,n){var r,i,o,s={};for(o in t)"key"==o?r=t[o]:"ref"==o?i=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?Lr.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return Ur(e,s,r,i,null)}function Ur(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==i?++Rr:i};return null==i&&null!=Ir.vnode&&Ir.vnode(o),o}function Kr(e){return e.children}function Wr(e,t){this.props=e,this.context=t}function Jr(e,t){if(null==t)return e.__?Jr(e.__,e.__.__k.indexOf(e)+1):null;for(var n;t0?Ur(f.type,f.props,f.key,null,f.__v):f)){if(f.__=n,f.__b=n.__b+1,null===(d=v[u])||d&&f.key==d.key&&f.type===d.type)v[u]=void 0;else for(h=0;h{let e=null;try{navigator.userAgent.includes("jsdom")||(e=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}))}catch{}if(!e)return()=>!1;const t=20,n=Math.floor(12.5);return e.font=n+"px Arial, Sans-Serif",e.textBaseline="top",e.canvas.width=40,e.canvas.height=25,n=>{e.clearRect(0,0,40,25),e.fillStyle="#FF0000",e.fillText(n,0,22),e.fillStyle="#0000FF",e.fillText(n,t,22);const r=e.getImageData(0,0,t,25).data,i=r.length;let o=0;for(;o=i)return!1;const s=t+o/4%t,a=Math.floor(o/4/t),l=e.getImageData(s,a,1,1).data;return r[o]===l[0]&&r[o+2]===l[2]&&!(e.measureText(n).width>=t)}})();var wi={latestVersion:function(){for(const{v:e,emoji:t}of vi)if(yi(t))return e},noCountryFlags:function(){return!yi("🇨🇦")}};const _i=["+1","grinning","kissing_heart","heart_eyes","laughing","stuck_out_tongue_winking_eye","sweat_smile","joy","scream","disappointed","unamused","weary","sob","sunglasses","heart"];let ki=null;var Oi={add:function(e){ki||(ki=mi("frequently")||{});const t=e.id||e;t&&(ki[t]||(ki[t]=0),ki[t]+=1,pi("last",t),pi("frequently",ki))},get:function({maxFrequentRows:e,perLine:t}){if(!e)return[];ki||(ki=mi("frequently"));let n=[];if(!ki){ki={};for(let e in _i.slice(0,t)){const r=_i[e];ki[r]=t-e,n.push(r)}return n}const r=e*t,i=mi("last");for(let e in ki)n.push(e);if(n.sort(((e,t)=>{const n=ki[t],r=ki[e];return n==r?e.localeCompare(t):n-r})),n.length>r){const e=n.slice(r);n=n.slice(0,r);for(let t of e)t!=i&&delete ki[t];i&&-1==n.indexOf(i)&&(delete ki[n[n.length-1]],n.splice(-1,1,i)),pi("frequently",ki)}return n},DEFAULTS:_i},Ci={};Ci=JSON.parse('{"search":"Search","search_no_results_1":"Oh no!","search_no_results_2":"That emoji couldn’t be found","pick":"Pick an emoji…","add_custom":"Add custom emoji","categories":{"activity":"Activity","custom":"Custom","flags":"Flags","foods":"Food & Drink","frequent":"Frequently used","nature":"Animals & Nature","objects":"Objects","people":"Smileys & People","places":"Travel & Places","search":"Search Results","symbols":"Symbols"},"skins":{"1":"Default","2":"Light","3":"Medium-Light","4":"Medium","5":"Medium-Dark","6":"Dark","choose":"Choose default skin tone"}}');var xi={autoFocus:{value:!1},dynamicWidth:{value:!1},emojiButtonColors:{value:null},emojiButtonRadius:{value:"100%"},emojiButtonSize:{value:36},emojiSize:{value:24},emojiVersion:{value:15,choices:[1,2,3,4,5,11,12,12.1,13,13.1,14,15]},exceptEmojis:{value:[]},icons:{value:"auto",choices:["auto","outline","solid"]},locale:{value:"en",choices:["en","ar","be","cs","de","es","fa","fi","fr","hi","it","ja","ko","nl","pl","pt","ru","sa","tr","uk","vi","zh"]},maxFrequentRows:{value:4},navPosition:{value:"top",choices:["top","bottom","none"]},noCountryFlags:{value:!1},noResultsEmoji:{value:null},perLine:{value:9},previewEmoji:{value:null},previewPosition:{value:"bottom",choices:["top","bottom","none"]},searchPosition:{value:"sticky",choices:["sticky","static","none"]},set:{value:"native",choices:["native","apple","facebook","google","twitter"]},skin:{value:1,choices:[1,2,3,4,5,6]},skinTonePosition:{value:"preview",choices:["preview","search","none"]},theme:{value:"auto",choices:["auto","light","dark"]},categories:null,categoryIcons:null,custom:null,data:null,i18n:null,getImageURL:null,getSpritesheetURL:null,onAddCustomEmoji:null,onClickOutside:null,onEmojiSelect:null,stickySearch:{deprecated:!0,value:!0}};let Si=null,ji=null;const Ti={};async function Ei(e){if(Ti[e])return Ti[e];const t=await fetch(e),n=await t.json();return Ti[e]=n,n}let Pi=null,Mi=null,Ai=!1;function Li(e,{caller:t}={}){return Pi||(Pi=new Promise((e=>{Mi=e}))),e?async function(e){Ai=!0;let{emojiVersion:t,set:n,locale:r}=e;if(t||(t=xi.emojiVersion.value),n||(n=xi.set.value),r||(r=xi.locale.value),ji)ji.categories=ji.categories.filter((e=>!e.name));else{ji=("function"==typeof e.data?await e.data():e.data)||await Ei(`https://cdn.jsdelivr.net/npm/@emoji-mart/data@latest/sets/${t}/${n}.json`),ji.emoticons={},ji.natives={},ji.categories.unshift({id:"frequent",emojis:[]});for(const e in ji.aliases){const t=ji.aliases[e],n=ji.emojis[t];n&&(n.aliases||(n.aliases=[]),n.aliases.push(e))}ji.originalCategories=ji.categories}if(Si=("function"==typeof e.i18n?await e.i18n():e.i18n)||("en"==r?Mr(Ci):await Ei(`https://cdn.jsdelivr.net/npm/@emoji-mart/data@latest/i18n/${r}.json`)),e.custom)for(let t in e.custom){t=parseInt(t);const n=e.custom[t],r=e.custom[t-1];if(n.emojis&&n.emojis.length){n.id||(n.id=`custom_${t+1}`),n.name||(n.name=Si.categories.custom),r&&!n.icon&&(n.target=r.target||r),ji.categories.push(n);for(const e of n.emojis)ji.emojis[e.id]=e}}e.categories&&(ji.categories=ji.originalCategories.filter((t=>-1!=e.categories.indexOf(t.id))).sort(((t,n)=>e.categories.indexOf(t.id)-e.categories.indexOf(n.id))));let i=null,o=null;"native"==n&&(i=wi.latestVersion(),o=e.noCountryFlags||wi.noCountryFlags());let s=ji.categories.length,a=!1;for(;s--;){const t=ji.categories[s];if("frequent"==t.id){let{maxFrequentRows:n,perLine:r}=e;n=n>=0?n:xi.maxFrequentRows.value,r||(r=xi.perLine.value),t.emojis=Oi.get({maxFrequentRows:n,perLine:r})}if(!t.emojis||!t.emojis.length){ji.categories.splice(s,1);continue}const{categoryIcons:n}=e;if(n){const e=n[t.id];e&&!t.icon&&(t.icon=e)}let r=t.emojis.length;for(;r--;){const n=t.emojis[r],s=n.id?n:ji.emojis[n],l=()=>{t.emojis.splice(r,1)};if(!s||e.exceptEmojis&&e.exceptEmojis.includes(s.id))l();else if(i&&s.version>i)l();else if(!o||"flags"!=t.id||Di.includes(s.id)){if(!s.search){if(a=!0,s.search=","+[[s.id,!1],[s.name,!0],[s.keywords,!1],[s.emoticons,!1]].map((([e,t])=>{if(e)return(Array.isArray(e)?e:[e]).map((e=>(t?e.split(/[-|_|\s]+/):[e]).map((e=>e.toLowerCase())))).flat()})).flat().filter((e=>e&&e.trim())).join(","),s.emoticons)for(const e of s.emoticons)ji.emoticons[e]||(ji.emoticons[e]=s.id);let e=0;for(const t of s.skins){if(!t)continue;e++;const{native:n}=t;n&&(ji.natives[n]=s.id,s.search+=`,${n}`);const r=1==e?"":`:skin-tone-${e}:`;t.shortcodes=`:${s.id}:${r}`}}}else l()}}a&&Fi.reset(),Mi()}(e):t&&!Ai&&console.warn(`\`${t}\` requires data to be initialized first. Promise will be pending until \`init\` is called.`),Pi}function Ii(e,t,n){e||(e={});const r={};for(let i in t)r[i]=Ri(i,e,t,n);return r}function Ri(e,t,n,r){const i=n[e];let o=r&&r.getAttribute(e)||(null!=t[e]&&null!=t[e]?t[e]:null);return i?(null!=o&&i.value&&typeof i.value!=typeof o&&(o="boolean"==typeof i.value?"false"!=o:i.value.constructor(o)),i.transform&&o&&(o=i.transform(o)),(null==o||i.choices&&-1==i.choices.indexOf(o))&&(o=i.value),o):o}let Bi=null;var Fi={search:async function(e,{maxResults:t,caller:n}={}){if(!e||!e.trim().length)return null;t||(t=90),await Li(null,{caller:n||"SearchIndex.search"});const r=e.toLowerCase().replace(/(\w)-/,"$1 ").split(/[\s|,]+/).filter(((e,t,n)=>e.trim()&&n.indexOf(e)==t));if(!r.length)return;let i,o,s=Bi||(Bi=Object.values(ji.emojis));for(const e of r){if(!s.length)break;i=[],o={};for(const t of s){if(!t.search)continue;const n=t.search.indexOf(`,${e}`);-1!=n&&(i.push(t),o[t.id]||(o[t.id]=0),o[t.id]+=t.id==e?0:n+1)}s=i}return i.length<2||(i.sort(((e,t)=>{const n=o[e.id],r=o[t.id];return n==r?e.id.localeCompare(t.id):n-r})),i.length>t&&(i=i.slice(0,t))),i},get:function(e){return e.id?e:ji.emojis[e]||ji.emojis[ji.aliases[e]]||ji.emojis[ji.natives[e]]},reset:function(){Bi=null},SHORTCODES_REGEX:/^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/};const Di=["checkered_flag","crossed_flags","pirate_flag","rainbow-flag","transgender_flag","triangular_flag_on_post","waving_black_flag","waving_white_flag"];var Ni={categories:{activity:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:fi("path",{d:"M12 0C5.373 0 0 5.372 0 12c0 6.627 5.373 12 12 12 6.628 0 12-5.373 12-12 0-6.628-5.372-12-12-12m9.949 11H17.05c.224-2.527 1.232-4.773 1.968-6.113A9.966 9.966 0 0 1 21.949 11M13 11V2.051a9.945 9.945 0 0 1 4.432 1.564c-.858 1.491-2.156 4.22-2.392 7.385H13zm-2 0H8.961c-.238-3.165-1.536-5.894-2.393-7.385A9.95 9.95 0 0 1 11 2.051V11zm0 2v8.949a9.937 9.937 0 0 1-4.432-1.564c.857-1.492 2.155-4.221 2.393-7.385H11zm4.04 0c.236 3.164 1.534 5.893 2.392 7.385A9.92 9.92 0 0 1 13 21.949V13h2.04zM4.982 4.887C5.718 6.227 6.726 8.473 6.951 11h-4.9a9.977 9.977 0 0 1 2.931-6.113M2.051 13h4.9c-.226 2.527-1.233 4.771-1.969 6.113A9.972 9.972 0 0 1 2.051 13m16.967 6.113c-.735-1.342-1.744-3.586-1.968-6.113h4.899a9.961 9.961 0 0 1-2.931 6.113"})}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M16.17 337.5c0 44.98 7.565 83.54 13.98 107.9C35.22 464.3 50.46 496 174.9 496c9.566 0 19.59-.4707 29.84-1.271L17.33 307.3C16.53 317.6 16.17 327.7 16.17 337.5zM495.8 174.5c0-44.98-7.565-83.53-13.98-107.9c-4.688-17.54-18.34-31.23-36.04-35.95C435.5 27.91 392.9 16 337 16c-9.564 0-19.59 .4707-29.84 1.271l187.5 187.5C495.5 194.4 495.8 184.3 495.8 174.5zM26.77 248.8l236.3 236.3c142-36.1 203.9-150.4 222.2-221.1L248.9 26.87C106.9 62.96 45.07 177.2 26.77 248.8zM256 335.1c0 9.141-7.474 16-16 16c-4.094 0-8.188-1.564-11.31-4.689L164.7 283.3C161.6 280.2 160 276.1 160 271.1c0-8.529 6.865-16 16-16c4.095 0 8.189 1.562 11.31 4.688l64.01 64C254.4 327.8 256 331.9 256 335.1zM304 287.1c0 9.141-7.474 16-16 16c-4.094 0-8.188-1.564-11.31-4.689L212.7 235.3C209.6 232.2 208 228.1 208 223.1c0-9.141 7.473-16 16-16c4.094 0 8.188 1.562 11.31 4.688l64.01 64.01C302.5 279.8 304 283.9 304 287.1zM256 175.1c0-9.141 7.473-16 16-16c4.094 0 8.188 1.562 11.31 4.688l64.01 64.01c3.125 3.125 4.688 7.219 4.688 11.31c0 9.133-7.468 16-16 16c-4.094 0-8.189-1.562-11.31-4.688l-64.01-64.01C257.6 184.2 256 180.1 256 175.1z"})})},custom:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:fi("path",{d:"M417.1 368c-5.937 10.27-16.69 16-27.75 16c-5.422 0-10.92-1.375-15.97-4.281L256 311.4V448c0 17.67-14.33 32-31.1 32S192 465.7 192 448V311.4l-118.3 68.29C68.67 382.6 63.17 384 57.75 384c-11.06 0-21.81-5.734-27.75-16c-8.828-15.31-3.594-34.88 11.72-43.72L159.1 256L41.72 187.7C26.41 178.9 21.17 159.3 29.1 144C36.63 132.5 49.26 126.7 61.65 128.2C65.78 128.7 69.88 130.1 73.72 132.3L192 200.6V64c0-17.67 14.33-32 32-32S256 46.33 256 64v136.6l118.3-68.29c3.838-2.213 7.939-3.539 12.07-4.051C398.7 126.7 411.4 132.5 417.1 144c8.828 15.31 3.594 34.88-11.72 43.72L288 256l118.3 68.28C421.6 333.1 426.8 352.7 417.1 368z"})}),flags:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:fi("path",{d:"M0 0l6.084 24H8L1.916 0zM21 5h-4l-1-4H4l3 12h3l1 4h13L21 5zM6.563 3h7.875l2 8H8.563l-2-8zm8.832 10l-2.856 1.904L12.063 13h3.332zM19 13l-1.5-6h1.938l2 8H16l3-2z"})}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M64 496C64 504.8 56.75 512 48 512h-32C7.25 512 0 504.8 0 496V32c0-17.75 14.25-32 32-32s32 14.25 32 32V496zM476.3 0c-6.365 0-13.01 1.35-19.34 4.233c-45.69 20.86-79.56 27.94-107.8 27.94c-59.96 0-94.81-31.86-163.9-31.87C160.9 .3055 131.6 4.867 96 15.75v350.5c32-9.984 59.87-14.1 84.85-14.1c73.63 0 124.9 31.78 198.6 31.78c31.91 0 68.02-5.971 111.1-23.09C504.1 355.9 512 344.4 512 332.1V30.73C512 11.1 495.3 0 476.3 0z"})})},foods:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:fi("path",{d:"M17 4.978c-1.838 0-2.876.396-3.68.934.513-1.172 1.768-2.934 4.68-2.934a1 1 0 0 0 0-2c-2.921 0-4.629 1.365-5.547 2.512-.064.078-.119.162-.18.244C11.73 1.838 10.798.023 9.207.023 8.579.022 7.85.306 7 .978 5.027 2.54 5.329 3.902 6.492 4.999 3.609 5.222 0 7.352 0 12.969c0 4.582 4.961 11.009 9 11.009 1.975 0 2.371-.486 3-1 .629.514 1.025 1 3 1 4.039 0 9-6.418 9-11 0-5.953-4.055-8-7-8M8.242 2.546c.641-.508.943-.523.965-.523.426.169.975 1.405 1.357 3.055-1.527-.629-2.741-1.352-2.98-1.846.059-.112.241-.356.658-.686M15 21.978c-1.08 0-1.21-.109-1.559-.402l-.176-.146c-.367-.302-.816-.452-1.266-.452s-.898.15-1.266.452l-.176.146c-.347.292-.477.402-1.557.402-2.813 0-7-5.389-7-9.009 0-5.823 4.488-5.991 5-5.991 1.939 0 2.484.471 3.387 1.251l.323.276a1.995 1.995 0 0 0 2.58 0l.323-.276c.902-.78 1.447-1.251 3.387-1.251.512 0 5 .168 5 6 0 3.617-4.187 9-7 9"})}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M481.9 270.1C490.9 279.1 496 291.3 496 304C496 316.7 490.9 328.9 481.9 337.9C472.9 346.9 460.7 352 448 352H64C51.27 352 39.06 346.9 30.06 337.9C21.06 328.9 16 316.7 16 304C16 291.3 21.06 279.1 30.06 270.1C39.06 261.1 51.27 256 64 256H448C460.7 256 472.9 261.1 481.9 270.1zM475.3 388.7C478.3 391.7 480 395.8 480 400V416C480 432.1 473.3 449.3 461.3 461.3C449.3 473.3 432.1 480 416 480H96C79.03 480 62.75 473.3 50.75 461.3C38.74 449.3 32 432.1 32 416V400C32 395.8 33.69 391.7 36.69 388.7C39.69 385.7 43.76 384 48 384H464C468.2 384 472.3 385.7 475.3 388.7zM50.39 220.8C45.93 218.6 42.03 215.5 38.97 211.6C35.91 207.7 33.79 203.2 32.75 198.4C31.71 193.5 31.8 188.5 32.99 183.7C54.98 97.02 146.5 32 256 32C365.5 32 457 97.02 479 183.7C480.2 188.5 480.3 193.5 479.2 198.4C478.2 203.2 476.1 207.7 473 211.6C469.1 215.5 466.1 218.6 461.6 220.8C457.2 222.9 452.3 224 447.3 224H64.67C59.73 224 54.84 222.9 50.39 220.8zM372.7 116.7C369.7 119.7 368 123.8 368 128C368 131.2 368.9 134.3 370.7 136.9C372.5 139.5 374.1 141.6 377.9 142.8C380.8 143.1 384 144.3 387.1 143.7C390.2 143.1 393.1 141.6 395.3 139.3C397.6 137.1 399.1 134.2 399.7 131.1C400.3 128 399.1 124.8 398.8 121.9C397.6 118.1 395.5 116.5 392.9 114.7C390.3 112.9 387.2 111.1 384 111.1C379.8 111.1 375.7 113.7 372.7 116.7V116.7zM244.7 84.69C241.7 87.69 240 91.76 240 96C240 99.16 240.9 102.3 242.7 104.9C244.5 107.5 246.1 109.6 249.9 110.8C252.8 111.1 256 112.3 259.1 111.7C262.2 111.1 265.1 109.6 267.3 107.3C269.6 105.1 271.1 102.2 271.7 99.12C272.3 96.02 271.1 92.8 270.8 89.88C269.6 86.95 267.5 84.45 264.9 82.7C262.3 80.94 259.2 79.1 256 79.1C251.8 79.1 247.7 81.69 244.7 84.69V84.69zM116.7 116.7C113.7 119.7 112 123.8 112 128C112 131.2 112.9 134.3 114.7 136.9C116.5 139.5 118.1 141.6 121.9 142.8C124.8 143.1 128 144.3 131.1 143.7C134.2 143.1 137.1 141.6 139.3 139.3C141.6 137.1 143.1 134.2 143.7 131.1C144.3 128 143.1 124.8 142.8 121.9C141.6 118.1 139.5 116.5 136.9 114.7C134.3 112.9 131.2 111.1 128 111.1C123.8 111.1 119.7 113.7 116.7 116.7L116.7 116.7z"})})},frequent:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[fi("path",{d:"M13 4h-2l-.001 7H9v2h2v2h2v-2h4v-2h-4z"}),fi("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0m0 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10"})]}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512zM232 256C232 264 236 271.5 242.7 275.1L338.7 339.1C349.7 347.3 364.6 344.3 371.1 333.3C379.3 322.3 376.3 307.4 365.3 300L280 243.2V120C280 106.7 269.3 96 255.1 96C242.7 96 231.1 106.7 231.1 120L232 256z"})})},nature:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[fi("path",{d:"M15.5 8a1.5 1.5 0 1 0 .001 3.001A1.5 1.5 0 0 0 15.5 8M8.5 8a1.5 1.5 0 1 0 .001 3.001A1.5 1.5 0 0 0 8.5 8"}),fi("path",{d:"M18.933 0h-.027c-.97 0-2.138.787-3.018 1.497-1.274-.374-2.612-.51-3.887-.51-1.285 0-2.616.133-3.874.517C7.245.79 6.069 0 5.093 0h-.027C3.352 0 .07 2.67.002 7.026c-.039 2.479.276 4.238 1.04 5.013.254.258.882.677 1.295.882.191 3.177.922 5.238 2.536 6.38.897.637 2.187.949 3.2 1.102C8.04 20.6 8 20.795 8 21c0 1.773 2.35 3 4 3 1.648 0 4-1.227 4-3 0-.201-.038-.393-.072-.586 2.573-.385 5.435-1.877 5.925-7.587.396-.22.887-.568 1.104-.788.763-.774 1.079-2.534 1.04-5.013C23.929 2.67 20.646 0 18.933 0M3.223 9.135c-.237.281-.837 1.155-.884 1.238-.15-.41-.368-1.349-.337-3.291.051-3.281 2.478-4.972 3.091-5.031.256.015.731.27 1.265.646-1.11 1.171-2.275 2.915-2.352 5.125-.133.546-.398.858-.783 1.313M12 22c-.901 0-1.954-.693-2-1 0-.654.475-1.236 1-1.602V20a1 1 0 1 0 2 0v-.602c.524.365 1 .947 1 1.602-.046.307-1.099 1-2 1m3-3.48v.02a4.752 4.752 0 0 0-1.262-1.02c1.092-.516 2.239-1.334 2.239-2.217 0-1.842-1.781-2.195-3.977-2.195-2.196 0-3.978.354-3.978 2.195 0 .883 1.148 1.701 2.238 2.217A4.8 4.8 0 0 0 9 18.539v-.025c-1-.076-2.182-.281-2.973-.842-1.301-.92-1.838-3.045-1.853-6.478l.023-.041c.496-.826 1.49-1.45 1.804-3.102 0-2.047 1.357-3.631 2.362-4.522C9.37 3.178 10.555 3 11.948 3c1.447 0 2.685.192 3.733.57 1 .9 2.316 2.465 2.316 4.48.313 1.651 1.307 2.275 1.803 3.102.035.058.068.117.102.178-.059 5.967-1.949 7.01-4.902 7.19m6.628-8.202c-.037-.065-.074-.13-.113-.195a7.587 7.587 0 0 0-.739-.987c-.385-.455-.648-.768-.782-1.313-.076-2.209-1.241-3.954-2.353-5.124.531-.376 1.004-.63 1.261-.647.636.071 3.044 1.764 3.096 5.031.027 1.81-.347 3.218-.37 3.235"})]}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:fi("path",{d:"M332.7 19.85C334.6 8.395 344.5 0 356.1 0C363.6 0 370.6 3.52 375.1 9.502L392 32H444.1C456.8 32 469.1 37.06 478.1 46.06L496 64H552C565.3 64 576 74.75 576 88V112C576 156.2 540.2 192 496 192H426.7L421.6 222.5L309.6 158.5L332.7 19.85zM448 64C439.2 64 432 71.16 432 80C432 88.84 439.2 96 448 96C456.8 96 464 88.84 464 80C464 71.16 456.8 64 448 64zM416 256.1V480C416 497.7 401.7 512 384 512H352C334.3 512 320 497.7 320 480V364.8C295.1 377.1 268.8 384 240 384C211.2 384 184 377.1 160 364.8V480C160 497.7 145.7 512 128 512H96C78.33 512 64 497.7 64 480V249.8C35.23 238.9 12.64 214.5 4.836 183.3L.9558 167.8C-3.331 150.6 7.094 133.2 24.24 128.1C41.38 124.7 58.76 135.1 63.05 152.2L66.93 167.8C70.49 182 83.29 191.1 97.97 191.1H303.8L416 256.1z"})})},objects:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[fi("path",{d:"M12 0a9 9 0 0 0-5 16.482V21s2.035 3 5 3 5-3 5-3v-4.518A9 9 0 0 0 12 0zm0 2c3.86 0 7 3.141 7 7s-3.14 7-7 7-7-3.141-7-7 3.14-7 7-7zM9 17.477c.94.332 1.946.523 3 .523s2.06-.19 3-.523v.834c-.91.436-1.925.689-3 .689a6.924 6.924 0 0 1-3-.69v-.833zm.236 3.07A8.854 8.854 0 0 0 12 21c.965 0 1.888-.167 2.758-.451C14.155 21.173 13.153 22 12 22c-1.102 0-2.117-.789-2.764-1.453z"}),fi("path",{d:"M14.745 12.449h-.004c-.852-.024-1.188-.858-1.577-1.824-.421-1.061-.703-1.561-1.182-1.566h-.009c-.481 0-.783.497-1.235 1.537-.436.982-.801 1.811-1.636 1.791l-.276-.043c-.565-.171-.853-.691-1.284-1.794-.125-.313-.202-.632-.27-.913-.051-.213-.127-.53-.195-.634C7.067 9.004 7.039 9 6.99 9A1 1 0 0 1 7 7h.01c1.662.017 2.015 1.373 2.198 2.134.486-.981 1.304-2.058 2.797-2.075 1.531.018 2.28 1.153 2.731 2.141l.002-.008C14.944 8.424 15.327 7 16.979 7h.032A1 1 0 1 1 17 9h-.011c-.149.076-.256.474-.319.709a6.484 6.484 0 0 1-.311.951c-.429.973-.79 1.789-1.614 1.789"})]}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",children:fi("path",{d:"M112.1 454.3c0 6.297 1.816 12.44 5.284 17.69l17.14 25.69c5.25 7.875 17.17 14.28 26.64 14.28h61.67c9.438 0 21.36-6.401 26.61-14.28l17.08-25.68c2.938-4.438 5.348-12.37 5.348-17.7L272 415.1h-160L112.1 454.3zM191.4 .0132C89.44 .3257 16 82.97 16 175.1c0 44.38 16.44 84.84 43.56 115.8c16.53 18.84 42.34 58.23 52.22 91.45c.0313 .25 .0938 .5166 .125 .7823h160.2c.0313-.2656 .0938-.5166 .125-.7823c9.875-33.22 35.69-72.61 52.22-91.45C351.6 260.8 368 220.4 368 175.1C368 78.61 288.9-.2837 191.4 .0132zM192 96.01c-44.13 0-80 35.89-80 79.1C112 184.8 104.8 192 96 192S80 184.8 80 176c0-61.76 50.25-111.1 112-111.1c8.844 0 16 7.159 16 16S200.8 96.01 192 96.01z"})})},people:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[fi("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0m0 22C6.486 22 2 17.514 2 12S6.486 2 12 2s10 4.486 10 10-4.486 10-10 10"}),fi("path",{d:"M8 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 8 7M16 7a2 2 0 1 0-.001 3.999A2 2 0 0 0 16 7M15.232 15c-.693 1.195-1.87 2-3.349 2-1.477 0-2.655-.805-3.347-2H15m3-2H6a6 6 0 1 0 12 0"})]}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256zM256 432C332.1 432 396.2 382 415.2 314.1C419.1 300.4 407.8 288 393.6 288H118.4C104.2 288 92.92 300.4 96.76 314.1C115.8 382 179.9 432 256 432V432zM176.4 160C158.7 160 144.4 174.3 144.4 192C144.4 209.7 158.7 224 176.4 224C194 224 208.4 209.7 208.4 192C208.4 174.3 194 160 176.4 160zM336.4 224C354 224 368.4 209.7 368.4 192C368.4 174.3 354 160 336.4 160C318.7 160 304.4 174.3 304.4 192C304.4 209.7 318.7 224 336.4 224z"})})},places:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[fi("path",{d:"M6.5 12C5.122 12 4 13.121 4 14.5S5.122 17 6.5 17 9 15.879 9 14.5 7.878 12 6.5 12m0 3c-.275 0-.5-.225-.5-.5s.225-.5.5-.5.5.225.5.5-.225.5-.5.5M17.5 12c-1.378 0-2.5 1.121-2.5 2.5s1.122 2.5 2.5 2.5 2.5-1.121 2.5-2.5-1.122-2.5-2.5-2.5m0 3c-.275 0-.5-.225-.5-.5s.225-.5.5-.5.5.225.5.5-.225.5-.5.5"}),fi("path",{d:"M22.482 9.494l-1.039-.346L21.4 9h.6c.552 0 1-.439 1-.992 0-.006-.003-.008-.003-.008H23c0-1-.889-2-1.984-2h-.642l-.731-1.717C19.262 3.012 18.091 2 16.764 2H7.236C5.909 2 4.738 3.012 4.357 4.283L3.626 6h-.642C1.889 6 1 7 1 8h.003S1 8.002 1 8.008C1 8.561 1.448 9 2 9h.6l-.043.148-1.039.346a2.001 2.001 0 0 0-1.359 2.097l.751 7.508a1 1 0 0 0 .994.901H3v1c0 1.103.896 2 2 2h2c1.104 0 2-.897 2-2v-1h6v1c0 1.103.896 2 2 2h2c1.104 0 2-.897 2-2v-1h1.096a.999.999 0 0 0 .994-.901l.751-7.508a2.001 2.001 0 0 0-1.359-2.097M6.273 4.857C6.402 4.43 6.788 4 7.236 4h9.527c.448 0 .834.43.963.857L19.313 9H4.688l1.585-4.143zM7 21H5v-1h2v1zm12 0h-2v-1h2v1zm2.189-3H2.811l-.662-6.607L3 11h18l.852.393L21.189 18z"})]}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M39.61 196.8L74.8 96.29C88.27 57.78 124.6 32 165.4 32H346.6C387.4 32 423.7 57.78 437.2 96.29L472.4 196.8C495.6 206.4 512 229.3 512 256V448C512 465.7 497.7 480 480 480H448C430.3 480 416 465.7 416 448V400H96V448C96 465.7 81.67 480 64 480H32C14.33 480 0 465.7 0 448V256C0 229.3 16.36 206.4 39.61 196.8V196.8zM109.1 192H402.9L376.8 117.4C372.3 104.6 360.2 96 346.6 96H165.4C151.8 96 139.7 104.6 135.2 117.4L109.1 192zM96 256C78.33 256 64 270.3 64 288C64 305.7 78.33 320 96 320C113.7 320 128 305.7 128 288C128 270.3 113.7 256 96 256zM416 320C433.7 320 448 305.7 448 288C448 270.3 433.7 256 416 256C398.3 256 384 270.3 384 288C384 305.7 398.3 320 416 320z"})})},symbols:{outline:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:fi("path",{d:"M0 0h11v2H0zM4 11h3V6h4V4H0v2h4zM15.5 17c1.381 0 2.5-1.116 2.5-2.493s-1.119-2.493-2.5-2.493S13 13.13 13 14.507 14.119 17 15.5 17m0-2.986c.276 0 .5.222.5.493 0 .272-.224.493-.5.493s-.5-.221-.5-.493.224-.493.5-.493M21.5 19.014c-1.381 0-2.5 1.116-2.5 2.493S20.119 24 21.5 24s2.5-1.116 2.5-2.493-1.119-2.493-2.5-2.493m0 2.986a.497.497 0 0 1-.5-.493c0-.271.224-.493.5-.493s.5.222.5.493a.497.497 0 0 1-.5.493M22 13l-9 9 1.513 1.5 8.99-9.009zM17 11c2.209 0 4-1.119 4-2.5V2s.985-.161 1.498.949C23.01 4.055 23 6 23 6s1-1.119 1-3.135C24-.02 21 0 21 0h-2v6.347A5.853 5.853 0 0 0 17 6c-2.209 0-4 1.119-4 2.5s1.791 2.5 4 2.5M10.297 20.482l-1.475-1.585a47.54 47.54 0 0 1-1.442 1.129c-.307-.288-.989-1.016-2.045-2.183.902-.836 1.479-1.466 1.729-1.892s.376-.871.376-1.336c0-.592-.273-1.178-.818-1.759-.546-.581-1.329-.871-2.349-.871-1.008 0-1.79.293-2.344.879-.556.587-.832 1.181-.832 1.784 0 .813.419 1.748 1.256 2.805-.847.614-1.444 1.208-1.794 1.784a3.465 3.465 0 0 0-.523 1.833c0 .857.308 1.56.924 2.107.616.549 1.423.823 2.42.823 1.173 0 2.444-.379 3.813-1.137L8.235 24h2.819l-2.09-2.383 1.333-1.135zm-6.736-6.389a1.02 1.02 0 0 1 .73-.286c.31 0 .559.085.747.254a.849.849 0 0 1 .283.659c0 .518-.419 1.112-1.257 1.784-.536-.651-.805-1.231-.805-1.742a.901.901 0 0 1 .302-.669M3.74 22c-.427 0-.778-.116-1.057-.349-.279-.232-.418-.487-.418-.766 0-.594.509-1.288 1.527-2.083.968 1.134 1.717 1.946 2.248 2.438-.921.507-1.686.76-2.3.76"})}),solid:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",children:fi("path",{d:"M500.3 7.251C507.7 13.33 512 22.41 512 31.1V175.1C512 202.5 483.3 223.1 447.1 223.1C412.7 223.1 383.1 202.5 383.1 175.1C383.1 149.5 412.7 127.1 447.1 127.1V71.03L351.1 90.23V207.1C351.1 234.5 323.3 255.1 287.1 255.1C252.7 255.1 223.1 234.5 223.1 207.1C223.1 181.5 252.7 159.1 287.1 159.1V63.1C287.1 48.74 298.8 35.61 313.7 32.62L473.7 .6198C483.1-1.261 492.9 1.173 500.3 7.251H500.3zM74.66 303.1L86.5 286.2C92.43 277.3 102.4 271.1 113.1 271.1H174.9C185.6 271.1 195.6 277.3 201.5 286.2L213.3 303.1H239.1C266.5 303.1 287.1 325.5 287.1 351.1V463.1C287.1 490.5 266.5 511.1 239.1 511.1H47.1C21.49 511.1-.0019 490.5-.0019 463.1V351.1C-.0019 325.5 21.49 303.1 47.1 303.1H74.66zM143.1 359.1C117.5 359.1 95.1 381.5 95.1 407.1C95.1 434.5 117.5 455.1 143.1 455.1C170.5 455.1 191.1 434.5 191.1 407.1C191.1 381.5 170.5 359.1 143.1 359.1zM440.3 367.1H496C502.7 367.1 508.6 372.1 510.1 378.4C513.3 384.6 511.6 391.7 506.5 396L378.5 508C372.9 512.1 364.6 513.3 358.6 508.9C352.6 504.6 350.3 496.6 353.3 489.7L391.7 399.1H336C329.3 399.1 323.4 395.9 321 389.6C318.7 383.4 320.4 376.3 325.5 371.1L453.5 259.1C459.1 255 467.4 254.7 473.4 259.1C479.4 263.4 481.6 271.4 478.7 278.3L440.3 367.1zM116.7 219.1L19.85 119.2C-8.112 90.26-6.614 42.31 24.85 15.34C51.82-8.137 93.26-3.642 118.2 21.83L128.2 32.32L137.7 21.83C162.7-3.642 203.6-8.137 231.6 15.34C262.6 42.31 264.1 90.26 236.1 119.2L139.7 219.1C133.2 225.6 122.7 225.6 116.7 219.1H116.7z"})})}},search:{loupe:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:fi("path",{d:"M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z"})}),delete:fi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",children:fi("path",{d:"M10 8.586L2.929 1.515 1.515 2.929 8.586 10l-7.071 7.071 1.414 1.414L10 11.414l7.071 7.071 1.414-1.414L11.414 10l7.071-7.071-1.414-1.414L10 8.586z"})})}};function zi(e){let{id:t,skin:n,emoji:r}=e;if(e.shortcodes){const r=e.shortcodes.match(Fi.SHORTCODES_REGEX);r&&(t=r[1],r[2]&&(n=r[2]))}if(r||(r=Fi.get(t||e.native)),!r)return e.fallback;const i=r.skins[n-1]||r.skins[0],o=i.src||("native"==e.set||e.spritesheet?void 0:"function"==typeof e.getImageURL?e.getImageURL(e.set,i.unified):`https://cdn.jsdelivr.net/npm/emoji-datasource-${e.set}@15.0.1/img/${e.set}/64/${i.unified}.png`),s="function"==typeof e.getSpritesheetURL?e.getSpritesheetURL(e.set):`https://cdn.jsdelivr.net/npm/emoji-datasource-${e.set}@15.0.1/img/${e.set}/sheets-256/64.png`;return fi("span",{class:"emoji-mart-emoji","data-emoji-set":e.set,children:o?fi("img",{style:{maxWidth:e.size||"1em",maxHeight:e.size||"1em",display:"inline-block"},alt:i.native||i.shortcodes,src:o}):"native"==e.set?fi("span",{style:{fontSize:e.size,fontFamily:'"EmojiMart", "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "Android Emoji"'},children:i.native}):fi("span",{style:{display:"block",width:e.size,height:e.size,backgroundImage:`url(${s})`,backgroundSize:`${100*ji.sheet.cols}% ${100*ji.sheet.rows}%`,backgroundPosition:`${100/(ji.sheet.cols-1)*i.x}% ${100/(ji.sheet.rows-1)*i.y}%`}})})}const Vi="undefined"!=typeof window&&window.HTMLElement?window.HTMLElement:Object;class $i extends Vi{static get observedAttributes(){return Object.keys(this.Props)}update(e={}){for(let t in e)this.attributeChangedCallback(t,null,e[t])}attributeChangedCallback(e,t,n){if(!this.component)return;const r=Ri(e,{[e]:n},this.constructor.Props,this);this.component.componentWillReceiveProps?this.component.componentWillReceiveProps({[e]:r}):(this.component.props[e]=r,this.component.forceUpdate())}disconnectedCallback(){this.disconnected=!0,this.component&&this.component.unregister&&this.component.unregister()}constructor(e={}){if(super(),this.props=e,e.parent||e.ref){let t=null;const n=e.parent||(t=e.ref&&e.ref.current);t&&(t.innerHTML=""),n&&n.appendChild(this)}}}class Hi extends $i{setShadow(){this.attachShadow({mode:"open"})}injectStyles(e){if(!e)return;const t=document.createElement("style");t.textContent=e,this.shadowRoot.insertBefore(t,this.shadowRoot.firstChild)}constructor(e,{styles:t}={}){super(e),this.setShadow(),this.injectStyles(t)}}var qi={fallback:"",id:"",native:"",shortcodes:"",size:{value:"",transform:e=>/\D/.test(e)?e:`${e}px`},set:xi.set,skin:xi.skin};class Ui extends $i{async connectedCallback(){const e=Ii(this.props,qi,this);e.element=this,e.ref=e=>{this.component=e},await Li(),this.disconnected||hi(fi(zi,{...e}),this)}constructor(e){super(e)}}Ar(Ui,"Props",qi),"undefined"==typeof customElements||customElements.get("em-emoji")||customElements.define("em-emoji",Ui);var Ki,Wi,Ji=[],Zi=Ir.__b,Gi=Ir.__r,Xi=Ir.diffed,Yi=Ir.__c,Qi=Ir.unmount;function eo(){var e;for(Ji.sort((function(e,t){return e.__v.__b-t.__v.__b}));e=Ji.pop();)if(e.__P)try{e.__H.__h.forEach(no),e.__H.__h.forEach(ro),e.__H.__h=[]}catch(t){e.__H.__h=[],Ir.__e(t,e.__v)}}Ir.__b=function(e){Ki=null,Zi&&Zi(e)},Ir.__r=function(e){Gi&&Gi(e);var t=(Ki=e.__c).__H;t&&(t.__h.forEach(no),t.__h.forEach(ro),t.__h=[])},Ir.diffed=function(e){Xi&&Xi(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==Ji.push(t)&&Wi===Ir.requestAnimationFrame||((Wi=Ir.requestAnimationFrame)||function(e){var t,n=function(){clearTimeout(r),to&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);to&&(t=requestAnimationFrame(n))})(eo)),Ki=null},Ir.__c=function(e,t){t.some((function(e){try{e.__h.forEach(no),e.__h=e.__h.filter((function(e){return!e.__||ro(e)}))}catch(n){t.some((function(e){e.__h&&(e.__h=[])})),t=[],Ir.__e(n,e.__v)}})),Yi&&Yi(e,t)},Ir.unmount=function(e){Qi&&Qi(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach((function(e){try{no(e)}catch(e){t=e}})),t&&Ir.__e(t,n.__v))};var to="function"==typeof requestAnimationFrame;function no(e){var t=Ki,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),Ki=t}function ro(e){var t=Ki;e.__c=e.__(),Ki=t}function io(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var r in t)if("__source"!==r&&e[r]!==t[r])return!0;return!1}function oo(e){this.props=e}(oo.prototype=new Wr).isPureReactComponent=!0,oo.prototype.shouldComponentUpdate=function(e,t){return io(this.props,e)||io(this.state,t)};var so=Ir.__b;Ir.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),so&&so(e)},"undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref");var ao=Ir.__e;Ir.__e=function(e,t,n){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t);ao(e,t,n)};var lo=Ir.unmount;function co(){this.__u=0,this.t=null,this.__b=null}function uo(e){var t=e.__.__c;return t&&t.__e&&t.__e(e)}function ho(){this.u=null,this.o=null}Ir.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&!0===e.__h&&(e.type=null),lo&&lo(e)},(co.prototype=new Wr).__c=function(e,t){var n=t.__c,r=this;null==r.t&&(r.t=[]),r.t.push(n);var i=uo(r.__v),o=!1,s=function(){o||(o=!0,n.__R=null,i?i(a):a())};n.__R=s;var a=function(){if(!--r.__u){if(r.state.__e){var e=r.state.__e;r.__v.__k[0]=function e(t,n,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map((function(t){return e(t,n,r)})),t.__c&&t.__c.__P===n&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__e:r.__b=null});t=r.t.pop();)t.forceUpdate()}},l=!0===t.__h;r.__u++||l||r.setState({__e:r.__b=r.__v.__k[0]}),e.then(s,s)},co.prototype.componentWillUnmount=function(){this.t=[]},co.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=function e(t,n,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach((function(e){"function"==typeof e.__c&&e.__c()})),t.__c.__H=null),null!=(t=function(e,t){for(var n in t)e[n]=t[n];return e}({},t)).__c&&(t.__c.__P===r&&(t.__c.__P=n),t.__c=null),t.__k=t.__k&&t.__k.map((function(t){return e(t,n,r)}))),t}(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__e&&qr(Kr,null,e.fallback);return i&&(i.__h=null),[qr(Kr,null,t.__e?null:e.children),i]};var fo=function(e,t,n){if(++n[1]===n[0]&&e.o.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.o.size))for(n=e.u;n;){for(;n.length>3;)n.pop()();if(n[1]{const r=t.name||Si.categories[t.id],i=!this.props.unfocused&&t.id==this.state.categoryId;return i&&(e=n),fi("button",{"aria-label":r,"aria-selected":i||void 0,title:r,type:"button",class:"flex flex-grow flex-center",onMouseDown:e=>e.preventDefault(),onClick:()=>{this.props.onClick({category:t,i:n})},children:this.renderIcon(t)})})),fi("div",{class:"bar",style:{width:100/this.categories.length+"%",opacity:null==e?0:1,transform:"rtl"===this.props.dir?`scaleX(-1) translateX(${100*e}%)`:`translateX(${100*e}%)`}})]})})}constructor(){super(),this.categories=ji.categories.filter((e=>!e.target)),this.state={categoryId:this.categories[0].id}}}class So extends oo{shouldComponentUpdate(e){for(let t in e)if("children"!=t&&e[t]!=this.props[t])return!0;return!1}render(){return this.props.children}}class jo extends Wr{getInitialState(e=this.props){return{skin:mi("skin")||e.skin,theme:this.initTheme(e.theme)}}componentWillMount(){this.dir=Si.rtl?"rtl":"ltr",this.refs={menu:{current:null},navigation:{current:null},scroll:{current:null},search:{current:null},searchInput:{current:null},skinToneButton:{current:null},skinToneRadio:{current:null}},this.initGrid(),0==this.props.stickySearch&&"sticky"==this.props.searchPosition&&(console.warn("[EmojiMart] Deprecation warning: `stickySearch` has been renamed `searchPosition`."),this.props.searchPosition="static")}componentDidMount(){if(this.register(),this.shadowRoot=this.base.parentNode,this.props.autoFocus){const{searchInput:e}=this.refs;e.current&&e.current.focus()}}componentWillReceiveProps(e){this.nextState||(this.nextState={});for(const t in e)this.nextState[t]=e[t];clearTimeout(this.nextStateTimer),this.nextStateTimer=setTimeout((()=>{let e=!1;for(const t in this.nextState)this.props[t]=this.nextState[t],"custom"!==t&&"categories"!==t||(e=!0);delete this.nextState;const t=this.getInitialState();if(e)return this.reset(t);this.setState(t)}))}componentWillUnmount(){this.unregister()}async reset(e={}){await Li(this.props),this.initGrid(),this.unobserve(),this.setState(e,(()=>{this.observeCategories(),this.observeRows()}))}register(){document.addEventListener("click",this.handleClickOutside),this.observe()}unregister(){document.removeEventListener("click",this.handleClickOutside),this.darkMedia?.removeEventListener("change",this.darkMediaCallback),this.unobserve()}observe(){this.observeCategories(),this.observeRows()}unobserve({except:e=[]}={}){Array.isArray(e)||(e=[e]);for(const t of this.observers)e.includes(t)||t.disconnect();this.observers=[].concat(e)}initGrid(){const{categories:e}=ji;this.refs.categories=new Map;const t=ji.categories.map((e=>e.id)).join(",");this.navKey&&this.navKey!=t&&this.refs.scroll.current&&(this.refs.scroll.current.scrollTop=0),this.navKey=t,this.grid=[],this.grid.setsize=0;const n=(e,t)=>{const n=[];n.__categoryId=t.id,n.__index=e.length,this.grid.push(n);const r=this.grid.length-1,i=r%10?{}:{current:null};return i.index=r,i.posinset=this.grid.setsize+1,e.push(i),n};for(let t of e){const e=[];let r=n(e,t);for(let i of t.emojis)r.length==this.getPerLine()&&(r=n(e,t)),this.grid.setsize+=1,r.push(i);this.refs.categories.set(t.id,{root:{current:null},rows:e})}}initTheme(e){if("auto"!=e)return e;if(!this.darkMedia){if(this.darkMedia=matchMedia("(prefers-color-scheme: dark)"),this.darkMedia.media.match(/^not/))return"light";this.darkMedia.addEventListener("change",this.darkMediaCallback)}return this.darkMedia.matches?"dark":"light"}initDynamicPerLine(e=this.props){if(!e.dynamicWidth)return;const{element:t,emojiButtonSize:n}=e,r=()=>{const{width:e}=t.getBoundingClientRect();return Math.floor(e/n)},i=new ResizeObserver((()=>{this.unobserve({except:i}),this.setState({perLine:r()},(()=>{this.initGrid(),this.forceUpdate((()=>{this.observeCategories(),this.observeRows()}))}))}));return i.observe(t),this.observers.push(i),r()}getPerLine(){return this.state.perLine||this.props.perLine}getEmojiByPos([e,t]){const n=this.state.searchResults||this.grid,r=n[e]&&n[e][t];if(r)return Fi.get(r)}observeCategories(){const e=this.refs.navigation.current;if(!e)return;const t=new Map,n={root:this.refs.scroll.current,threshold:[0,1]},r=new IntersectionObserver((n=>{for(const e of n){const n=e.target.dataset.id;t.set(n,e.intersectionRatio)}const r=[...t];for(const[t,n]of r)if(n){(i=t)!=e.state.categoryId&&e.setState({categoryId:i});break}var i}),n);for(const{root:e}of this.refs.categories.values())r.observe(e.current);this.observers.push(r)}observeRows(){const e={...this.state.visibleRows},t=new IntersectionObserver((t=>{for(const n of t){const t=parseInt(n.target.dataset.index);n.isIntersecting?e[t]=!0:delete e[t]}this.setState({visibleRows:e})}),{root:this.refs.scroll.current,rootMargin:`${15*this.props.emojiButtonSize}px 0px ${10*this.props.emojiButtonSize}px`});for(const{rows:e}of this.refs.categories.values())for(const n of e)n.current&&t.observe(n.current);this.observers.push(t)}preventDefault(e){e.preventDefault()}unfocusSearch(){const e=this.refs.searchInput.current;e&&e.blur()}navigate({e,input:t,left:n,right:r,up:i,down:o}){const s=this.state.searchResults||this.grid;if(!s.length)return;let[a,l]=this.state.pos;const c=(()=>{if(0==a&&0==l&&!e.repeat&&(n||i))return null;if(-1==a)return e.repeat||!r&&!o||t.selectionStart!=t.value.length?null:[0,0];if(n||r){let e=s[a];const t=n?-1:1;if(l+=t,!e[l]){if(a+=t,e=s[a],!e)return a=n?0:s.length-1,l=n?0:s[a].length-1,[a,l];l=n?e.length-1:0}return[a,l]}if(i||o){a+=i?-1:1;const e=s[a];return e?(e[l]||(l=e.length-1),[a,l]):(a=i?0:s.length-1,l=i?0:s[a].length-1,[a,l])}})();c?(e.preventDefault(),this.setState({pos:c,keyboard:!0},(()=>{this.scrollTo({row:c[0]})}))):this.state.pos[0]>-1&&this.setState({pos:[-1,-1]})}scrollTo({categoryId:e,row:t}){const n=this.state.searchResults||this.grid;if(!n.length)return;const r=this.refs.scroll.current,i=r.getBoundingClientRect();let o=0;if(t>=0&&(e=n[t].__categoryId),e&&(o=(this.refs[e]||this.refs.categories.get(e).root).current.getBoundingClientRect().top-(i.top-r.scrollTop)+1),t>=0)if(t){const e=o+n[t].__index*this.props.emojiButtonSize,s=e+this.props.emojiButtonSize+.88*this.props.emojiButtonSize;if(er.scrollTop+i.height))return;o=s-i.height}}else o=0;this.ignoreMouse(),r.scrollTop=o}ignoreMouse(){this.mouseIsIgnored=!0,clearTimeout(this.ignoreMouseTimer),this.ignoreMouseTimer=setTimeout((()=>{delete this.mouseIsIgnored}),100)}handleEmojiOver(e){this.mouseIsIgnored||this.state.showSkins||this.setState({pos:e||[-1,-1],keyboard:!1})}handleEmojiClick({e,emoji:t,pos:n}){if(this.props.onEmojiSelect&&(!t&&n&&(t=this.getEmojiByPos(n)),t)){const n=function(e,{skinIndex:t=0}={}){const n=e.skins[t]||(t=0,e.skins[t]),r={id:e.id,name:e.name,native:n.native,unified:n.unified,keywords:e.keywords,shortcodes:n.shortcodes||e.shortcodes};return e.skins.length>1&&(r.skin=t+1),n.src&&(r.src=n.src),e.aliases&&e.aliases.length&&(r.aliases=e.aliases),e.emoticons&&e.emoticons.length&&(r.emoticons=e.emoticons),r}(t,{skinIndex:this.state.skin-1});this.props.maxFrequentRows&&Oi.add(n,this.props),this.props.onEmojiSelect(n,e)}}closeSkins(){this.state.showSkins&&(this.setState({showSkins:null,tempSkin:null}),this.base.removeEventListener("click",this.handleBaseClick),this.base.removeEventListener("keydown",this.handleBaseKeydown))}handleSkinMouseOver(e){this.setState({tempSkin:e})}handleSkinClick(e){this.ignoreMouse(),this.closeSkins(),this.setState({skin:e,tempSkin:null}),pi("skin",e)}renderNav(){return fi(xo,{ref:this.refs.navigation,icons:this.props.icons,theme:this.state.theme,dir:this.dir,unfocused:!!this.state.searchResults,position:this.props.navPosition,onClick:this.handleCategoryClick},this.navKey)}renderPreview(){const e=this.getEmojiByPos(this.state.pos),t=this.state.searchResults&&!this.state.searchResults.length;return fi("div",{id:"preview",class:"flex flex-middle",dir:this.dir,"data-position":this.props.previewPosition,children:[fi("div",{class:"flex flex-middle flex-grow",children:[fi("div",{class:"flex flex-auto flex-middle flex-center",style:{height:this.props.emojiButtonSize,fontSize:this.props.emojiButtonSize},children:fi(zi,{emoji:e,id:t?this.props.noResultsEmoji||"cry":this.props.previewEmoji||("top"==this.props.previewPosition?"point_down":"point_up"),set:this.props.set,size:this.props.emojiButtonSize,skin:this.state.tempSkin||this.state.skin,spritesheet:!0,getSpritesheetURL:this.props.getSpritesheetURL})}),fi("div",{class:`margin-${this.dir[0]}`,children:fi("div",e||t?{class:`padding-${this.dir[2]} align-${this.dir[0]}`,children:[fi("div",{class:"preview-title ellipsis",children:e?e.name:Si.search_no_results_1}),fi("div",{class:"preview-subtitle ellipsis color-c",children:e?e.skins[0].shortcodes:Si.search_no_results_2})]}:{class:"preview-placeholder color-c",children:Si.pick})})]}),!e&&"preview"==this.props.skinTonePosition&&this.renderSkinToneButton()]})}renderEmojiButton(e,{pos:t,posinset:n,grid:r}){const i=this.props.emojiButtonSize,o=this.state.tempSkin||this.state.skin,s=(e.skins[o-1]||e.skins[0]).native,a=(l=this.state.pos,c=t,Array.isArray(l)&&Array.isArray(c)&&l.length===c.length&&l.every(((e,t)=>e==c[t])));var l,c;const u=t.concat(e.id).join("");return fi(So,{selected:a,skin:o,size:i,children:fi("button",{"aria-label":s,"aria-selected":a||void 0,"aria-posinset":n,"aria-setsize":r.setsize,"data-keyboard":this.state.keyboard,title:"none"==this.props.previewPosition?e.name:void 0,type:"button",class:"flex flex-center flex-middle",tabindex:"-1",onClick:t=>this.handleEmojiClick({e:t,emoji:e}),onMouseEnter:()=>this.handleEmojiOver(t),onMouseLeave:()=>this.handleEmojiOver(),style:{width:this.props.emojiButtonSize,height:this.props.emojiButtonSize,fontSize:this.props.emojiSize,lineHeight:0},children:[fi("div",{"aria-hidden":"true",class:"background",style:{borderRadius:this.props.emojiButtonRadius,backgroundColor:this.props.emojiButtonColors?this.props.emojiButtonColors[(n-1)%this.props.emojiButtonColors.length]:void 0}}),fi(zi,{emoji:e,set:this.props.set,size:this.props.emojiSize,skin:o,spritesheet:!0,getSpritesheetURL:this.props.getSpritesheetURL})]})},u)}renderSearch(){const e="none"==this.props.previewPosition||"search"==this.props.skinTonePosition;return fi("div",{children:[fi("div",{class:"spacer"}),fi("div",{class:"flex flex-middle",children:[fi("div",{class:"search relative flex-grow",children:[fi("input",{type:"search",ref:this.refs.searchInput,placeholder:Si.search,onClick:this.handleSearchClick,onInput:this.handleSearchInput,onKeyDown:this.handleSearchKeyDown,autoComplete:"off"}),fi("span",{class:"icon loupe flex",children:Ni.search.loupe}),this.state.searchResults&&fi("button",{title:"Clear","aria-label":"Clear",type:"button",class:"icon delete flex",onClick:this.clearSearch,onMouseDown:this.preventDefault,children:Ni.search.delete})]}),e&&this.renderSkinToneButton()]})]})}renderSearchResults(){const{searchResults:e}=this.state;return e?fi("div",{class:"category",ref:this.refs.search,children:[fi("div",{class:`sticky padding-small align-${this.dir[0]}`,children:Si.categories.search}),fi("div",{children:e.length?e.map(((t,n)=>fi("div",{class:"flex",children:t.map(((t,r)=>this.renderEmojiButton(t,{pos:[n,r],posinset:n*this.props.perLine+r+1,grid:e})))}))):fi("div",{class:`padding-small align-${this.dir[0]}`,children:this.props.onAddCustomEmoji&&fi("a",{onClick:this.props.onAddCustomEmoji,children:Si.add_custom})})})]}):null}renderCategories(){const{categories:e}=ji,t=!!this.state.searchResults,n=this.getPerLine();return fi("div",{style:{visibility:t?"hidden":void 0,display:t?"none":void 0,height:"100%"},children:e.map((e=>{const{root:t,rows:r}=this.refs.categories.get(e.id);return fi("div",{"data-id":e.target?e.target.id:e.id,class:"category",ref:t,children:[fi("div",{class:`sticky padding-small align-${this.dir[0]}`,children:e.name||Si.categories[e.id]}),fi("div",{class:"relative",style:{height:r.length*this.props.emojiButtonSize},children:r.map(((t,r)=>{const i=t.index-t.index%10,o=this.state.visibleRows[i],s="current"in t?t:void 0;if(!o&&!s)return null;const a=r*n,l=a+n,c=e.emojis.slice(a,l);return c.length{if(!e)return fi("div",{style:{width:this.props.emojiButtonSize,height:this.props.emojiButtonSize}});const r=Fi.get(e);return this.renderEmojiButton(r,{pos:[t.index,n],posinset:t.posinset+n,grid:this.grid})}))},t.index)}))})]})}))})}renderSkinToneButton(){return"none"==this.props.skinTonePosition?null:fi("div",{class:"flex flex-auto flex-center flex-middle",style:{position:"relative",width:this.props.emojiButtonSize,height:this.props.emojiButtonSize},children:fi("button",{type:"button",ref:this.refs.skinToneButton,class:"skin-tone-button flex flex-auto flex-center flex-middle","aria-selected":this.state.showSkins?"":void 0,"aria-label":Si.skins.choose,title:Si.skins.choose,onClick:this.openSkins,style:{width:this.props.emojiSize,height:this.props.emojiSize},children:fi("span",{class:`skin-tone skin-tone-${this.state.skin}`})})})}renderLiveRegion(){const e=this.getEmojiByPos(this.state.pos);return fi("div",{"aria-live":"polite",class:"sr-only",children:e?e.name:""})}renderSkins(){const e=this.refs.skinToneButton.current.getBoundingClientRect(),t=this.base.getBoundingClientRect(),n={};return"ltr"==this.dir?n.right=t.right-e.right-3:n.left=e.left-t.left-3,"bottom"==this.props.previewPosition&&"preview"==this.props.skinTonePosition?n.bottom=t.bottom-e.top+6:(n.top=e.bottom-t.top+3,n.bottom="auto"),fi("div",{ref:this.refs.menu,role:"radiogroup",dir:this.dir,"aria-label":Si.skins.choose,class:"menu hidden","data-position":n.top?"top":"bottom",style:n,children:[...Array(6).keys()].map((e=>{const t=e+1,n=this.state.skin==t;return fi("div",{children:[fi("input",{type:"radio",name:"skin-tone",value:t,"aria-label":Si.skins[t],ref:n?this.refs.skinToneRadio:null,defaultChecked:n,onChange:()=>this.handleSkinMouseOver(t),onKeyDown:e=>{"Enter"!=e.code&&"Space"!=e.code&&"Tab"!=e.code||(e.preventDefault(),this.handleSkinClick(t))}}),fi("button",{"aria-hidden":"true",tabindex:"-1",onClick:()=>this.handleSkinClick(t),onMouseEnter:()=>this.handleSkinMouseOver(t),onMouseLeave:()=>this.handleSkinMouseOver(),class:"option flex flex-grow flex-middle",children:[fi("span",{class:`skin-tone skin-tone-${t}`}),fi("span",{class:"margin-small-lr",children:Si.skins[t]})]})]})}))})}render(){const e=this.props.perLine*this.props.emojiButtonSize;return fi("section",{id:"root",class:"flex flex-column",dir:this.dir,style:{width:this.props.dynamicWidth?"100%":`calc(${e}px + (var(--padding) + var(--sidebar-width)))`},"data-emoji-set":this.props.set,"data-theme":this.state.theme,"data-menu":this.state.showSkins?"":void 0,children:["top"==this.props.previewPosition&&this.renderPreview(),"top"==this.props.navPosition&&this.renderNav(),"sticky"==this.props.searchPosition&&fi("div",{class:"padding-lr",children:this.renderSearch()}),fi("div",{ref:this.refs.scroll,class:"scroll flex-grow padding-lr",children:fi("div",{style:{width:this.props.dynamicWidth?"100%":e,height:"100%"},children:["static"==this.props.searchPosition&&this.renderSearch(),this.renderSearchResults(),this.renderCategories()]})}),"bottom"==this.props.navPosition&&this.renderNav(),"bottom"==this.props.previewPosition&&this.renderPreview(),this.state.showSkins&&this.renderSkins(),this.renderLiveRegion()]})}constructor(e){super(),Ar(this,"darkMediaCallback",(()=>{"auto"==this.props.theme&&this.setState({theme:this.darkMedia.matches?"dark":"light"})})),Ar(this,"handleClickOutside",(e=>{const{element:t}=this.props;e.target!=t&&(this.state.showSkins&&this.closeSkins(),this.props.onClickOutside&&this.props.onClickOutside(e))})),Ar(this,"handleBaseClick",(e=>{this.state.showSkins&&(e.target.closest(".menu")||(e.preventDefault(),e.stopImmediatePropagation(),this.closeSkins()))})),Ar(this,"handleBaseKeydown",(e=>{this.state.showSkins&&"Escape"==e.key&&(e.preventDefault(),e.stopImmediatePropagation(),this.closeSkins())})),Ar(this,"handleSearchClick",(()=>{this.getEmojiByPos(this.state.pos)&&this.setState({pos:[-1,-1]})})),Ar(this,"handleSearchInput",(async()=>{const e=this.refs.searchInput.current;if(!e)return;const{value:t}=e,n=await Fi.search(t),r=()=>{this.refs.scroll.current&&(this.refs.scroll.current.scrollTop=0)};if(!n)return this.setState({searchResults:n,pos:[-1,-1]},r);const i=e.selectionStart==e.value.length?[0,0]:[-1,-1],o=[];o.setsize=n.length;let s=null;for(let e of n)o.length&&s.length!=this.getPerLine()||(s=[],s.__categoryId="search",s.__index=o.length,o.push(s)),s.push(e);this.ignoreMouse(),this.setState({searchResults:o,pos:i},r)})),Ar(this,"handleSearchKeyDown",(e=>{const t=e.currentTarget;switch(e.stopImmediatePropagation(),e.key){case"ArrowLeft":this.navigate({e,input:t,left:!0});break;case"ArrowRight":this.navigate({e,input:t,right:!0});break;case"ArrowUp":this.navigate({e,input:t,up:!0});break;case"ArrowDown":this.navigate({e,input:t,down:!0});break;case"Enter":e.preventDefault(),this.handleEmojiClick({e,pos:this.state.pos});break;case"Escape":e.preventDefault(),this.state.searchResults?this.clearSearch():this.unfocusSearch()}})),Ar(this,"clearSearch",(()=>{const e=this.refs.searchInput.current;e&&(e.value="",e.focus(),this.handleSearchInput())})),Ar(this,"handleCategoryClick",(({category:e,i:t})=>{this.scrollTo(0==t?{row:-1}:{categoryId:e.id})})),Ar(this,"openSkins",(e=>{const{currentTarget:t}=e,n=t.getBoundingClientRect();this.setState({showSkins:n},(async()=>{await async function(e=1){for(let t in[...Array(e).keys()])await new Promise(requestAnimationFrame)}(2);const e=this.refs.menu.current;e&&(e.classList.remove("hidden"),this.refs.skinToneRadio.current.focus(),this.base.addEventListener("click",this.handleBaseClick,!0),this.base.addEventListener("keydown",this.handleBaseKeydown,!0))}))})),this.observers=[],this.state={pos:[-1,-1],perLine:this.initDynamicPerLine(e),visibleRows:{0:!0},...this.getInitialState(e)}}}class To extends Hi{async connectedCallback(){const e=Ii(this.props,xi,this);e.element=this,e.ref=e=>{this.component=e},await Li(e),this.disconnected||hi(fi(jo,{...e}),this.shadowRoot)}constructor(e){super(e,{styles:Mr(Eo)})}}Ar(To,"Props",xi),"undefined"==typeof customElements||customElements.get("em-emoji-picker")||customElements.define("em-emoji-picker",To);var Eo={};Eo=':host {\n width: min-content;\n height: 435px;\n min-height: 230px;\n border-radius: var(--border-radius);\n box-shadow: var(--shadow);\n --border-radius: 10px;\n --category-icon-size: 18px;\n --font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;\n --font-size: 15px;\n --preview-placeholder-size: 21px;\n --preview-title-size: 1.1em;\n --preview-subtitle-size: .9em;\n --shadow-color: 0deg 0% 0%;\n --shadow: .3px .5px 2.7px hsl(var(--shadow-color) / .14), .4px .8px 1px -3.2px hsl(var(--shadow-color) / .14), 1px 2px 2.5px -4.5px hsl(var(--shadow-color) / .14);\n display: flex;\n}\n\n[data-theme="light"] {\n --em-rgb-color: var(--rgb-color, 34, 36, 39);\n --em-rgb-accent: var(--rgb-accent, 34, 102, 237);\n --em-rgb-background: var(--rgb-background, 255, 255, 255);\n --em-rgb-input: var(--rgb-input, 255, 255, 255);\n --em-color-border: var(--color-border, rgba(0, 0, 0, .05));\n --em-color-border-over: var(--color-border-over, rgba(0, 0, 0, .1));\n}\n\n[data-theme="dark"] {\n --em-rgb-color: var(--rgb-color, 222, 222, 221);\n --em-rgb-accent: var(--rgb-accent, 58, 130, 247);\n --em-rgb-background: var(--rgb-background, 21, 22, 23);\n --em-rgb-input: var(--rgb-input, 0, 0, 0);\n --em-color-border: var(--color-border, rgba(255, 255, 255, .1));\n --em-color-border-over: var(--color-border-over, rgba(255, 255, 255, .2));\n}\n\n#root {\n --color-a: rgb(var(--em-rgb-color));\n --color-b: rgba(var(--em-rgb-color), .65);\n --color-c: rgba(var(--em-rgb-color), .45);\n --padding: 12px;\n --padding-small: calc(var(--padding) / 2);\n --sidebar-width: 16px;\n --duration: 225ms;\n --duration-fast: 125ms;\n --duration-instant: 50ms;\n --easing: cubic-bezier(.4, 0, .2, 1);\n width: 100%;\n text-align: left;\n border-radius: var(--border-radius);\n background-color: rgb(var(--em-rgb-background));\n position: relative;\n}\n\n@media (prefers-reduced-motion) {\n #root {\n --duration: 0;\n --duration-fast: 0;\n --duration-instant: 0;\n }\n}\n\n#root[data-menu] button {\n cursor: auto;\n}\n\n#root[data-menu] .menu button {\n cursor: pointer;\n}\n\n:host, #root, input, button {\n color: rgb(var(--em-rgb-color));\n font-family: var(--font-family);\n font-size: var(--font-size);\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n line-height: normal;\n}\n\n*, :before, :after {\n box-sizing: border-box;\n min-width: 0;\n margin: 0;\n padding: 0;\n}\n\n.relative {\n position: relative;\n}\n\n.flex {\n display: flex;\n}\n\n.flex-auto {\n flex: none;\n}\n\n.flex-center {\n justify-content: center;\n}\n\n.flex-column {\n flex-direction: column;\n}\n\n.flex-grow {\n flex: auto;\n}\n\n.flex-middle {\n align-items: center;\n}\n\n.flex-wrap {\n flex-wrap: wrap;\n}\n\n.padding {\n padding: var(--padding);\n}\n\n.padding-t {\n padding-top: var(--padding);\n}\n\n.padding-lr {\n padding-left: var(--padding);\n padding-right: var(--padding);\n}\n\n.padding-r {\n padding-right: var(--padding);\n}\n\n.padding-small {\n padding: var(--padding-small);\n}\n\n.padding-small-b {\n padding-bottom: var(--padding-small);\n}\n\n.padding-small-lr {\n padding-left: var(--padding-small);\n padding-right: var(--padding-small);\n}\n\n.margin {\n margin: var(--padding);\n}\n\n.margin-r {\n margin-right: var(--padding);\n}\n\n.margin-l {\n margin-left: var(--padding);\n}\n\n.margin-small-l {\n margin-left: var(--padding-small);\n}\n\n.margin-small-lr {\n margin-left: var(--padding-small);\n margin-right: var(--padding-small);\n}\n\n.align-l {\n text-align: left;\n}\n\n.align-r {\n text-align: right;\n}\n\n.color-a {\n color: var(--color-a);\n}\n\n.color-b {\n color: var(--color-b);\n}\n\n.color-c {\n color: var(--color-c);\n}\n\n.ellipsis {\n white-space: nowrap;\n max-width: 100%;\n width: auto;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.sr-only {\n width: 1px;\n height: 1px;\n position: absolute;\n top: auto;\n left: -10000px;\n overflow: hidden;\n}\n\na {\n cursor: pointer;\n color: rgb(var(--em-rgb-accent));\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.spacer {\n height: 10px;\n}\n\n[dir="rtl"] .scroll {\n padding-left: 0;\n padding-right: var(--padding);\n}\n\n.scroll {\n padding-right: 0;\n overflow-x: hidden;\n overflow-y: auto;\n}\n\n.scroll::-webkit-scrollbar {\n width: var(--sidebar-width);\n height: var(--sidebar-width);\n}\n\n.scroll::-webkit-scrollbar-track {\n border: 0;\n}\n\n.scroll::-webkit-scrollbar-button {\n width: 0;\n height: 0;\n display: none;\n}\n\n.scroll::-webkit-scrollbar-corner {\n background-color: rgba(0, 0, 0, 0);\n}\n\n.scroll::-webkit-scrollbar-thumb {\n min-height: 20%;\n min-height: 65px;\n border: 4px solid rgb(var(--em-rgb-background));\n border-radius: 8px;\n}\n\n.scroll::-webkit-scrollbar-thumb:hover {\n background-color: var(--em-color-border-over) !important;\n}\n\n.scroll:hover::-webkit-scrollbar-thumb {\n background-color: var(--em-color-border);\n}\n\n.sticky {\n z-index: 1;\n background-color: rgba(var(--em-rgb-background), .9);\n -webkit-backdrop-filter: blur(4px);\n backdrop-filter: blur(4px);\n font-weight: 500;\n position: sticky;\n top: -1px;\n}\n\n[dir="rtl"] .search input[type="search"] {\n padding: 10px 2.2em 10px 2em;\n}\n\n[dir="rtl"] .search .loupe {\n left: auto;\n right: .7em;\n}\n\n[dir="rtl"] .search .delete {\n left: .7em;\n right: auto;\n}\n\n.search {\n z-index: 2;\n position: relative;\n}\n\n.search input, .search button {\n font-size: calc(var(--font-size) - 1px);\n}\n\n.search input[type="search"] {\n width: 100%;\n background-color: var(--em-color-border);\n transition-duration: var(--duration);\n transition-property: background-color, box-shadow;\n transition-timing-function: var(--easing);\n border: 0;\n border-radius: 10px;\n outline: 0;\n padding: 10px 2em 10px 2.2em;\n display: block;\n}\n\n.search input[type="search"]::-ms-input-placeholder {\n color: inherit;\n opacity: .6;\n}\n\n.search input[type="search"]::placeholder {\n color: inherit;\n opacity: .6;\n}\n\n.search input[type="search"], .search input[type="search"]::-webkit-search-decoration, .search input[type="search"]::-webkit-search-cancel-button, .search input[type="search"]::-webkit-search-results-button, .search input[type="search"]::-webkit-search-results-decoration {\n -webkit-appearance: none;\n -ms-appearance: none;\n appearance: none;\n}\n\n.search input[type="search"]:focus {\n background-color: rgb(var(--em-rgb-input));\n box-shadow: inset 0 0 0 1px rgb(var(--em-rgb-accent)), 0 1px 3px rgba(65, 69, 73, .2);\n}\n\n.search .icon {\n z-index: 1;\n color: rgba(var(--em-rgb-color), .7);\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n}\n\n.search .loupe {\n pointer-events: none;\n left: .7em;\n}\n\n.search .delete {\n right: .7em;\n}\n\nsvg {\n fill: currentColor;\n width: 1em;\n height: 1em;\n}\n\nbutton {\n -webkit-appearance: none;\n -ms-appearance: none;\n appearance: none;\n cursor: pointer;\n color: currentColor;\n background-color: rgba(0, 0, 0, 0);\n border: 0;\n}\n\n#nav {\n z-index: 2;\n padding-top: 12px;\n padding-bottom: 12px;\n padding-right: var(--sidebar-width);\n position: relative;\n}\n\n#nav button {\n color: var(--color-b);\n transition: color var(--duration) var(--easing);\n}\n\n#nav button:hover {\n color: var(--color-a);\n}\n\n#nav svg, #nav img {\n width: var(--category-icon-size);\n height: var(--category-icon-size);\n}\n\n#nav[dir="rtl"] .bar {\n left: auto;\n right: 0;\n}\n\n#nav .bar {\n width: 100%;\n height: 3px;\n background-color: rgb(var(--em-rgb-accent));\n transition: transform var(--duration) var(--easing);\n border-radius: 3px 3px 0 0;\n position: absolute;\n bottom: -12px;\n left: 0;\n}\n\n#nav button[aria-selected] {\n color: rgb(var(--em-rgb-accent));\n}\n\n#preview {\n z-index: 2;\n padding: calc(var(--padding) + 4px) var(--padding);\n padding-right: var(--sidebar-width);\n position: relative;\n}\n\n#preview .preview-placeholder {\n font-size: var(--preview-placeholder-size);\n}\n\n#preview .preview-title {\n font-size: var(--preview-title-size);\n}\n\n#preview .preview-subtitle {\n font-size: var(--preview-subtitle-size);\n}\n\n#nav:before, #preview:before {\n content: "";\n height: 2px;\n position: absolute;\n left: 0;\n right: 0;\n}\n\n#nav[data-position="top"]:before, #preview[data-position="top"]:before {\n background: linear-gradient(to bottom, var(--em-color-border), transparent);\n top: 100%;\n}\n\n#nav[data-position="bottom"]:before, #preview[data-position="bottom"]:before {\n background: linear-gradient(to top, var(--em-color-border), transparent);\n bottom: 100%;\n}\n\n.category:last-child {\n min-height: calc(100% + 1px);\n}\n\n.category button {\n font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, sans-serif;\n position: relative;\n}\n\n.category button > * {\n position: relative;\n}\n\n.category button .background {\n opacity: 0;\n background-color: var(--em-color-border);\n transition: opacity var(--duration-fast) var(--easing) var(--duration-instant);\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n\n.category button:hover .background {\n transition-duration: var(--duration-instant);\n transition-delay: 0s;\n}\n\n.category button[aria-selected] .background {\n opacity: 1;\n}\n\n.category button[data-keyboard] .background {\n transition: none;\n}\n\n.row {\n width: 100%;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n.skin-tone-button {\n border: 1px solid rgba(0, 0, 0, 0);\n border-radius: 100%;\n}\n\n.skin-tone-button:hover {\n border-color: var(--em-color-border);\n}\n\n.skin-tone-button:active .skin-tone {\n transform: scale(.85) !important;\n}\n\n.skin-tone-button .skin-tone {\n transition: transform var(--duration) var(--easing);\n}\n\n.skin-tone-button[aria-selected] {\n background-color: var(--em-color-border);\n border-top-color: rgba(0, 0, 0, .05);\n border-bottom-color: rgba(0, 0, 0, 0);\n border-left-width: 0;\n border-right-width: 0;\n}\n\n.skin-tone-button[aria-selected] .skin-tone {\n transform: scale(.9);\n}\n\n.menu {\n z-index: 2;\n white-space: nowrap;\n border: 1px solid var(--em-color-border);\n background-color: rgba(var(--em-rgb-background), .9);\n -webkit-backdrop-filter: blur(4px);\n backdrop-filter: blur(4px);\n transition-property: opacity, transform;\n transition-duration: var(--duration);\n transition-timing-function: var(--easing);\n border-radius: 10px;\n padding: 4px;\n position: absolute;\n box-shadow: 1px 1px 5px rgba(0, 0, 0, .05);\n}\n\n.menu.hidden {\n opacity: 0;\n}\n\n.menu[data-position="bottom"] {\n transform-origin: 100% 100%;\n}\n\n.menu[data-position="bottom"].hidden {\n transform: scale(.9)rotate(-3deg)translateY(5%);\n}\n\n.menu[data-position="top"] {\n transform-origin: 100% 0;\n}\n\n.menu[data-position="top"].hidden {\n transform: scale(.9)rotate(3deg)translateY(-5%);\n}\n\n.menu input[type="radio"] {\n clip: rect(0 0 0 0);\n width: 1px;\n height: 1px;\n border: 0;\n margin: 0;\n padding: 0;\n position: absolute;\n overflow: hidden;\n}\n\n.menu input[type="radio"]:checked + .option {\n box-shadow: 0 0 0 2px rgb(var(--em-rgb-accent));\n}\n\n.option {\n width: 100%;\n border-radius: 6px;\n padding: 4px 6px;\n}\n\n.option:hover {\n color: #fff;\n background-color: rgb(var(--em-rgb-accent));\n}\n\n.skin-tone {\n width: 16px;\n height: 16px;\n border-radius: 100%;\n display: inline-block;\n position: relative;\n overflow: hidden;\n}\n\n.skin-tone:after {\n content: "";\n mix-blend-mode: overlay;\n background: linear-gradient(rgba(255, 255, 255, .2), rgba(0, 0, 0, 0));\n border: 1px solid rgba(0, 0, 0, .8);\n border-radius: 100%;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n box-shadow: inset 0 -2px 3px #000, inset 0 1px 2px #fff;\n}\n\n.skin-tone-1 {\n background-color: #ffc93a;\n}\n\n.skin-tone-2 {\n background-color: #ffdab7;\n}\n\n.skin-tone-3 {\n background-color: #e7b98f;\n}\n\n.skin-tone-4 {\n background-color: #c88c61;\n}\n\n.skin-tone-5 {\n background-color: #a46134;\n}\n\n.skin-tone-6 {\n background-color: #5d4437;\n}\n\n[data-index] {\n justify-content: space-between;\n}\n\n[data-emoji-set="twitter"] .skin-tone:after {\n box-shadow: none;\n border-color: rgba(0, 0, 0, .5);\n}\n\n[data-emoji-set="twitter"] .skin-tone-1 {\n background-color: #fade72;\n}\n\n[data-emoji-set="twitter"] .skin-tone-2 {\n background-color: #f3dfd0;\n}\n\n[data-emoji-set="twitter"] .skin-tone-3 {\n background-color: #eed3a8;\n}\n\n[data-emoji-set="twitter"] .skin-tone-4 {\n background-color: #cfad8d;\n}\n\n[data-emoji-set="twitter"] .skin-tone-5 {\n background-color: #a8805d;\n}\n\n[data-emoji-set="twitter"] .skin-tone-6 {\n background-color: #765542;\n}\n\n[data-emoji-set="google"] .skin-tone:after {\n box-shadow: inset 0 0 2px 2px rgba(0, 0, 0, .4);\n}\n\n[data-emoji-set="google"] .skin-tone-1 {\n background-color: #f5c748;\n}\n\n[data-emoji-set="google"] .skin-tone-2 {\n background-color: #f1d5aa;\n}\n\n[data-emoji-set="google"] .skin-tone-3 {\n background-color: #d4b48d;\n}\n\n[data-emoji-set="google"] .skin-tone-4 {\n background-color: #aa876b;\n}\n\n[data-emoji-set="google"] .skin-tone-5 {\n background-color: #916544;\n}\n\n[data-emoji-set="google"] .skin-tone-6 {\n background-color: #61493f;\n}\n\n[data-emoji-set="facebook"] .skin-tone:after {\n border-color: rgba(0, 0, 0, .4);\n box-shadow: inset 0 -2px 3px #000, inset 0 1px 4px #fff;\n}\n\n[data-emoji-set="facebook"] .skin-tone-1 {\n background-color: #f5c748;\n}\n\n[data-emoji-set="facebook"] .skin-tone-2 {\n background-color: #f1d5aa;\n}\n\n[data-emoji-set="facebook"] .skin-tone-3 {\n background-color: #d4b48d;\n}\n\n[data-emoji-set="facebook"] .skin-tone-4 {\n background-color: #aa876b;\n}\n\n[data-emoji-set="facebook"] .skin-tone-5 {\n background-color: #916544;\n}\n\n[data-emoji-set="facebook"] .skin-tone-6 {\n background-color: #61493f;\n}\n\n';var Po=e=>{Object.assign(e,{show(){this.openValue=!0},hide(){this.openValue=!1},toggle(){this.openValue=!this.openValue},setupFloatingUI(e){var{trigger:t,popover:n}=e;this.floatingUICleanup=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:l=!1}=r,c=cr(e),u=i||o?[...c?sr(c):[],...sr(t)]:[];u.forEach((e=>{i&&e.addEventListener("scroll",n,{passive:!0}),o&&e.addEventListener("resize",n)}));const h=c&&a?function(e,t){let n,r=null;const i=Dn(e);function o(){var e;clearTimeout(n),null==(e=r)||e.disconnect(),r=null}return function s(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),o();const c=e.getBoundingClientRect(),{left:u,top:h,width:d,height:f}=c;if(a||t(),!d||!f)return;const p={rootMargin:-hn(h)+"px "+-hn(i.clientWidth-(u+d))+"px "+-hn(i.clientHeight-(h+f))+"px "+-hn(u)+"px",threshold:cn(0,ln(1,l))||1};let m=!0;function g(t){const r=t[0].intersectionRatio;if(r!==l){if(!m)return s();r?s(!1,r):n=setTimeout((()=>{s(!1,1e-7)}),1e3)}1!==r||Cr(c,e.getBoundingClientRect())||s(),m=!1}try{r=new IntersectionObserver(g,{...p,root:i.ownerDocument})}catch(e){r=new IntersectionObserver(g,p)}r.observe(e)}(!0),o}(c,n):null;let d,f=-1,p=null;s&&(p=new ResizeObserver((e=>{let[r]=e;r&&r.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(t)}))),n()})),c&&!l&&p.observe(c),p.observe(t));let m=l?fr(e):null;return l&&function t(){const r=fr(e);m&&!Cr(m,r)&&n(),m=r,d=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach((e=>{i&&e.removeEventListener("scroll",n),o&&e.removeEventListener("resize",n)})),null==h||h(),null==(e=p)||e.disconnect(),p=null,l&&cancelAnimationFrame(d)}}(t,n,(()=>{((e,t,n)=>{const r=new Map,i={platform:Or,...n},o={...i.platform,_c:r};return(async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(null==s.isRTL?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:h}=An(c,r,l),d=r,f={},p=0;for(let n=0;n{var{x:t,y:r,strategy:i}=e,o={left:"".concat(t,"px"),top:"".concat(r,"px"),position:i};Object.assign(n.style,o)}))}))},openValueChanged(){this.disabledValue||(this.openValue?(this.popoverTarget.showPopover(),this.popoverTarget.setAttribute("aria-expanded","true"),this.onPopoverOpened&&this.onPopoverOpened()):(this.popoverTarget.hidePopover(),this.popoverTarget.removeAttribute("aria-expanded"),this.onPopoverClosed&&this.onPopoverClosed()))}})};function Mo(e,t){for(var n=0;n{var[n,r]=e;t.searchParams.append(n,r)})),yield fetch(t,{method:"GET",headers:Jt.headers})})),function(e){return o.apply(this,arguments)})},{key:"create",value:(i=Fo((function*(e){var t=yield fetch(this.url,{method:"POST",headers:{Authorization:"Bearer ".concat(Jt.business.id)},body:e});return new ie(t.ok,t)})),function(e){return i.apply(this,arguments)})},{key:"markAsSeen",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=e?this.url+"/".concat(e):this.url+"/seen";fetch(t,{method:"PATCH",headers:Jt.headers,body:JSON.stringify({session:Jt.session})})}},{key:"url",get:function(){return e.endpoint.replace(":id",this.webchatId)}}],r=[{key:"endpoint",get:function(){return I.endpoint("public/webchats/:id/messages")}}],n&&Do(t.prototype,n),r&&Do(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function zo(e,t){for(var n=0;n{this.webSocket.send(JSON.stringify(i))}))}},{key:"onMessage",value:function(e){this.webSocket.addEventListener("message",(t=>{var n=JSON.parse(t.data),{type:r,message:i}=n;this.ignoredEvents.includes(r)||e(i)}))}},{key:"webSocket",get:function(){return e.webSocket?e.webSocket:e.webSocket=new WebSocket(I.actionCableUrl)}},{key:"ignoredEvents",get:function(){return["ping","confirm_subscription","welcome"]}}])&&zo(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function $o(e,t){for(var n=0;n{"message"===t.type&&e(t)}))}},{key:"onReaction",value:function(e){Ho(Uo(s.prototype),"onMessage",this).call(this,(t=>{"reaction.create"!==t.type&&"reaction.destroy"!==t.type||e(t)}))}},{key:"onTypingStart",value:function(e){Ho(Uo(s.prototype),"onMessage",this).call(this,(t=>{"started_typing"===t.type&&e(t)}))}},{key:"updateSubscriptionWith",value:function(e){this.unsubscribe(),setTimeout((()=>{this.conversation=e,this.subscribe()}),1e3)}}])&&$o(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),s}(Vo);const Wo=Ko;function Jo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Zo(e){for(var t=1;t{this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight,behavior:"instant"})}));var t=this.typingIndicatorKeepAliveValue;this.incomingTypingIndicatorTimeout=setTimeout((()=>{this.clearTypingIndicator()}),t)}},{key:"resetTypingIndicatorTimer",value:function(){if(this.typingIndicatorVisible){clearTimeout(this.incomingTypingIndicatorTimeout),clearTimeout(this.optimisticTypingTimeout);var e=this.typingIndicatorKeepAliveValue;this.incomingTypingIndicatorTimeout=setTimeout((()=>{this.clearTypingIndicator()}),e)}}},{key:"clearTypingIndicator",value:function(){this.hasTypingIndicatorTarget&&this.typingIndicatorTarget.remove(),this.typingIndicatorVisible=!1,clearTimeout(this.incomingTypingIndicatorTimeout),clearTimeout(this.optimisticTypingTimeout)}},{key:"onMessageInputChange",value:function(){this.resizeInput(),clearTimeout(this.typingIndicatorTimeout),this.hasSentTypingIndicator||(this.webChatChannel.startTypingIndicator(),this.hasSentTypingIndicator=!0),this.typingIndicatorTimeout=setTimeout((()=>{this.hasSentTypingIndicator=!1}),3e3)}},{key:"onOutboundMessageSent",value:function(e){var{data:t}=e,n={"message:sent":e=>{var t=(new DOMParser).parseFromString(e.element,"text/html").body.firstElementChild;this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(t,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(t),t.scrollIntoView({behavior:"instant"})},"message:failed":e=>{var t;null===(t=this.messagesContainerTarget.querySelector("#".concat(e.id)))||void 0===t||t.classList.add("failed")}};n[t.type]?n[t.type](t):console.log("Unhandled message event: ".concat(t.type))}},{key:"onScroll",value:(o=Yo((function*(){if(!(this.messagesContainerTarget.scrollTop>300||!this.nextPageValue||this.fetchingNextPage)){this.fetchingNextPage=!0;var e=yield this.messagesAPI.index({page:this.nextPageValue,session:Jt.session}),{next:t,messages:n}=yield e.json();this.nextPageValue=t,this.oldScrollHeight=this.messagesContainerTarget.scrollHeight,n.forEach((e=>{var{body:t,attachments:n}=e,r=document.createElement("div");r.innerHTML=t;var i=this.messageTemplateTarget.cloneNode(!0);i.setAttribute("data-hellotext--webchat-target","message"),i.style.removeProperty("display"),i.querySelector("[data-body]").innerHTML=r.innerHTML,"received"===e.state?i.classList.add("received"):i.classList.remove("received"),n&&n.forEach((e=>{var t=this.attachmentImageTarget.cloneNode(!0);t.removeAttribute("data-hellotext--webchat-target"),t.src=e,t.style.display="block",i.querySelector("[data-attachment-container]").appendChild(t)})),i.setAttribute("data-body",t),this.messagesContainerTarget.prepend(i)})),this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight-this.oldScrollHeight,behavior:"instant"}),this.fetchingNextPage=!1}})),function(){return o.apply(this,arguments)})},{key:"onClickOutside",value:function(e){A.behaviour===M.POPOVER&&this.openValue&&e.target.nodeType&&!1===this.element.contains(e.target)&&(this.openValue=!1)}},{key:"closePopover",value:function(){this.popoverTarget.classList.add(...this.fadeOutClasses),setTimeout((()=>{this.openValue=!1}),250)}},{key:"onPopoverOpened",value:function(){this.popoverTarget.classList.remove(...this.fadeOutClasses),this.onMobile||this.inputTarget.focus(),this.scrolled||(requestAnimationFrame((()=>{this.messagesContainerTarget.scroll({top:this.messagesContainerTarget.scrollHeight,behavior:"instant"})})),this.scrolled=!0),Jt.eventEmitter.dispatch("webchat:opened"),localStorage.setItem("hellotext--webchat--".concat(this.idValue),"opened"),"none"!==this.unreadCounterTarget.style.display&&(this.unreadCounterTarget.style.display="none",this.unreadCounterTarget.innerText="0",this.messagesAPI.markAsSeen())}},{key:"onPopoverClosed",value:function(){Jt.eventEmitter.dispatch("webchat:closed"),localStorage.setItem("hellotext--webchat--".concat(this.idValue),"closed")}},{key:"onMessageReaction",value:function(e){var{message:t,reaction:n,type:r}=e,i=this.messageTargets.find((e=>e.dataset.id===t)).querySelector("[data-reactions]");if("reaction.destroy"===r)return i.querySelector('[data-id="'.concat(n.id,'"]')).remove();if(i.querySelector('[data-id="'.concat(n.id,'"]')))i.querySelector('[data-id="'.concat(n.id,'"]')).innerText=n.emoji;else{var o=document.createElement("span");o.innerText=n.emoji,o.setAttribute("data-id",n.id),i.appendChild(o)}}},{key:"onMessageReceived",value:function(e){var{id:t,body:n,attachments:r}=e;if(e.carousel)return this.insertCarouselMessage(e);var i=document.createElement("div");i.innerHTML=n;var o=this.messageTemplateTarget.cloneNode(!0);if(o.style.display="flex",o.querySelector("[data-body]").innerHTML=i.innerHTML,o.setAttribute("data-hellotext--webchat-target","message"),r&&r.forEach((e=>{var t=this.attachmentImageTarget.cloneNode(!0);t.src=e,t.style.display="block",o.querySelector("[data-attachment-container]").appendChild(t)})),this.clearTypingIndicator(),this.messagesContainerTarget.appendChild(o),Jt.eventEmitter.dispatch("webchat:message:received",Zo(Zo({},e),{},{body:o.querySelector("[data-body]").innerText})),o.scrollIntoView({behavior:"smooth"}),this.openValue)this.messagesAPI.markAsSeen(t);else{this.unreadCounterTarget.style.display="flex";var s=(parseInt(this.unreadCounterTarget.innerText)||0)+1;this.unreadCounterTarget.innerText=s>99?"99+":s}}},{key:"insertCarouselMessage",value:function(e){var t,n=e.html,r=(new DOMParser).parseFromString(n,"text/html").body.firstElementChild;if(this.clearTypingIndicator(),this.messagesContainerTarget.appendChild(r),r.scrollIntoView({behavior:"smooth"}),Jt.eventEmitter.dispatch("webchat:message:received",Zo(Zo({},e),{},{body:(null===(t=r.querySelector("[data-body]"))||void 0===t?void 0:t.innerText)||""})),this.openValue)this.messagesAPI.markAsSeen(e.id);else{this.unreadCounterTarget.style.display="flex";var i=(parseInt(this.unreadCounterTarget.innerText)||0)+1;this.unreadCounterTarget.innerText=i>99?"99+":i}}},{key:"resizeInput",value:function(){this.inputTarget.style.height="auto";var e=this.inputTarget.scrollHeight;this.inputTarget.style.height="".concat(Math.min(e,96),"px")}},{key:"sendQuickReplyMessage",value:(i=Yo((function*(e){var t,{detail:{id:n,product:r,buttonId:i,body:o,cardElement:s}}=e,a=new FormData;a.append("message[body]",o),a.append("message[replied_to]",n),a.append("message[product]",r),a.append("message[button]",i),a.append("session",Jt.session),a.append("locale",j.toString());var l=this.buildMessageElement(),c=null===(t=s.querySelector("img"))||void 0===t?void 0:t.cloneNode(!0);l.querySelector("[data-body]").innerText=o,c&&(c.removeAttribute("width"),c.removeAttribute("height"),l.querySelector("[data-attachment-container]").appendChild(c)),this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(l,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(l),l.scrollIntoView({behavior:"smooth"}),this.broadcastChannel.postMessage({type:"message:sent",element:l.outerHTML});var u=yield this.messagesAPI.create(a);if(u.failed)return clearTimeout(this.optimisticTypingTimeout),this.broadcastChannel.postMessage({type:"message:failed",id:l.id}),l.classList.add("failed");var h=yield u.json();this.dispatch("set:id",{target:l,detail:h.id});var d={id:h.id,body:o,attachments:c?[c.src]:[],replied_to:n,product:r,button:i,type:"quick_reply"};Jt.eventEmitter.dispatch("webchat:message:sent",d)})),function(e){return i.apply(this,arguments)})},{key:"sendMessage",value:(r=Yo((function*(e){var t=new FormData,n={body:this.inputTarget.value,attachments:this.files};if(0!==this.inputTarget.value.trim().length||0!==this.files.length){this.inputTarget.value.trim().length>0?t.append("message[body]",this.inputTarget.value):delete n.body,this.files.forEach((e=>{t.append("message[attachments][]",e)})),t.append("session",Jt.session),t.append("locale",j.toString());var r=this.buildMessageElement();this.inputTarget.value.trim().length>0?r.querySelector("[data-body]").innerText=this.inputTarget.value:r.querySelector("[data-message-bubble]").remove();var i=this.attachmentContainerTarget.querySelectorAll("img");i.length>0&&i.forEach((e=>{r.querySelector("[data-attachment-container]").appendChild(e.cloneNode(!0))})),this.typingIndicatorVisible&&this.hasTypingIndicatorTarget?this.messagesContainerTarget.insertBefore(r,this.typingIndicatorTarget):this.messagesContainerTarget.appendChild(r),r.scrollIntoView({behavior:"smooth"}),this.broadcastChannel.postMessage({type:"message:sent",element:r.outerHTML}),this.inputTarget.value="",this.resizeInput(),this.files=[],this.attachmentInputTarget.value="",this.attachmentContainerTarget.innerHTML="",this.attachmentContainerTarget.style.display="none",this.errorMessageContainerTarget.style.display="none",this.inputTarget.focus(),this.typingIndicatorVisible||(clearTimeout(this.optimisticTypingTimeout),this.optimisticTypingTimeout=setTimeout((()=>{this.showOptimisticTypingIndicator()}),this.optimisticTypingIndicatorWaitValue));var o=yield this.messagesAPI.create(t);if(o.failed)return clearTimeout(this.optimisticTypingTimeout),this.broadcastChannel.postMessage({type:"message:failed",id:r.id}),r.classList.add("failed");var s=yield o.json();r.setAttribute("data-id",s.id),n.id=s.id,Jt.eventEmitter.dispatch("webchat:message:sent",n),s.conversation!==this.conversationIdValue&&(this.conversationIdValue=s.conversation,this.webChatChannel.updateSubscriptionWith(this.conversationIdValue)),this.typingIndicatorVisible&&this.resetTypingIndicatorTimer(),this.attachmentContainerTarget.style.display=""}else e&&e.target&&e.preventDefault()})),function(e){return r.apply(this,arguments)})},{key:"buildMessageElement",value:function(){var e=this.messageTemplateTarget.cloneNode(!0);return e.id="hellotext--webchat--".concat(this.idValue,"--message--").concat(Date.now()),e.classList.add("received"),e.style.removeProperty("display"),e.setAttribute("data-controller","hellotext--message"),e.setAttribute("data-hellotext--webchat-target","message"),e}},{key:"openAttachment",value:function(){this.attachmentInputTarget.click()}},{key:"onFileInputChange",value:function(){this.errorMessageContainerTarget.style.display="none";var e=Array.from(this.attachmentInputTarget.files);this.attachmentInputTarget.value="";var t=e.find((e=>{var t=e.type.split("/")[0];return["image","video","audio"].includes(t)?this.mediaValue[t].max_sizethis.createAttachmentElement(e))),this.inputTarget.focus()}},{key:"createAttachmentElement",value:function(e){var t=this.attachmentElement();if(this.attachmentContainerTarget.style.display="",t.setAttribute("data-name",e.name),e.type.startsWith("image/")){var n=this.attachmentImageTarget.cloneNode(!0);n.src=URL.createObjectURL(e),n.style.display="block",t.appendChild(n),this.attachmentContainerTarget.appendChild(t),this.attachmentContainerTarget.style.display="flex"}else{var r=t.querySelector("main");r.style.height="5rem",r.style.borderRadius="0.375rem",r.style.backgroundColor="#e5e7eb",r.style.padding="0.25rem",t.querySelector("p[data-attachment-name]").innerText=e.name,this.attachmentContainerTarget.appendChild(t),this.attachmentContainerTarget.style.display="flex"}}},{key:"removeAttachment",value:function(e){var{currentTarget:t}=e,n=t.closest("[data-hellotext--webchat-target='attachment']");this.files=this.files.filter((e=>e.name!==n.dataset.name)),this.attachmentInputTarget.value="",n.remove(),this.inputTarget.focus()}},{key:"attachmentTargetDisconnected",value:function(){0===this.attachmentTargets.length&&(this.attachmentContainerTarget.innerHTML="",this.attachmentContainerTarget.style.display="none")}},{key:"attachmentElement",value:function(){var e=this.attachmentTemplateTarget.cloneNode(!0);return e.removeAttribute("hidden"),e.style.display="flex",e.setAttribute("data-hellotext--webchat-target","attachment"),e}},{key:"onEmojiSelect",value:function(e){var{detail:t}=e,n=this.inputTarget.value,r=this.inputTarget.selectionStart,i=this.inputTarget.selectionEnd;this.inputTarget.value=n.slice(0,r)+t+n.slice(i),this.inputTarget.selectionStart=this.inputTarget.selectionEnd=r+t.length,this.inputTarget.focus()}},{key:"byteToMegabyte",value:function(e){return Math.ceil(e/1024/1024)}},{key:"middlewares",get:function(){return[xr(this.offsetValue),jr({padding:this.paddingValue}),Tr()]}},{key:"shouldOpenOnMount",get:function(){return"opened"===localStorage.getItem("hellotext--webchat--".concat(this.idValue))&&!this.onMobile}},{key:"onMobile",get:function(){return window.matchMedia("(max-width: ".concat(this.fullScreenThresholdValue,"px)")).matches}}],n&&Qo(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),c}(v.Qr);is.values={id:String,conversationId:String,media:Object,fileSizeErrorMessage:String,placement:{type:String,default:"bottom-end"},open:{type:Boolean,default:!1},autoPlacement:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},nextPage:{type:Number,default:void 0},fullScreenThreshold:{type:Number,default:1024},typingIndicatorKeepAlive:{type:Number,default:3e4},offset:{type:Number,default:24},padding:{type:Number,default:24},optimisticTypingIndicatorWait:{type:Number,default:1e3}},is.classes=["fadeOut"],is.targets=["trigger","popover","input","attachmentInput","attachmentButton","errorMessageContainer","attachmentTemplate","attachmentContainer","attachment","messageTemplate","messagesContainer","title","attachmentImage","footer","toolbar","message","unreadCounter","typingIndicator","typingIndicatorTemplate"];var os=v.Mx.start();os.register("hellotext--form",en),os.register("hellotext--webchat",is),os.register("hellotext--webchat--emoji",Ro),os.register("hellotext--message",on),window.Hellotext=Jt;const ss=Jt},989:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(81),i=n.n(r),o=n(645),s=n.n(o)()(i());s.push([e.id,"form[data-hello-form] {\n position: relative;\n}\n\nform[data-hello-form] article [data-error-container] {\n font-size: 0.875rem;\n line-height: 1.25rem;\n display: none;\n}\n\nform[data-hello-form] article:has(input:invalid) [data-error-container] {\n display: block;\n}\n\nform[data-hello-form] [data-logo-container] {\n display: flex;\n justify-content: center;\n align-items: flex-end;\n position: absolute;\n right: 1rem;\n bottom: 1rem;\n}\n\nform[data-hello-form] [data-logo-container] small {\n margin: 0 0.3rem;\n}\n\nform[data-hello-form] [data-logo-container] [data-hello-brand] {\n width: 4rem;\n}\n",""]);const a=s},645:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",r=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),r&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),r&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,r,i,o){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(r)for(var a=0;a0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=o),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),i&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=i):u[4]="".concat(i)),t.push(u))}},t}},81:e=>{e.exports=function(e){return e[1]}},379:e=>{var t=[];function n(e){for(var n=-1,r=0;r{var t={};e.exports=function(e,n){var r=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!r)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");r.appendChild(n)}},216:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,n)=>{e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},795:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,n){var r="";n.supports&&(r+="@supports (".concat(n.supports,") {")),n.media&&(r+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(r+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),r+=n.css,i&&(r+="}"),n.media&&(r+="}"),n.supports&&(r+="}");var o=n.sourceMap;o&&"undefined"!=typeof btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(r,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nc=void 0,n(599);var r=n(184);return r.default})())); \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index d71cc2c..c093c9a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -70,7 +70,8 @@ declare class Hellotext { export declare class User { static get id(): string | undefined static get source(): string | undefined - static remember(id: string, source?: string): void + static get fingerprint(): string | undefined + static remember(id: string, source?: string, fingerprint?: string): void static forget(): void static get identificationData(): IdentificationData | Record } diff --git a/lib/hellotext.cjs b/lib/hellotext.cjs index bd787b8..af7707a 100644 --- a/lib/hellotext.cjs +++ b/lib/hellotext.cjs @@ -85,7 +85,9 @@ let Hellotext = /*#__PURE__*/function () { * @property { String } [name] - the name of the user * @property { String } [source] - the platform specific identifier where this pixel is running on. * - * Identifies a user and attaches the hello_session to the user ID + * Identifies a user and attaches the hello_session to the user ID. + * Repeated calls are skipped only when the last successful identify payload + * for the current session remains unchanged. * @param { String } externalId - the user ID * @param { IdentificationOptions } options - the options for the identification * @returns {Promise} @@ -93,11 +95,12 @@ let Hellotext = /*#__PURE__*/function () { }, { key: "identify", value: async function identify(externalId, options = {}) { - if (_models.User.id === externalId) { + const fingerprint = await _models.Fingerprint.generate(this.session, externalId, options); + if (_models.Fingerprint.matches(_models.User.fingerprint, fingerprint)) { return new _api.Response(true, { - json: async () => { - already_identified: true; - } + json: async () => ({ + already_identified: true + }) }); } const response = await _api.default.identifications.create({ @@ -105,7 +108,7 @@ let Hellotext = /*#__PURE__*/function () { ...options }); if (response.succeeded) { - _models.User.remember(externalId, options.source); + _models.User.remember(externalId, options.source, fingerprint); } return response; } diff --git a/lib/hellotext.js b/lib/hellotext.js index ff0a193..ca7316e 100644 --- a/lib/hellotext.js +++ b/lib/hellotext.js @@ -10,7 +10,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } import { Configuration, Event } from './core'; import API, { Response } from './api'; -import { Business, FormCollection, Page, Query, Session, User, Webchat } from './models'; +import { Business, Fingerprint, FormCollection, Page, Query, Session, User, Webchat } from './models'; import { NotInitializedError } from './errors'; var Hellotext = /*#__PURE__*/function () { function Hellotext() { @@ -85,7 +85,9 @@ var Hellotext = /*#__PURE__*/function () { * @property { String } [name] - the name of the user * @property { String } [source] - the platform specific identifier where this pixel is running on. * - * Identifies a user and attaches the hello_session to the user ID + * Identifies a user and attaches the hello_session to the user ID. + * Repeated calls are skipped only when the last successful identify payload + * for the current session remains unchanged. * @param { String } externalId - the user ID * @param { IdentificationOptions } options - the options for the identification * @returns {Promise} @@ -95,11 +97,14 @@ var Hellotext = /*#__PURE__*/function () { value: function () { var _identify = _asyncToGenerator(function* (externalId) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (User.id === externalId) { + var fingerprint = yield Fingerprint.generate(this.session, externalId, options); + if (Fingerprint.matches(User.fingerprint, fingerprint)) { return new Response(true, { json: function () { var _json = _asyncToGenerator(function* () { - already_identified: true; + return { + already_identified: true + }; }); function json() { return _json.apply(this, arguments); @@ -112,7 +117,7 @@ var Hellotext = /*#__PURE__*/function () { user_id: externalId }, options)); if (response.succeeded) { - User.remember(externalId, options.source); + User.remember(externalId, options.source, fingerprint); } return response; }); diff --git a/lib/models/fingerprint.cjs b/lib/models/fingerprint.cjs new file mode 100644 index 0000000..ebd8938 --- /dev/null +++ b/lib/models/fingerprint.cjs @@ -0,0 +1,89 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Fingerprint = void 0; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function normalizeValue(value) { + // Collapse "missing" values so callers can add optional fields incrementally + // without changing the fingerprint when the effective payload is the same. + if (value === null || value === undefined) { + return undefined; + } + if (typeof value === 'string') { + const trimmedValue = value.trim(); + + // Treat blank strings as absent values so "" and an omitted field compare equally. + return trimmedValue === '' ? undefined : trimmedValue; + } + if (Array.isArray(value)) { + // Preserve array order because, unlike object keys, caller-provided sequence can be meaningful. + return value.map(item => normalizeValue(item)).filter(item => item !== undefined); + } + if (value instanceof Date) { + // Serialize dates into a stable primitive so equivalent timestamps fingerprint the same way. + return value.toISOString(); + } + if (typeof value === 'object') { + // Canonicalize object shape by sorting keys recursively, so key placement never affects equality. + const normalizedObject = Object.keys(value).sort((leftKey, rightKey) => leftKey.localeCompare(rightKey)).reduce((result, key) => { + const normalizedChild = normalizeValue(value[key]); + if (normalizedChild !== undefined) { + result[key] = normalizedChild; + } + return result; + }, {}); + return Object.keys(normalizedObject).length > 0 ? normalizedObject : undefined; + } + if (typeof value === 'number' || typeof value === 'boolean') { + return value; + } + return undefined; +} +function serializePayload(session, userId, options = {}) { + const normalizedPayload = normalizeValue({ + session, + user_id: userId, + ...options + }) || {}; + return JSON.stringify(normalizedPayload); +} +function fallbackHash(value) { + let hash = 5381; + for (let index = 0; index < value.length; index += 1) { + hash = hash * 33 ^ value.charCodeAt(index); + } + return `v1:${(hash >>> 0).toString(16)}`; +} +async function sha256(value) { + var _globalThis$crypto; + if (!((_globalThis$crypto = globalThis.crypto) !== null && _globalThis$crypto !== void 0 && _globalThis$crypto.subtle) || typeof TextEncoder === 'undefined') { + return fallbackHash(value); + } + const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(value)); + const hex = Array.from(new Uint8Array(digest)).map(byte => byte.toString(16).padStart(2, '0')).join(''); + return `v1:${hex}`; +} +let Fingerprint = /*#__PURE__*/function () { + function Fingerprint() { + _classCallCheck(this, Fingerprint); + } + _createClass(Fingerprint, null, [{ + key: "matches", + value: function matches(storedFingerprint, fingerprint) { + return !!storedFingerprint && storedFingerprint === fingerprint; + } + }, { + key: "generate", + value: async function generate(session, userId, options = {}) { + return await sha256(serializePayload(session, userId, options)); + } + }]); + return Fingerprint; +}(); +exports.Fingerprint = Fingerprint; \ No newline at end of file diff --git a/lib/models/fingerprint.js b/lib/models/fingerprint.js new file mode 100644 index 0000000..9532a31 --- /dev/null +++ b/lib/models/fingerprint.js @@ -0,0 +1,101 @@ +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function normalizeValue(value) { + // Collapse "missing" values so callers can add optional fields incrementally + // without changing the fingerprint when the effective payload is the same. + if (value === null || value === undefined) { + return undefined; + } + if (typeof value === 'string') { + var trimmedValue = value.trim(); + + // Treat blank strings as absent values so "" and an omitted field compare equally. + return trimmedValue === '' ? undefined : trimmedValue; + } + if (Array.isArray(value)) { + // Preserve array order because, unlike object keys, caller-provided sequence can be meaningful. + return value.map(item => normalizeValue(item)).filter(item => item !== undefined); + } + if (value instanceof Date) { + // Serialize dates into a stable primitive so equivalent timestamps fingerprint the same way. + return value.toISOString(); + } + if (typeof value === 'object') { + // Canonicalize object shape by sorting keys recursively, so key placement never affects equality. + var normalizedObject = Object.keys(value).sort((leftKey, rightKey) => leftKey.localeCompare(rightKey)).reduce((result, key) => { + var normalizedChild = normalizeValue(value[key]); + if (normalizedChild !== undefined) { + result[key] = normalizedChild; + } + return result; + }, {}); + return Object.keys(normalizedObject).length > 0 ? normalizedObject : undefined; + } + if (typeof value === 'number' || typeof value === 'boolean') { + return value; + } + return undefined; +} +function serializePayload(session, userId) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var normalizedPayload = normalizeValue(_objectSpread({ + session, + user_id: userId + }, options)) || {}; + return JSON.stringify(normalizedPayload); +} +function fallbackHash(value) { + var hash = 5381; + for (var index = 0; index < value.length; index += 1) { + hash = hash * 33 ^ value.charCodeAt(index); + } + return "v1:".concat((hash >>> 0).toString(16)); +} +function sha256(_x) { + return _sha.apply(this, arguments); +} +function _sha() { + _sha = _asyncToGenerator(function* (value) { + var _globalThis$crypto; + if (!((_globalThis$crypto = globalThis.crypto) !== null && _globalThis$crypto !== void 0 && _globalThis$crypto.subtle) || typeof TextEncoder === 'undefined') { + return fallbackHash(value); + } + var digest = yield globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(value)); + var hex = Array.from(new Uint8Array(digest)).map(byte => byte.toString(16).padStart(2, '0')).join(''); + return "v1:".concat(hex); + }); + return _sha.apply(this, arguments); +} +var Fingerprint = /*#__PURE__*/function () { + function Fingerprint() { + _classCallCheck(this, Fingerprint); + } + _createClass(Fingerprint, null, [{ + key: "matches", + value: function matches(storedFingerprint, fingerprint) { + return !!storedFingerprint && storedFingerprint === fingerprint; + } + }, { + key: "generate", + value: function () { + var _generate = _asyncToGenerator(function* (session, userId) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + return yield sha256(serializePayload(session, userId, options)); + }); + function generate(_x2, _x3) { + return _generate.apply(this, arguments); + } + return generate; + }() + }]); + return Fingerprint; +}(); +export { Fingerprint }; \ No newline at end of file diff --git a/lib/models/index.cjs b/lib/models/index.cjs index 6033bd0..9a9c7c4 100644 --- a/lib/models/index.cjs +++ b/lib/models/index.cjs @@ -15,6 +15,12 @@ Object.defineProperty(exports, "Cookies", { return _cookies.Cookies; } }); +Object.defineProperty(exports, "Fingerprint", { + enumerable: true, + get: function () { + return _fingerprint.Fingerprint; + } +}); Object.defineProperty(exports, "Form", { enumerable: true, get: function () { @@ -65,6 +71,7 @@ Object.defineProperty(exports, "Webchat", { }); var _business = require("./business"); var _cookies = require("./cookies"); +var _fingerprint = require("./fingerprint"); var _form = require("./form"); var _form_collection = require("./form_collection"); var _page = require("./page"); diff --git a/lib/models/index.js b/lib/models/index.js index 9495091..c101028 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -1,5 +1,6 @@ export { Business } from './business'; export { Cookies } from './cookies'; +export { Fingerprint } from './fingerprint'; export { Form } from './form'; export { FormCollection } from './form_collection'; export { Page } from './page'; diff --git a/lib/models/user.cjs b/lib/models/user.cjs index 007c126..d50bbde 100644 --- a/lib/models/user.cjs +++ b/lib/models/user.cjs @@ -24,12 +24,20 @@ let User = /*#__PURE__*/function () { get: function () { return _cookies.Cookies.get('hello_user_source'); } + }, { + key: "fingerprint", + get: function () { + return _cookies.Cookies.get('hello_user_identification_hash'); + } }, { key: "remember", - value: function remember(id, source) { + value: function remember(id, source, fingerprint) { if (source) { _cookies.Cookies.set('hello_user_source', source); } + if (fingerprint) { + _cookies.Cookies.set('hello_user_identification_hash', fingerprint); + } _cookies.Cookies.set('hello_user_id', id); } }, { @@ -37,6 +45,7 @@ let User = /*#__PURE__*/function () { value: function forget() { _cookies.Cookies.delete('hello_user_id'); _cookies.Cookies.delete('hello_user_source'); + _cookies.Cookies.delete('hello_user_identification_hash'); } }, { key: "identificationData", diff --git a/lib/models/user.js b/lib/models/user.js index 0b41a93..d168c5b 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -18,12 +18,20 @@ var User = /*#__PURE__*/function () { get: function get() { return Cookies.get('hello_user_source'); } + }, { + key: "fingerprint", + get: function get() { + return Cookies.get('hello_user_identification_hash'); + } }, { key: "remember", - value: function remember(id, source) { + value: function remember(id, source, fingerprint) { if (source) { Cookies.set('hello_user_source', source); } + if (fingerprint) { + Cookies.set('hello_user_identification_hash', fingerprint); + } Cookies.set('hello_user_id', id); } }, { @@ -31,6 +39,7 @@ var User = /*#__PURE__*/function () { value: function forget() { Cookies.delete('hello_user_id'); Cookies.delete('hello_user_source'); + Cookies.delete('hello_user_identification_hash'); } }, { key: "identificationData", diff --git a/src/hellotext.js b/src/hellotext.js index b3b287b..27213dd 100644 --- a/src/hellotext.js +++ b/src/hellotext.js @@ -1,7 +1,7 @@ import { Configuration, Event } from './core' import API, { Response } from './api' -import { Business, FormCollection, Page, Query, Session, User, Webchat } from './models' +import { Business, Fingerprint, FormCollection, Page, Query, Session, User, Webchat } from './models' import { NotInitializedError } from './errors' @@ -83,17 +83,21 @@ class Hellotext { * @property { String } [name] - the name of the user * @property { String } [source] - the platform specific identifier where this pixel is running on. * - * Identifies a user and attaches the hello_session to the user ID + * Identifies a user and attaches the hello_session to the user ID. + * Repeated calls are skipped only when the last successful identify payload + * for the current session remains unchanged. * @param { String } externalId - the user ID * @param { IdentificationOptions } options - the options for the identification * @returns {Promise} */ static async identify(externalId, options = {}) { - if (User.id === externalId) { + const fingerprint = await Fingerprint.generate(this.session, externalId, options) + + if (Fingerprint.matches(User.fingerprint, fingerprint)) { return new Response(true, { - json: async () => { - already_identified: true - }, + json: async () => ({ + already_identified: true, + }), }) } @@ -103,7 +107,11 @@ class Hellotext { }) if (response.succeeded) { - User.remember(externalId, options.source) + User.remember( + externalId, + options.source, + fingerprint, + ) } return response diff --git a/src/models/fingerprint.js b/src/models/fingerprint.js new file mode 100644 index 0000000..1471a4a --- /dev/null +++ b/src/models/fingerprint.js @@ -0,0 +1,98 @@ +function normalizeValue(value) { + // Collapse "missing" values so callers can add optional fields incrementally + // without changing the fingerprint when the effective payload is the same. + if (value === null || value === undefined) { + return undefined + } + + if (typeof value === 'string') { + const trimmedValue = value.trim() + + // Treat blank strings as absent values so "" and an omitted field compare equally. + return trimmedValue === '' ? undefined : trimmedValue + } + + if (Array.isArray(value)) { + // Preserve array order because, unlike object keys, caller-provided sequence can be meaningful. + return value + .map(item => normalizeValue(item)) + .filter(item => item !== undefined) + } + + if (value instanceof Date) { + // Serialize dates into a stable primitive so equivalent timestamps fingerprint the same way. + return value.toISOString() + } + + if (typeof value === 'object') { + // Canonicalize object shape by sorting keys recursively, so key placement never affects equality. + const normalizedObject = Object.keys(value) + .sort((leftKey, rightKey) => leftKey.localeCompare(rightKey)) + .reduce((result, key) => { + const normalizedChild = normalizeValue(value[key]) + + if (normalizedChild !== undefined) { + result[key] = normalizedChild + } + + return result + }, {}) + + return Object.keys(normalizedObject).length > 0 ? normalizedObject : undefined + } + + if (typeof value === 'number' || typeof value === 'boolean') { + return value + } + + return undefined +} + +function serializePayload(session, userId, options = {}) { + const normalizedPayload = normalizeValue({ + session, + user_id: userId, + ...options, + }) || {} + + return JSON.stringify(normalizedPayload) +} + +function fallbackHash(value) { + let hash = 5381 + + for (let index = 0; index < value.length; index += 1) { + hash = (hash * 33) ^ value.charCodeAt(index) + } + + return `v1:${(hash >>> 0).toString(16)}` +} + +async function sha256(value) { + if (!globalThis.crypto?.subtle || typeof TextEncoder === 'undefined') { + return fallbackHash(value) + } + + const digest = await globalThis.crypto.subtle.digest( + 'SHA-256', + new TextEncoder().encode(value), + ) + + const hex = Array.from(new Uint8Array(digest)) + .map(byte => byte.toString(16).padStart(2, '0')) + .join('') + + return `v1:${hex}` +} + +class Fingerprint { + static matches(storedFingerprint, fingerprint) { + return !!storedFingerprint && storedFingerprint === fingerprint + } + + static async generate(session, userId, options = {}) { + return await sha256(serializePayload(session, userId, options)) + } +} + +export { Fingerprint } diff --git a/src/models/index.js b/src/models/index.js index 36018e2..4835f36 100644 --- a/src/models/index.js +++ b/src/models/index.js @@ -1,5 +1,6 @@ export { Business } from './business' export { Cookies } from './cookies' +export { Fingerprint } from './fingerprint' export { Form } from './form' export { FormCollection } from './form_collection' export { Page } from './page' diff --git a/src/models/user.js b/src/models/user.js index 2087a2f..e30271a 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -9,17 +9,26 @@ class User { return Cookies.get('hello_user_source') } - static remember(id, source) { + static get fingerprint() { + return Cookies.get('hello_user_identification_hash') + } + + static remember(id, source, fingerprint) { if (source) { Cookies.set('hello_user_source', source) } + if (fingerprint) { + Cookies.set('hello_user_identification_hash', fingerprint) + } + Cookies.set('hello_user_id', id) } static forget() { Cookies.delete('hello_user_id') Cookies.delete('hello_user_source') + Cookies.delete('hello_user_identification_hash') } static get identificationData() {