diff --git a/static/assets/app.js b/static/assets/app.js index dca01891c..63e95fc9d 100644 --- a/static/assets/app.js +++ b/static/assets/app.js @@ -299,7 +299,7 @@ ${o.message}`)))}function uJ(){return import("./mermaid.core-IHQY3BMC.js") `}var Die=new Bt(t=>t.isLoaded?Lie(t):Iie(t)),wm=hi("picker","skeleton","placeholder","searchSkeleton","searchInput","categoryTabsSkeleton","headerSkeleton","categoryTab","contentSkeleton","categoryName","emojiGrid","emoji","previewSkeleton","previewEmoji","previewName","tagList","tag","overlay","content","fullHeight","pluginContainer","header"),km={emojisPerRow:"--emojis-per-row",visibleRows:"--row-count",emojiSize:"--emoji-size"},N2=class extends Me{constructor(){super({template:Die,classes:wm}),this.pickerReady=!1,this.externalEvents=new S2,this.updaters={styleProperty:e=>i=>this.el.style.setProperty(km[e],i.toString()),theme:e=>{let i=this.options.theme,r=this.el.closest(`.${i}`);this.el.classList.remove(i),r==null||r.classList.remove(i),this.el.classList.add(e),r==null||r.classList.add(e)},className:e=>{this.options.className&&this.el.classList.remove(this.options.className),this.el.classList.add(e)},emojisPerRow:this.updateStyleProperty.bind(this,"emojisPerRow"),emojiSize:this.updateStyleProperty.bind(this,"emojiSize"),visibleRows:this.updateStyleProperty.bind(this,"visibleRows")}}initialize(){this.uiElements={pickerContent:Me.byClass(wm.content),header:Me.byClass(wm.header)},this.uiEvents=[Me.uiEvent("keydown",this.handleKeyDown)],this.appEvents={error:this.onError,reinitialize:this.reinitialize,"data:ready":this.onDataReady,"content:show":this.showContent,"variantPopup:hide":this.hideVariantPopup,"emoji:select":this.selectEmoji},super.initialize(),this.options.recentsProvider}destroy(){var e,i;super.destroy(),(e=this.search)==null||e.destroy(),this.emojiArea.destroy(),(i=this.categoryTabs)==null||i.destroy(),this.events.removeAll(),this.externalEvents.removeAll()}clearRecents(){this.options.recentsProvider.clear()}addEventListener(e,i){this.externalEvents.on(e,i)}removeEventListener(e,i){this.externalEvents.off(e,i)}initializePickerView(){this.pickerReady&&(this.showContent(),this.emojiArea.reset(!1))}handleKeyDown(e){let i=e.ctrlKey||e.metaKey;e.key==="s"&&i&&this.search&&(e.preventDefault(),this.search.focus())}buildChildViews(){return this.options.showPreview&&(this.preview=this.viewFactory.create(X2)),this.options.showSearch&&(this.search=this.viewFactory.create(R2,{categories:this.categories,emojiVersion:this.emojiVersion})),this.options.showCategoryTabs&&(this.categoryTabs=this.viewFactory.create(D2,{categories:this.categories})),this.currentView=this.emojiArea=this.viewFactory.create(A2,{categoryTabs:this.categoryTabs,categories:this.categories,emojiVersion:this.emojiVersion}),[this.preview,this.search,this.emojiArea,this.categoryTabs]}setStyleProperties(){this.options.showSearch||this.el.style.setProperty("--search-height-full","0px"),this.options.showCategoryTabs||(this.el.style.setProperty("--category-tabs-height","0px"),this.el.style.setProperty("--category-tabs-offset","0px")),this.options.showPreview||this.el.style.setProperty("--emoji-preview-height-full","0px"),Object.keys(km).forEach(e=>{this.options[e]&&this.el.style.setProperty(km[e],this.options[e].toString())})}updateStyleProperty(e,i){this.el.style.setProperty(km[e],i.toString())}reinitialize(){this.renderSync()}onError(e){let i=this.viewFactory.createWithOptions({data:!1},$2,{message:this.i18n.get("error.load")}),r=this.el.offsetHeight||375;throw this.el.style.height=`${r}px`,jl(this.el,i.renderSync()),e}async onDataReady(e){let i=this.el;try{e?this.emojiData=e:await this.emojiDataPromise,this.options.emojiVersion==="auto"?this.emojiVersion=$ie()||parseFloat(bte):this.emojiVersion=this.options.emojiVersion,this.categories=await this.emojiData.getCategories(this.options);let[r,n,o,s]=this.buildChildViews();await super.render({isLoaded:!0,search:n,categoryTabs:s,emojiArea:o,preview:r,showHeader:!!(this.search||this.categoryTabs),theme:this.options.theme,className:this.options.className}),this.el.style.setProperty("--category-count",this.categories.length.toString()),this.pickerReady=!0,i.replaceWith(this.el),this.setStyleProperties(),this.initializePickerView(),this.setInitialFocus(),this.externalEvents.emit("data:ready")}catch(r){this.events.emit("error",r)}}renderSync(){var e;let i=((e=this.options.categories)==null?void 0:e.length)||10;if(this.options.showRecents&&(i+=1),super.renderSync({isLoaded:!1,theme:this.options.theme,className:this.options.className,showSearch:this.options.showSearch,showPreview:this.options.showPreview,showCategoryTabs:this.options.showCategoryTabs,showHeader:this.options.showSearch||this.options.showCategoryTabs,emojiCount:this.options.emojisPerRow*this.options.visibleRows,categoryCount:i}),this.el.style.setProperty("--category-count",i.toString()),!this.options.rootElement)throw new Error("Picker must be given a root element via the rootElement option");return jl(this.options.rootElement,this.el),this.setStyleProperties(),this.pickerReady&&this.initializePickerView(),this.el}getInitialFocusTarget(){if(typeof this.options.autoFocus<"u")switch(this.options.autoFocus){case"emojis":return this.emojiArea.focusableEmoji;case"search":return this.search;case"auto":return this.search||this.emojiArea.focusableEmoji;default:return null}if(this.options.autoFocusSearch===!0)return console.warn("options.autoFocusSearch is deprecated, please use options.focusTarget instead"),this.search}setInitialFocus(){var e;!this.pickerReady||(e=this.getInitialFocusTarget())==null||e.focus()}reset(e=!0){var i;this.pickerReady&&(this.emojiArea.reset(e),this.showContent(this.emojiArea)),(i=this.search)==null||i.clear(),this.hideVariantPopup()}showContent(e=this.emojiArea){var i,r;e!==this.currentView&&(this.currentView!==this.emojiArea&&((i=this.currentView)==null||i.destroy()),this.ui.pickerContent.classList.toggle(wm.fullHeight,e!==this.emojiArea),jl(this.ui.pickerContent,e.el),this.currentView=e,e===this.emojiArea?(this.emojiArea.reset(),this.categoryTabs&&this.ui.header.appendChild(this.categoryTabs.el)):(r=this.categoryTabs)==null||r.el.remove())}hideVariantPopup(){var e;(e=this.variantPopup)==null||e.destroy()}isPickerClick(e){var i,r;let n=e.target,o=this.el.contains(n),s=(r=(i=this.variantPopup)==null?void 0:i.el)==null?void 0:r.contains(n);return o||s}async selectEmoji({emoji:e}){var i,r;(i=e.skins)!=null&&i.length&&this.options.showVariants&&!this.isVariantPopupOpen?this.showVariantPopup(e):(await((r=this.variantPopup)==null?void 0:r.animateHide()),this.events.emit("variantPopup:hide"),await this.emitEmoji(e))}get isVariantPopupOpen(){return this.variantPopup&&!this.variantPopup.isDestroyed}async showVariantPopup(e){let i=document.activeElement;this.events.once("variantPopup:hide",()=>{i==null||i.focus()}),this.variantPopup=this.viewFactory.create(L2,{emoji:e,parent:this.el}),this.el.appendChild(this.variantPopup.renderSync()),this.variantPopup.activate()}async emitEmoji(e){this.externalEvents.emit("emoji:select",await this.renderer.doEmit(e)),this.options.recentsProvider.addOrUpdateRecent(e,this.options.maxRecents),this.events.emit("recent:add",e)}updateOptions(e){Object.keys(e).forEach(i=>{this.updaters[i](e[i])}),Object.assign(this.options,e)}},M2=class{constructor({events:e,i18n:i,renderer:r,emojiData:n,options:o,customEmojis:s=[],pickerId:a}){this.events=e,this.i18n=i,this.renderer=r,this.emojiData=n,this.options=o,this.customEmojis=s,this.pickerId=a}setEmojiData(e){this.emojiData=Promise.resolve(e)}createWithOptions(e={},i,...r){let n=new i(...r);return n.setPickerId(this.pickerId),n.setEvents(this.events),n.setI18n(this.i18n),n.setRenderer(this.renderer),e.data!==!1&&n.setEmojiData(this.emojiData),n.setOptions(this.options),n.setCustomEmojis(this.customEmojis),n.viewFactory=this,n.initialize(),n}create(e,...i){return this.createWithOptions({},e,...i)}},Am,U2=class{constructor(e={}){no(this,Am,void 0),l2(this,Am,new Map(Object.entries(e)))}get(e,i=e){return oo(this,Am).get(e)||i}};Am=new WeakMap;function Nie(t,e){e===void 0&&(e={});var i=e.insertAt;if(!(!t||typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",i==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}function B2(){let t=!1;return function(e){lie.injectStyles&&!t&&(Nie(e),t=!0)}}var Mie=`.picmo__picker .picmo__icon{width:1.25em;height:1em;fill:currentColor}.picmo__icon-small{font-size:.8em}.picmo__icon-medium{font-size:1em}.picmo__icon-large{font-size:1.25em}.picmo__icon-2x{font-size:2em}.picmo__icon-3x{font-size:3em}.picmo__icon-4x{font-size:4em}.picmo__icon-5x{font-size:5em}.picmo__icon-8x{font-size:8em}.picmo__icon-10x{font-size:10em}.picmo__light,.picmo__auto{color-scheme:light;--accent-color: #4f46e5;--background-color: #f9fafb;--border-color: #cccccc;--category-name-background-color: #f9fafb;--category-name-button-color: #999999;--category-name-text-color: hsl(214, 30%, 50%);--category-tab-active-background-color: rgba(255, 255, 255, .6);--category-tab-active-color: var(--accent-color);--category-tab-color: #666;--category-tab-highlight-background-color: rgba(0, 0, 0, .15);--error-color-dark: hsl(0, 100%, 45%);--error-color: hsl(0, 100%, 40%);--focus-indicator-background-color: hsl(198, 65%, 85%);--focus-indicator-color: #333333;--hover-background-color: #c7d2fe;--placeholder-background-color: #cccccc;--search-background-color: #f9fafb;--search-focus-background-color: #ffffff;--search-icon-color: #999999;--search-placeholder-color: #71717a;--secondary-background-color: #e2e8f0;--secondary-text-color: #666666;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #000000;--variant-popup-background-color: #ffffff}.picmo__dark{color-scheme:dark;--accent-color: #A580F9;--background-color: #333333;--border-color: #666666;--category-name-background-color: #333333;--category-name-button-color: #eeeeee;--category-name-text-color: #ffffff;--category-tab-active-background-color: #000000;--category-tab-active-color: var(--accent-color);--category-tab-color: #cccccc;--category-tab-highlight-background-color: #4A4A4A;--error-color-dark: hsl(0, 7%, 3%);--error-color: hsl(0, 30%, 60%);--focus-indicator-background-color: hsl(0, 0%, 50%);--focus-indicator-color: #999999;--hover-background-color: hsla(0, 0%, 40%, .85);--image-placeholder-color: #ffffff;--placeholder-background-color: #666666;--search-background-color: #71717a;--search-focus-background-color: #52525b;--search-icon-color: #cccccc;--search-placeholder-color: #d4d4d8;--secondary-background-color: #000000;--secondary-text-color: #999999;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #ffffff;--variant-popup-background-color: #333333}@media (prefers-color-scheme: dark){.picmo__auto{color-scheme:dark;--accent-color: #A580F9;--background-color: #333333;--border-color: #666666;--category-name-background-color: #333333;--category-name-button-color: #eeeeee;--category-name-text-color: #ffffff;--category-tab-active-background-color: #000000;--category-tab-active-color: var(--accent-color);--category-tab-color: #cccccc;--category-tab-highlight-background-color: #4A4A4A;--error-color-dark: hsl(0, 7%, 3%);--error-color: hsl(0, 30%, 60%);--focus-indicator-background-color: hsl(0, 0%, 50%);--focus-indicator-color: #999999;--hover-background-color: hsla(0, 0%, 40%, .85);--image-placeholder-color: #ffffff;--placeholder-background-color: #666666;--search-background-color: #71717a;--search-focus-background-color: #52525b;--search-icon-color: #cccccc;--search-placeholder-color: #d4d4d8;--secondary-background-color: #000000;--secondary-text-color: #999999;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #ffffff;--variant-popup-background-color: #333333}}.picmo__picker .picmo__categoryButtonsContainer{overflow:auto;padding:2px 0}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-right{mask-image:linear-gradient(270deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%);-webkit-mask-image:linear-gradient(270deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%)}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-left{mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%);-webkit-mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%)}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-both{mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%,rgba(255,255,255,1) 90%,rgba(255,255,255,0) 100%);-webkit-mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%,rgba(255,255,255,1) 90%,rgba(255,255,255,0) 100%)}.picmo__picker .picmo__categoryButtons{display:flex;flex-direction:row;gap:var(--tab-gap);margin:0;padding:0 .5em;align-items:center;height:var(--category-tabs-height);box-sizing:border-box;width:100%;justify-content:space-between;position:relative;list-style-type:none;justify-self:center;max-width:min(23.55rem,calc(var(--category-count, 1) * 2.5rem))}.picmo__picker .picmo__categoryButtons .picmo__categoryTab{display:flex;align-items:center;transition:all .1s;width:2em}.picmo__picker .picmo__categoryButtons .picmo__categoryTab.picmo__categoryTabActive .picmo__categoryButton{color:var(--category-tab-active-color);background:linear-gradient(rgba(255,255,255,.75) 0%,rgba(255,255,255,.75) 100%),linear-gradient(var(--category-tab-active-color) 0%,var(--category-tab-active-color) 100%);border:2px solid var(--category-tab-active-color)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab.picmo__categoryTabActive .picmo__categoryButton:hover{background-color:var(--category-tab-active-background-color)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton{border-radius:5px;background:transparent;border:2px solid transparent;color:var(--category-tab-color);cursor:pointer;padding:2px;vertical-align:middle;display:flex;align-items:center;justify-content:center;font-size:1.2rem;width:1.6em;height:1.6em;transition:all .1s}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton:is(img){width:var(--category-tab-size);height:var(--category-tab-size)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton:hover{background:var(--category-tab-highlight-background-color)}.picmo__dataError [data-icon]{opacity:.8}@keyframes appear{0%{opacity:0}to{opacity:.8}}@keyframes appear-grow{0%{opacity:0;transform:scale(.8)}to{opacity:.8;transform:scale(1)}}.picmo__picker .picmo__error{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--secondary-text-color)}.picmo__picker .picmo__error .picmo__iconContainer{opacity:.8;animation:appear-grow .25s cubic-bezier(.175,.885,.32,1.275);--color-primary: var(--error-color);--color-secondary: var(--error-color-dark)}.picmo__picker .picmo__error .picmo__title{animation:appear .25s;animation-delay:50ms;animation-fill-mode:both}.picmo__picker .picmo__error button{padding:8px 16px;cursor:pointer;background:var(--background-color);border:1px solid var(--text-color);border-radius:5px;color:var(--text-color)}.picmo__picker .picmo__error button:hover{background:var(--text-color);color:var(--background-color)}.picmo__emojiButton{background:transparent;border:none;border-radius:15px;cursor:pointer;display:flex;font-family:var(--emoji-font);font-size:var(--emoji-size);height:100%;justify-content:center;align-items:center;margin:0;overflow:hidden;padding:0;width:100%}.picmo__emojiButton:hover{background:var(--hover-background-color)}.picmo__emojiButton:focus{border-radius:0;background:var(--focus-indicator-background-color);outline:1px solid var(--focus-indicator-color)}.picmo__picker .picmo__emojiArea{height:var(--emoji-area-height);overflow-y:auto;position:relative}.picmo__picker .picmo__emojiCategory{position:relative}.picmo__picker .picmo__emojiCategory .picmo__categoryName{font-size:.9em;padding:.5rem;margin:0;background:var(--category-name-background-color);color:var(--category-name-text-color);top:0;z-index:1;display:grid;gap:4px;grid-template-columns:auto 1fr auto;align-items:center;line-height:1;box-sizing:border-box;height:var(--category-name-height);justify-content:flex-start;text-transform:uppercase}.picmo__picker .picmo__emojiCategory .picmo__categoryName button{background:transparent;border:none;display:flex;align-items:center;cursor:pointer;color:var(--category-name-button-color)}.picmo__picker .picmo__emojiCategory .picmo__categoryName button:hover{opacity:1}.picmo__picker .picmo__emojiCategory .picmo__noRecents{color:var(--secondary-text-color);grid-column:1 / span var(--emojis-per-row);font-size:.9em;text-align:center;display:flex;align-items:center;justify-content:center;min-height:calc(var(--emoji-size) * var(--emoji-size-multiplier))}.picmo__picker .picmo__emojiCategory .picmo__recentEmojis[data-empty=true]{display:none}:is(.picmo__picker .picmo__emojiCategory) .picmo__recentEmojis[data-empty=false]+div{display:none}.picmo__picker .picmo__emojiContainer{display:grid;justify-content:space-between;gap:1px;padding:0 .5em;grid-template-columns:repeat(var(--emojis-per-row),calc(var(--emoji-size) * var(--emoji-size-multiplier)));grid-auto-rows:calc(var(--emoji-size) * var(--emoji-size-multiplier));align-items:center;justify-items:center}.picmo__picker.picmo__picker{--border-radius: 5px;--emoji-area-height: calc( (var(--row-count) * var(--emoji-size) * var(--emoji-size-multiplier)) + var(--category-name-height) );--content-height: var(--emoji-area-height);--emojis-per-row: 8;--row-count: 6;--emoji-preview-margin: 4px;--emoji-preview-height: calc(var(--emoji-preview-size) + 1em + 1px);--emoji-preview-height-full: calc(var(--emoji-preview-height) + var(--emoji-preview-margin));--emoji-preview-size: 2.75em;--emoji-size: 2rem;--emoji-size-multiplier: 1.3;--content-margin: 8px;--category-tabs-height:calc(1.5em + 9px);--category-tabs-offset: 8px;--category-tab-size: 1.2rem;--category-name-height: 2rem;--category-name-padding-y: 6px;--search-height: 2em;--search-margin: .5em;--search-margin-bottom: 4px;--search-height-full: calc(var(--search-height) + var(--search-margin) + var(--search-margin-bottom));--overlay-background-color: rgba(0, 0, 0, .8);--emoji-font: "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "EmojiOne Color", "Android Emoji";--ui-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;--ui-font-size: 16px;--picker-width: calc(var(--emojis-per-row) * var(--emoji-size) * var(--emoji-size-multiplier) + 2.75rem);--preview-background-color: var(--secondary-background-color);background:var(--background-color);border-radius:var(--border-radius);border:1px solid var(--border-color);font-family:var(--ui-font);font-size:var(--ui-font-size);overflow:hidden;position:relative;width:var(--picker-width);display:grid;gap:8px}.picmo__picker.picmo__picker>*{font-family:var(--ui-font)}.picmo__picker.picmo__skeleton{background:var(--background-color);border-radius:var(--border-radius);border:1px solid var(--border-color);font-family:var(--ui-font);width:var(--picker-width);color:var(--secondary-text-color)}.picmo__picker.picmo__skeleton *{box-sizing:border-box}.picmo__picker.picmo__skeleton .picmo__placeholder{background:var(--placeholder-background-color);position:relative;overflow:hidden}.picmo__picker.picmo__skeleton .picmo__placeholder:after{position:absolute;top:0;right:0;bottom:0;left:0;transform:translate(-100%);background-image:linear-gradient(90deg,rgba(255,255,255,0) 0,rgba(255,255,255,.2) 20%,rgba(255,255,255,.5) 60%,rgba(255,255,255,0) 100%);animation:shine 2s infinite;content:""}.picmo__picker.picmo__skeleton .picmo__headerSkeleton{background-color:var(--secondary-background-color);padding-top:8px;padding-bottom:8px;display:flex;flex-direction:column;overflow:hidden;gap:8px;border-bottom:1px solid var(--border-color);width:var(--picker-width)}.picmo__picker.picmo__skeleton .picmo__searchSkeleton{padding:0 8px;height:var(--search-height)}.picmo__picker.picmo__skeleton .picmo__searchSkeleton .picmo__searchInput{width:100%;height:28px;border-radius:3px}.picmo__picker.picmo__skeleton .picmo__categoryTabsSkeleton{height:var(--category-tabs-height);display:flex;flex-direction:row;align-items:center;justify-self:center;width:calc(2rem * var(--category-count, 1))}.picmo__picker.picmo__skeleton .picmo__categoryTabsSkeleton .picmo__categoryTab{width:25px;height:25px;padding:2px;border-radius:5px;margin:.25em}.picmo__picker.picmo__skeleton .picmo__contentSkeleton{height:var(--content-height);padding-right:8px;opacity:.7}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__categoryName{width:50%;height:1rem;margin:.5rem;box-sizing:border-box}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__emojiGrid{display:grid;justify-content:space-between;gap:1px;padding:0 .5em;grid-template-columns:repeat(var(--emojis-per-row),calc(var(--emoji-size) * var(--emoji-size-multiplier)));grid-auto-rows:calc(var(--emoji-size) * var(--emoji-size-multiplier));align-items:center;justify-items:center;width:var(--picker-width)}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__emojiGrid .picmo__emoji{width:var(--emoji-size);height:var(--emoji-size);border-radius:50%}.picmo__picker.picmo__skeleton .picmo__previewSkeleton{height:var(--emoji-preview-height);border-top:1px solid var(--border-color);display:grid;align-items:center;padding:.5em;gap:6px;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"emoji name" "emoji tags"}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__previewEmoji{grid-area:emoji;border-radius:50%;width:var(--emoji-preview-size);height:var(--emoji-preview-size)}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__previewName{grid-area:name;height:.8em;width:80%}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__tagList{grid-area:tags;list-style-type:none;display:flex;flex-direction:row;padding:0;margin:0}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__tagList .picmo__tag{border-radius:3px;padding:2px 8px;margin-right:.25em;height:1em;width:20%}.picmo__overlay{background:rgba(0,0,0,.75);height:100%;left:0;position:fixed;top:0;width:100%;z-index:1000}.picmo__content{position:relative;overflow:hidden;height:var(--content-height)}.picmo__content.picmo__fullHeight{height:calc(var(--content-height) + var(--category-tabs-height) + var(--category-tabs-offset));overflow-y:auto}.picmo__pluginContainer{margin:.5em;display:flex;flex-direction:row}.picmo__header{background-color:var(--secondary-background-color);padding-top:8px;padding-bottom:8px;display:grid;gap:8px;border-bottom:1px solid var(--border-color)}@media (prefers-reduced-motion: reduce){.picmo__placeholder{background:var(--placeholder-background-color);position:relative;overflow:hidden}.picmo__placeholder:after{display:none}}.picmo__picker .picmo__preview{border-top:1px solid var(--border-color);display:grid;align-items:center;gap:6px;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"emoji name" "emoji tags";height:var(--emoji-preview-height);box-sizing:border-box;padding:.5em;position:relative;background:var(--preview-background-color)}.picmo__picker .picmo__preview .picmo__previewEmoji{grid-area:emoji;font-size:var(--emoji-preview-size);font-family:var(--emoji-font);width:1.25em;display:flex;align-items:center;justify-content:center}.picmo__picker .picmo__preview .picmo__previewName{grid-area:name;color:var(--text-color);font-size:.8em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}.picmo__picker .picmo__preview .picmo__tagList{grid-area:tags;list-style-type:none;display:flex;flex-direction:row;padding:0;margin:0;font-size:.75em;overflow:hidden}.picmo__picker .picmo__preview .picmo__tag{border-radius:3px;background:var(--tag-background-color);color:var(--text-color);padding:2px 8px;margin-right:.25em;white-space:nowrap}.picmo__picker .picmo__preview .picmo__tag:last-child{margin-right:0}.picmo__picker .picmo__searchContainer{display:flex;height:var(--search-height);box-sizing:border-box;padding:0 8px;position:relative}.picmo__picker .picmo__searchContainer .picmo__searchField{background:var(--search-background-color);border-radius:3px;border:none;box-sizing:border-box;color:var(--text-color);font-size:.9em;outline:none;padding:.5em 2.25em .5em .5em;width:100%}.picmo__picker .picmo__searchContainer .picmo__searchField:focus{background:var(--search-focus-background-color)}.picmo__picker .picmo__searchContainer .picmo__searchField::placeholder{color:var(--search-placeholder-color)}.picmo__picker .picmo__searchContainer .picmo__searchAccessory{color:var(--search-icon-color);height:100%;position:absolute;right:1em;top:0;width:1.25rem;display:flex;align-items:center}.picmo__picker .picmo__searchContainer .picmo__searchAccessory svg{fill:var(--search-icon-color)}.picmo__picker .picmo__searchContainer .picmo__clearButton{border:0;color:var(--search-icon-color);background:transparent;cursor:pointer}.picmo__picker .picmo__searchContainer .picmo__clearSearchButton{cursor:pointer;border:none;background:transparent;color:var(--search-icon-color);font-size:1em;width:100%;height:100%;display:flex;align-items:center;padding:0}.picmo__picker .picmo__searchContainer .picmo__notFound [data-icon]{fill:#f3e265}.picmo__picker .picmo__variantOverlay{background:var(--overlay-background-color);border-radius:5px;display:flex;flex-direction:column;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:1}.picmo__picker .picmo__variantOverlay .picmo__variantPopup{background:var(--variant-popup-background-color);border-radius:5px;margin:.5em;padding:.5em;text-align:center;user-select:none;display:flex;align-items:center;justify-content:center}.picmo__customEmoji{width:1em;height:1em}@keyframes shine{to{transform:translate(100%)}}.picmo__picker .picmo__imagePlaceholder{width:2rem;height:2rem;border-radius:50%}.picmo__placeholder{background:#DDDBDD;position:relative}.picmo__placeholder:after{position:absolute;top:0;right:0;bottom:0;left:0;transform:translate(-100%);background-image:linear-gradient(90deg,rgba(255,255,255,0) 0,rgba(255,255,255,.2) 20%,rgba(255,255,255,.5) 60%,rgba(255,255,255,0) 100%);animation:shine 2s infinite;content:""} `;function Uie(t){return eL(t.locale,t.dataStore,t.messages,t.emojiData)}var zie=0,Sm;function jie(){return`picmo-${Date.now()}-${zie++}`}var qie=B2();function rL(t){qie(Mie);let e=W2(t),i=((e==null?void 0:e.custom)||[]).map(s=>Ce(H({},s),{custom:!0,tags:["custom",...s.tags||[]]})),r=new k2;Sm||(Sm=Uie(e));let n=new U2(e.i18n);Sm.then(s=>{r.emit("data:ready",s)}).catch(s=>{r.emit("error",s)});let o=new M2({events:r,i18n:n,customEmojis:i,renderer:e.renderer,options:e,emojiData:Sm,pickerId:jie()}).create(N2);return o.renderSync(),o}function ba(t){return t.split("-")[0]}function ql(t){return t.split("-")[1]}function qm(t){return["top","bottom"].includes(ba(t))?"x":"y"}function dL(t){return t==="y"?"height":"width"}function nL(t,e,i){let{reference:r,floating:n}=t,o=r.x+r.width/2-n.width/2,s=r.y+r.height/2-n.height/2,a=qm(e),l=dL(a),c=r[l]/2-n[l]/2,u=ba(e),f=a==="x",d;switch(u){case"top":d={x:o,y:r.y-n.height};break;case"bottom":d={x:o,y:r.y+r.height};break;case"right":d={x:r.x+r.width,y:s};break;case"left":d={x:r.x-n.width,y:s};break;default:d={x:r.x,y:r.y}}switch(ql(e)){case"start":d[a]-=c*(i&&f?-1:1);break;case"end":d[a]+=c*(i&&f?-1:1);break}return d}var Wie=async(t,e,i)=>{let{placement:r="bottom",strategy:n="absolute",middleware:o=[],platform:s}=i,a=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:t,floating:e,strategy:n}),{x:c,y:u}=nL(l,r,a),f=r,d={},p=0;for(let g=0;gFie[e])}function pL(t,e,i){i===void 0&&(i=!1);let r=ql(t),n=qm(t),o=dL(n),s=n==="x"?r===(i?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=Um(s)),{main:s,cross:Um(s)}}var Hie={start:"end",end:"start"};function Z2(t){return t.replace(/start|end/g,e=>Hie[e])}var Gie=["top","right","bottom","left"],Kie=Gie.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);function Jie(t,e,i){return(t?[...i.filter(r=>ql(r)===t),...i.filter(r=>ql(r)!==t)]:i.filter(r=>ba(r)===r)).filter(r=>t?ql(r)===t||(e?Z2(r)!==r:!1):!0)}var ere=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var i,r,n,o,s;let{x:a,y:l,rects:c,middlewareData:u,placement:f,platform:d,elements:p}=e,he=t,{alignment:g=null,allowedPlacements:x=Kie,autoAlignment:v=!0}=he,S=pi(he,["alignment","allowedPlacements","autoAlignment"]),T=Jie(g,v,x),$=await F2(e,S),I=(i=(r=u.autoPlacement)==null?void 0:r.index)!=null?i:0,_=T[I];if(_==null)return{};let{main:A,cross:q}=pL(_,c,await(d.isRTL==null?void 0:d.isRTL(p.floating)));if(f!==_)return{x:a,y:l,reset:{placement:T[0]}};let le=[$[ba(_)],$[A],$[q]],F=[...(n=(o=u.autoPlacement)==null?void 0:o.overflows)!=null?n:[],{placement:_,overflows:le}],U=T[I+1];if(U)return{data:{index:I+1,overflows:F},reset:{placement:U}};let ie=F.slice().sort((me,ve)=>me.overflows[0]-ve.overflows[0]),ue=(s=ie.find(me=>{let{overflows:ve}=me;return ve.every(j=>j<=0)}))==null?void 0:s.placement,re=ue!=null?ue:ie[0].placement;return re!==f?{data:{index:I+1,overflows:F},reset:{placement:re}}:{}}}};function tre(t){let e=Um(t);return[Z2(t),e,Z2(e)]}var ire=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i;let{placement:r,middlewareData:n,rects:o,initialPlacement:s,platform:a,elements:l}=e,le=t,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:d="bestFit",flipAlignment:p=!0}=le,g=pi(le,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","flipAlignment"]),x=ba(r),v=f||(x===s||!p?[Um(s)]:tre(s)),S=[s,...v],T=await F2(e,g),$=[],I=((i=n.flip)==null?void 0:i.overflows)||[];if(c&&$.push(T[x]),u){let{main:F,cross:U}=pL(r,o,await(a.isRTL==null?void 0:a.isRTL(l.floating)));$.push(T[F],T[U])}if(I=[...I,{placement:r,overflows:$}],!$.every(F=>F<=0)){var _,A;let F=((_=(A=n.flip)==null?void 0:A.index)!=null?_:0)+1,U=S[F];if(U)return{data:{index:F,overflows:I},reset:{placement:U}};let ie="bottom";switch(d){case"bestFit":{var q;let ue=(q=I.map(re=>[re,re.overflows.filter(he=>he>0).reduce((he,me)=>he+me,0)]).sort((re,he)=>re[1]-he[1])[0])==null?void 0:q[0].placement;ue&&(ie=ue);break}case"initialPlacement":ie=s;break}if(r!==ie)return{reset:{placement:ie}}}return{}}}};async function rre(t,e){let{placement:i,platform:r,elements:n}=t,o=await(r.isRTL==null?void 0:r.isRTL(n.floating)),s=ba(i),a=ql(i),l=qm(i)==="x",c=["left","top"].includes(s)?-1:1,u=o&&l?-1:1,f=typeof e=="function"?e(t):e,{mainAxis:d,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:H({mainAxis:0,crossAxis:0,alignmentAxis:null},f);return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:d*c}:{x:d*c,y:p*u}}var sL=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:i,y:r}=e,n=await rre(e,t);return{x:i+n.x,y:r+n.y,data:n}}}};function nre(t){return t==="x"?"y":"x"}var aL=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:r,placement:n}=e,v=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:a={fn:S=>{let{x:T,y:$}=S;return{x:T,y:$}}}}=v,l=pi(v,["mainAxis","crossAxis","limiter"]),c={x:i,y:r},u=await F2(e,l),f=qm(ba(n)),d=nre(f),p=c[f],g=c[d];if(o){let S=f==="y"?"top":"left",T=f==="y"?"bottom":"right",$=p+u[S],I=p-u[T];p=oL($,p,I)}if(s){let S=d==="y"?"top":"left",T=d==="y"?"bottom":"right",$=g+u[S],I=g-u[T];g=oL($,g,I)}let x=a.fn(Ce(H({},e),{[f]:p,[d]:g}));return Ce(H({},x),{data:{x:x.x-i,y:x.y-r}})}}};function OL(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function lo(t){if(t==null)return window;if(!OL(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function xn(t){return lo(t).getComputedStyle(t)}function so(t){return OL(t)?"":t?(t.nodeName||"").toLowerCase():""}function mL(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function vn(t){return t instanceof lo(t).HTMLElement}function as(t){return t instanceof lo(t).Element}function ore(t){return t instanceof lo(t).Node}function Wl(t){if(typeof ShadowRoot>"u")return!1;let e=lo(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Wm(t){let{overflow:e,overflowX:i,overflowY:r}=xn(t);return/auto|scroll|overlay|hidden/.test(e+r+i)}function sre(t){return["table","td","th"].includes(so(t))}function gL(t){let e=/firefox/i.test(mL()),i=xn(t);return i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].includes(i.willChange)||e&&i.willChange==="filter"||e&&(i.filter?i.filter!=="none":!1)}function bL(){return!/^((?!chrome|android).)*safari/i.test(mL())}var lL=Math.min,th=Math.max,zm=Math.round;function ao(t,e,i){var r,n,o,s;e===void 0&&(e=!1),i===void 0&&(i=!1);let a=t.getBoundingClientRect(),l=1,c=1;e&&vn(t)&&(l=t.offsetWidth>0&&zm(a.width)/t.offsetWidth||1,c=t.offsetHeight>0&&zm(a.height)/t.offsetHeight||1);let u=as(t)?lo(t):window,f=!bL()&&i,d=(a.left+(f&&(r=(n=u.visualViewport)==null?void 0:n.offsetLeft)!=null?r:0))/l,p=(a.top+(f&&(o=(s=u.visualViewport)==null?void 0:s.offsetTop)!=null?o:0))/c,g=a.width/l,x=a.height/c;return{width:g,height:x,top:p,right:d+g,bottom:p+x,left:d,x:d,y:p}}function ls(t){return((ore(t)?t.ownerDocument:t.document)||window.document).documentElement}function Bm(t){return as(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function yL(t){return ao(ls(t)).left+Bm(t).scrollLeft}function are(t){let e=ao(t);return zm(e.width)!==t.offsetWidth||zm(e.height)!==t.offsetHeight}function lre(t,e,i){let r=vn(e),n=ls(e),o=ao(t,r&&are(e),i==="fixed"),s={scrollLeft:0,scrollTop:0},a={x:0,y:0};if(r||!r&&i!=="fixed")if((so(e)!=="body"||Wm(n))&&(s=Bm(e)),vn(e)){let l=ao(e,!0);a.x=l.x+e.clientLeft,a.y=l.y+e.clientTop}else n&&(a.x=yL(n));return{x:o.left+s.scrollLeft-a.x,y:o.top+s.scrollTop-a.y,width:o.width,height:o.height}}function xL(t){return so(t)==="html"?t:t.assignedSlot||t.parentNode||(Wl(t)?t.host:null)||ls(t)}function cL(t){return!vn(t)||xn(t).position==="fixed"?null:cre(t)}function cre(t){let{offsetParent:e}=t,i=t,r=!1;for(;i&&i!==e;){let{assignedSlot:n}=i;if(n){let o=n.offsetParent;if(xn(n).display==="contents"){let s=n.hasAttribute("style"),a=n.style.display;n.style.display=xn(i).display,o=n.offsetParent,n.style.display=a,s||n.removeAttribute("style")}i=n,e!==o&&(e=o,r=!0)}else if(Wl(i)&&i.host&&r)break;i=Wl(i)&&i.host||i.parentNode}return e}function ure(t){let e=xL(t);for(Wl(e)&&(e=e.host);vn(e)&&!["html","body"].includes(so(e));){if(gL(e))return e;{let i=e.parentNode;e=Wl(i)?i.host:i}}return null}function V2(t){let e=lo(t),i=cL(t);for(;i&&sre(i)&&xn(i).position==="static";)i=cL(i);return i&&(so(i)==="html"||so(i)==="body"&&xn(i).position==="static"&&!gL(i))?e:i||ure(t)||e}function uL(t){if(vn(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=ao(t);return{width:e.width,height:e.height}}function fre(t){let{rect:e,offsetParent:i,strategy:r}=t,n=vn(i),o=ls(i);if(i===o)return e;let s={scrollLeft:0,scrollTop:0},a={x:0,y:0};if((n||!n&&r!=="fixed")&&((so(i)!=="body"||Wm(o))&&(s=Bm(i)),vn(i))){let l=ao(i,!0);a.x=l.x+i.clientLeft,a.y=l.y+i.clientTop}return Ce(H({},e),{x:e.x-s.scrollLeft+a.x,y:e.y-s.scrollTop+a.y})}function hre(t,e){let i=lo(t),r=ls(t),n=i.visualViewport,o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(n){o=n.width,s=n.height;let c=bL();(c||!c&&e==="fixed")&&(a=n.offsetLeft,l=n.offsetTop)}return{width:o,height:s,x:a,y:l}}function dre(t){var e;let i=ls(t),r=Bm(t),n=(e=t.ownerDocument)==null?void 0:e.body,o=th(i.scrollWidth,i.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),s=th(i.scrollHeight,i.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),a=-r.scrollLeft+yL(t),l=-r.scrollTop;return xn(n||i).direction==="rtl"&&(a+=th(i.clientWidth,n?n.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}function vL(t){let e=xL(t);return["html","body","#document"].includes(so(e))?t.ownerDocument.body:vn(e)&&Wm(e)?e:vL(e)}function jm(t,e){var i;e===void 0&&(e=[]);let r=vL(t),n=r===((i=t.ownerDocument)==null?void 0:i.body),o=lo(r),s=n?[o].concat(o.visualViewport||[],Wm(r)?r:[]):r,a=e.concat(s);return n?a:a.concat(jm(s))}function pre(t,e){let i=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(i&&Wl(i)){let r=e;do{if(r&&t===r)return!0;r=r.parentNode||r.host}while(r)}return!1}function Ore(t,e){let i=ao(t,!1,e==="fixed"),r=i.top+t.clientTop,n=i.left+t.clientLeft;return{top:r,left:n,x:n,y:r,right:n+t.clientWidth,bottom:r+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}function fL(t,e,i){return e==="viewport"?Mm(hre(t,i)):as(e)?Ore(e,i):Mm(dre(ls(t)))}function mre(t){let e=jm(t),i=["absolute","fixed"].includes(xn(t).position)&&vn(t)?V2(t):t;return as(i)?e.filter(r=>as(r)&&pre(r,i)&&so(r)!=="body"):[]}function gre(t){let{element:e,boundary:i,rootBoundary:r,strategy:n}=t,o=[...i==="clippingAncestors"?mre(e):[].concat(i),r],s=o[0],a=o.reduce((l,c)=>{let u=fL(e,c,n);return l.top=th(u.top,l.top),l.right=lL(u.right,l.right),l.bottom=lL(u.bottom,l.bottom),l.left=th(u.left,l.left),l},fL(e,s,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}var bre={getClippingRect:gre,convertOffsetParentRelativeRectToViewportRelativeRect:fre,isElement:as,getDimensions:uL,getOffsetParent:V2,getDocumentElement:ls,getElementRects:t=>{let{reference:e,floating:i,strategy:r}=t;return{reference:lre(e,V2(i),r),floating:Ce(H({},uL(i)),{x:0,y:0})}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>xn(t).direction==="rtl"};function yre(t,e,i,r){r===void 0&&(r={});let{ancestorScroll:n=!0,ancestorResize:o=!0,elementResize:s=!0,animationFrame:a=!1}=r,l=n&&!a,c=o&&!a,u=l||c?[...as(t)?jm(t):[],...jm(e)]:[];u.forEach(x=>{l&&x.addEventListener("scroll",i,{passive:!0}),c&&x.addEventListener("resize",i)});let f=null;if(s){let x=!0;f=new ResizeObserver(()=>{x||i(),x=!1}),as(t)&&!a&&f.observe(t),f.observe(e)}let d,p=a?ao(t):null;a&&g();function g(){let x=ao(t);p&&(x.x!==p.x||x.y!==p.y||x.width!==p.width||x.height!==p.height)&&i(),p=x,d=requestAnimationFrame(g)}return i(),()=>{var x;u.forEach(v=>{l&&v.removeEventListener("scroll",i),c&&v.removeEventListener("resize",i)}),(x=f)==null||x.disconnect(),f=null,a&&cancelAnimationFrame(d)}}var xre=(t,e,i)=>Wie(t,e,H({platform:bre},i));async function vre(t,e,i,r){if(!r)throw new Error("Must provide a positioning option");return await(typeof r=="string"?wre(t,e,i,r):kre(e,r))}async function wre(t,e,i,r){if(!i)throw new Error("Reference element is required for relative positioning");let n;return r==="auto"?n={middleware:[ere(),aL(),sL({mainAxis:5,crossAxis:12})]}:n={placement:r,middleware:[ire(),aL(),sL(5)]},yre(i,e,async()=>{if((!i.isConnected||!i.offsetParent)&&Sre(t))return;let{x:o,y:s}=await xre(i,e,n);Object.assign(e.style,{position:"absolute",left:`${o}px`,top:`${s}px`})})}function kre(t,e){return t.style.position="fixed",Object.entries(e).forEach(([i,r])=>{t.style[i]=r}),()=>{}}function Sre(t){switch(t.options.onPositionLost){case"close":return t.close(),!0;case"destroy":return t.destroy(),!0;case"hold":return!0}}var Tre={hideOnClickOutside:!0,hideOnEmojiSelect:!0,hideOnEscape:!0,position:"auto",showCloseButton:!0,onPositionLost:"none"};function Ere(t={}){return H(Ce(H({},Tre),{rootElement:document.body}),t)}var Cre='',hL=hi("popupContainer","closeButton"),Y2=class{constructor(e,i){this.isOpen=!1,this.externalEvents=new ma,this.options=H(H({},Ere(i)),W2(e)),this.popupEl=document.createElement("div"),this.popupEl.classList.add(hL.popupContainer),this.popupEl.classList.add(this.options.theme),i.className&&this.popupEl.classList.add(i.className),this.options.showCloseButton&&(this.closeButton=document.createElement("button"),this.closeButton.type="button",this.closeButton.classList.add(hL.closeButton),this.closeButton.innerHTML=Cre,this.closeButton.addEventListener("click",()=>{this.close()}),this.popupEl.appendChild(this.closeButton));let r=document.createElement("div");this.popupEl.appendChild(r),this.picker=rL(Ce(H({},this.options),{rootElement:r})),this.focusTrap=new Kf,this.picker.addEventListener("data:ready",()=>{this.focusTrap.activate(this.picker.el),this.picker.setInitialFocus()}),this.options.hideOnEmojiSelect&&this.picker.addEventListener("emoji:select",()=>{var n;this.close(),(n=this.triggerElement)==null||n.focus()}),this.options.hideOnClickOutside&&(this.onDocumentClick=this.onDocumentClick.bind(this),document.addEventListener("click",this.onDocumentClick)),this.options.hideOnEscape&&(this.handleKeydown=this.handleKeydown.bind(this),this.popupEl.addEventListener("keydown",this.handleKeydown)),this.referenceElement=this.options.referenceElement,this.triggerElement=this.options.triggerElement}addEventListener(e,i){this.externalEvents.on(e,i),this.picker.addEventListener(e,i)}removeEventListener(e,i){this.externalEvents.off(e,i),this.picker.removeEventListener(e,i)}handleKeydown(e){var i;e.key==="Escape"&&(this.close(),(i=this.triggerElement)==null||i.focus())}async destroy(){this.isOpen&&await this.close(),document.removeEventListener("click",this.onDocumentClick),this.picker.destroy(),this.externalEvents.removeAll()}toggle(e){return this.isOpen?this.close():this.open(e)}async open({triggerElement:e,referenceElement:i}={}){this.isOpen||(e&&(this.triggerElement=e),i&&(this.referenceElement=i),await this.initiateOpenStateChange(!0),this.popupEl.style.opacity="0",this.options.rootElement.appendChild(this.popupEl),await this.setPosition(),this.picker.reset(!1),await this.animatePopup(!0),await this.animateCloseButton(!0),this.picker.setInitialFocus(),this.externalEvents.emit("picker:open"))}async close(){var e;!this.isOpen||(await this.initiateOpenStateChange(!1),await this.animateCloseButton(!1),await this.animatePopup(!1),this.popupEl.remove(),this.picker.reset(),(e=this.positionCleanup)==null||e.call(this),this.focusTrap.deactivate(),this.externalEvents.emit("picker:close"))}getRunningAnimations(){return this.picker.el.getAnimations().filter(e=>e.playState==="running")}async setPosition(){var e;(e=this.positionCleanup)==null||e.call(this),this.positionCleanup=await vre(this,this.popupEl,this.referenceElement,this.options.position)}awaitPendingAnimations(){return Promise.all(this.getRunningAnimations().map(e=>e.finished))}onDocumentClick(e){var i;let r=e.target,n=(i=this.triggerElement)==null?void 0:i.contains(r);this.isOpen&&!this.picker.isPickerClick(e)&&!n&&this.close()}animatePopup(e){return pa(this.popupEl,{opacity:[0,1],transform:["scale(0.9)","scale(1)"]},{duration:150,id:e?"show-picker":"hide-picker",easing:"ease-in-out",direction:e?"normal":"reverse",fill:"both"},this.options)}animateCloseButton(e){if(this.closeButton)return pa(this.closeButton,{opacity:[0,1]},{duration:25,id:e?"show-close":"hide-close",easing:"ease-in-out",direction:e?"normal":"reverse",fill:"both"},this.options)}async initiateOpenStateChange(e){this.isOpen=e,await this.awaitPendingAnimations()}},Pre=`.picmo__popupContainer{display:flex;flex-direction:column;position:absolute}.picmo__popupContainer .picmo__closeButton{position:absolute;opacity:0;background:transparent;border:none;z-index:1;right:0;top:0;cursor:pointer;padding:4px;align-self:flex-end;transform:translate(50%,-50%);background:#999999;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center;border-radius:50%}.picmo__popupContainer .picmo__closeButton:hover{background:var(--accent-color)}.picmo__popupContainer .picmo__closeButton svg{fill:#fff;width:1.25rem;height:1.25rem} `,_re=B2();function wL(t,e){return _re(Pre),new Y2(H({autoFocus:"auto"},t),e)}var Qre={mounted(){let t=this.el.querySelector("[data-emoji-button]"),e=this.el.querySelector("[data-emoji-preview]"),i=this.el.querySelector("[data-emoji-input]"),r=wL({showPreview:!1},{triggerElement:t,referenceElement:t,position:"bottom"});r.addEventListener("emoji:select",({emoji:n})=>{e.innerHTML=n,i.value=n}),t.addEventListener("click",n=>{r.toggle()})}},kL=Qre;var Are={mounted(){this.focus()},updated(){this.el!==document.activeElement&&this.focus()},focus(){Jo(document.activeElement)||(this.el.focus(),this.el.selectionStart=this.el.selectionEnd=this.el.value.length,this.el.scrollLeft=this.el.scrollWidth)}},SL=Are;var $re={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.initializeHeadingEl(),this.navigationSubscription=ti.subscribe("navigation",this.handleNavigationEvent.bind(this))},updated(){this.props=this.getProps(),this.initializeHeadingEl()},destroyed(){this.navigationSubscription.destroy()},getProps(){return ht(this.el,["id","on-value-change","metadata"])},initializeHeadingEl(){let t=this.el.querySelector("[data-el-heading]");t!==this.headingEl&&(this.headingEl=t,this.headingEl.addEventListener("paste",e=>{e.preventDefault();let i=e.clipboardData.getData("text/plain").replace(` -`," ");document.execCommand("insertText",!1,i)}),this.headingEl.addEventListener("keydown",e=>{e.key==="Enter"&&e.preventDefault()}),this.headingEl.addEventListener("blur",e=>{setTimeout(()=>{this.isFocused&&this.insertMode&&(this.headingEl.focus(),TL(this.headingEl))},0)}))},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleElementFocused(t,e){this.props.id===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&na(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.el.setAttribute("phx-update","ignore"),this.headingEl.setAttribute("contenteditable",""),this.headingEl.focus(),TL(this.headingEl)):this.insertMode&&!t&&(this.insertMode=t,this.headingEl.removeAttribute("contenteditable"),this.el.removeAttribute("phx-update"),this.pushEvent(this.props.onValueChange,{value:this.headingEl.textContent.trim(),metadata:this.props.metadata}))}};function TL(t){let e=document.createRange();e.selectNodeContents(t),e.collapse(!1);let i=window.getSelection();i.removeAllRanges(),i.addRange(e)}var EL=$re;var Xre={mounted(){this.props=this.getProps(),this.sourceEl=to(this.el,"[data-source]"),this.targetEl=to(this.el,"[data-target]"),this.updateDOM()},updated(){this.props=this.getProps(),this.updateDOM()},getProps(){return ht(this.el,["language"])},updateDOM(){let t=this.sourceEl.innerText,e=MO(t,this.props.language);this.targetEl.innerHTML=e,this.el.setAttribute("data-highlighted","")}},CL=Xre;var H2=["bg-yellow-100","border-yellow-300"],Rre={mounted(){this.props=this.getProps(),this.inputEl=this.el.querySelector("[data-input]"),this.previewEl=this.el.querySelector("[data-preview]"),this.initialPreviewContentEl=this.previewEl.firstElementChild,this.cameraPreviewEl=this.el.querySelector("[data-camera-preview]"),this.cameraListEl=this.el.querySelector("[data-camera-list]"),this.cameraItemTemplateEl=this.cameraListEl.firstElementChild,this.cameraItemTemplateEl.remove(),this.uploadButton=this.el.querySelector("[data-btn-upload]"),this.openCameraButton=this.el.querySelector("[data-btn-open-camera]"),this.captureCameraButton=this.el.querySelector("[data-btn-capture-camera]"),this.cancelButton=this.el.querySelector("[data-btn-cancel]"),this.cameraListPopulated=!1,this.cameraVideoEl=null,this.cameraStream=null,this.updateImagePreview(),this.uploadButton.addEventListener("click",t=>{this.inputEl.click()}),this.inputEl.addEventListener("change",t=>{let[e]=t.target.files;e&&this.loadFile(e)}),this.el.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}),this.el.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault();let[e]=t.dataTransfer.files;e&&this.loadFile(e),this.closeCameraView()}),this.el.addEventListener("dragenter",t=>{this.el.classList.add(...H2)}),this.el.addEventListener("dragleave",t=>{this.el.contains(t.relatedTarget)||this.el.classList.remove(...H2)}),this.el.addEventListener("drop",t=>{this.el.classList.remove(...H2)}),this.openCameraButton.addEventListener("click",t=>{this.cameraListPopulated||(this.renderCameraList(),this.cameraListPopulated=!0)}),this.cameraListEl.addEventListener("click",t=>{let e=t.target.closest("[data-camera-id]");if(e){let i=e.dataset.cameraId;this.openCameraView(i)}}),this.captureCameraButton.addEventListener("click",t=>{let e=this.toCanvas(this.cameraVideoEl,this.cameraVideoEl.videoWidth,this.cameraVideoEl.videoHeight);this.pushImage(e),this.closeCameraView()}),this.cancelButton.addEventListener("click",t=>{this.closeCameraView()})},updated(){this.props=this.getProps(),this.updateImagePreview()},getProps(){return ht(this.el,["id","phx-target","height","width","format","fit","image-url","value-height","value-width"])},updateImagePreview(){this.props.imageUrl?Dre(this.props.imageUrl,this.props.valueHeight,this.props.valueWidth,this.props.format).then(t=>{this.setPreview(t)}):this.setPreview(this.initialPreviewContentEl)},loadFile(t){let e=new FileReader;e.onload=i=>{let r=document.createElement("img");r.addEventListener("load",n=>{let o=this.toCanvas(r,r.width,r.height);this.pushImage(o)}),r.src=i.target.result},e.readAsDataURL(t)},openCameraView(t){this.cameraPreviewEl.classList.remove("hidden"),this.cancelButton.classList.remove("hidden"),this.captureCameraButton.classList.remove("hidden"),this.previewEl.classList.add("hidden"),this.openCameraButton.classList.add("hidden"),this.uploadButton.classList.add("hidden"),navigator.mediaDevices.getUserMedia(this.cameraConstraints(t)).then(e=>{this.cameraStream=e,this.cameraVideoEl=document.createElement("video"),this.cameraVideoEl.autoplay=!0,this.cameraVideoEl.playsinline=!0,this.cameraVideoEl.muted=!0,this.cameraVideoEl.srcObject=e,this.setCameraPreview(this.cameraVideoEl)}).catch(()=>{})},cameraConstraints(t){return t==="system_default"?{audio:!1,video:!0}:{audio:!1,video:{deviceId:t}}},renderCameraList(){navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then(t=>navigator.mediaDevices.enumerateDevices().then(e=>(this.stopMediaStream(t),e))).then(t=>{let e=t.filter(i=>i.kind==="videoinput").map(i=>({deviceId:i.deviceId,label:i.label}));[{deviceId:"system_default",label:"System Default"},...e].forEach(({deviceId:i,label:r})=>{let n=this.cameraItemTemplateEl.cloneNode(!0);n.querySelector("[data-camera-id]").setAttribute("data-camera-id",i),n.querySelector("[data-label]").innerHTML=r,this.cameraListEl.appendChild(n)})}).catch(t=>{console.error(t),this.openCameraButton.disabled=!0})},closeCameraView(){return this.cameraStream!==null&&(this.stopMediaStream(this.cameraStream),this.cameraStream=null),this.cameraVideoEl!==null&&(this.cameraVideoEl.remove(),this.cameraVideoEl=null),this.cameraPreviewEl.classList.add("hidden"),this.cancelButton.classList.add("hidden"),this.captureCameraButton.classList.add("hidden"),this.previewEl.classList.remove("hidden"),this.openCameraButton.classList.remove("hidden"),this.uploadButton.classList.remove("hidden"),!0},stopMediaStream(t){t.getTracks().forEach(e=>{e.stop()})},pushImage(t){Lre(t,this.props.format).then(e=>{let i={height:t.height,width:t.width},r=new Blob([e]);r.meta=()=>i,this.uploadTo(this.props.phxTarget,"file",[r])})},toCanvas(t,e,i){let{width:r,height:n}=this.props,o=document.createElement("canvas"),s=o.getContext("2d");if(r===null&&n===null||r===e&&n===i)o.width=e,o.height=i,o.getContext("2d").drawImage(t,0,0,e,i,0,0,e,i);else if(this.props.fit==="contain"){let a=r/e,l=n/i,c=Math.min(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=u,o.height=f,s.drawImage(t,0,0,e,i,0,0,u,f)}else if(this.props.fit==="crop"){let a=r/e,l=n/i,c=Math.max(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=r,o.height=n,s.drawImage(t,Math.round((u-r)/c/2),Math.round((f-n)/c/2),e-Math.round((u-r)/c),i-Math.round((f-n)/c),0,0,r,n)}else if(this.props.fit==="pad"){let a=r/e,l=n/i,c=Math.min(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=r,o.height=n,s.fillStyle="black",s.fillRect(0,0,o.width,o.height),s.drawImage(t,0,0,e,i,Math.round((r-u)/2),Math.round((n-f)/2),u,f)}else o.width=r,o.height=n,s.drawImage(t,0,0,e,i,0,0,r,n);return o},setPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.previewEl.replaceChildren(t)},setCameraPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.cameraPreviewEl.replaceChildren(t)}};function Lre(t,e){if(e==="png"||e==="jpeg")return new Promise((i,r)=>{t.toBlob(n=>{n.arrayBuffer().then(o=>{i(o)})},`image/${e}`)});if(e==="rgb"){let i=t.getContext("2d").getImageData(0,0,t.width,t.height),r=Ire(i);return Promise.resolve(r)}throw new Error(`Unexpected format: ${e}`)}function Ire(t){let e=t.width*t.height,i=new Uint8ClampedArray(e*3);for(let r=0;rn.arrayBuffer()).then(n=>{let o=document.createElement("canvas");o.height=e,o.width=i;let s=Nre(n,i,e);return o.getContext("2d").putImageData(s,0,0),o});throw new Error(`Unexpected format: ${r}`)}function Nre(t,e,i){let r=e*i,n=new Uint8Array(t),o=new Uint8ClampedArray(r*4);for(let s=0;s{t.sandbox="allow-scripts allow-same-origin allow-downloads allow-forms allow-modals allow-popups allow-top-navigation",t.allow="accelerometer; ambient-light-sensor; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; microphone; midi; usb; xr-spatial-tracking; clipboard-read; clipboard-write; bluetooth; serial",t.src=r})}function jre(t,e){let i=window.location.protocol;return e?e.replace(/^https?:/,i):i==="https:"?"https://livebookusercontent.com/iframe/v5.html":`http://${window.location.hostname}:${t}/iframe/v5.html`}var J2=null;function qre(t){return J2||(J2=fetch(t).then(e=>e.text()).then(e=>{if(TX(e)!==XL)throw new Error(`The iframe loaded from ${t} doesn't have the expected checksum ${XL}`)})),J2}var Wre={mounted(){this.props=this.getProps(),this.id=wX(),this.childToken=kX(),this.childReadyPromise=null,this.childReady=!1,this.initReceived=!1,this.syncCallbackQueue=[],this.pongCallbackQueue=[],this.initTimeout=setTimeout(()=>this.handleInitTimeout(),2e3),this.channel=QL(this.props.sessionToken),this.iframeActions=this.createIframe(),this.childReadyPromise=new Promise((n,o)=>{this._handleWindowMessage=s=>{s.source===this.iframe.contentWindow&&this.handleChildMessage(s.data,n)},window.addEventListener("message",this._handleWindowMessage)}),this.hiddenInput=document.createElement("input"),this.hiddenInput.style.display="none",this.el.appendChild(this.hiddenInput),this.iframeActions.visibilityPromise.then(()=>{this.loadIframe()});let t=this.channel.on(`init:${this.props.ref}:${this.id}`,n=>{let[,o]=K2(n);this.handleServerInit(o)}),e=this.channel.on(`event:${this.props.ref}`,n=>{let[[o],s]=K2(n);this.handleServerEvent(o,s)}),i=this.channel.on(`error:${this.props.ref}`,({message:n,init:o})=>{this.handleServerError(n,o)}),r=this.channel.on(`pong:${this.props.ref}`,()=>{this.handleServerPong()});this.unsubscribeFromChannelEvents=()=>{this.channel.off(`init:${this.props.ref}:${this.id}`,t),this.channel.off(`event:${this.props.ref}`,e),this.channel.off(`error:${this.props.ref}`,i),this.channel.off(`pong:${this.props.ref}`,r)},this.subscriptions=[ti.subscribe(`js_views:${this.props.ref}`,this.handleJSViewEvent.bind(this)),ti.subscribe("navigation",this.handleNavigationEvent.bind(this))],this.channel.push("connect",{connect_token:this.props.connectToken,ref:this.props.ref,id:this.id},3e4)},updated(){this.props=this.getProps(this)},disconnected(){this.el.removeAttribute("id")},destroyed(){window.removeEventListener("message",this._handleWindowMessage),this.iframeActions.remove(),this.unsubscribeFromChannelEvents(),this.channel.push("disconnect",{ref:this.props.ref}),this.subscriptions.forEach(t=>t.destroy())},getProps(){return ht(this.el,["ref","assets-base-path","assets-cdn-url","js-path","session-token","connect-token","iframe-port","iframe-url","timeout-message"])},createIframe(){this.iframePlaceholder=document.createElement("div"),this.el.appendChild(this.iframePlaceholder),this.iframe=document.createElement("iframe"),this.iframe.className="w-full h-0 absolute z-[1]";let t=document.querySelector("[data-el-notebook]"),e=t.querySelector("[data-el-notebook-content]"),i=new ResizeObserver(l=>{this.repositionIframe()});i.observe(e),i.observe(t);let r=bn(this.iframePlaceholder),n=new ResizeObserver(l=>{let c=bn(this.iframePlaceholder);r!==c&&(r=c,this.repositionIframe())});n.observe(this.iframePlaceholder);let o=ti.subscribe("js_views",l=>{l.type==="reposition"&&this.repositionIframe()});this.iframe.addEventListener("mouseenter",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}))}),this.iframe.addEventListener("mouseleave",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))});let s=RO(this.iframePlaceholder,{root:t,proximity:2e3});this.iframe.toggleAttribute("data-js-focused",!!this.el.closest("[data-js-focused]"));let a=()=>{i.disconnect(),n.disconnect(),o.destroy(),s.cancel(),this.iframe.remove(),this.iframePlaceholder.remove()};return{visibilityPromise:s.promise,remove:a}},repositionIframe(){let{iframe:t,iframePlaceholder:e}=this,i=document.querySelector("[data-el-notebook]");if(bn(e))t.classList.add("hidden");else{t.classList.remove("hidden");let r=i.getBoundingClientRect(),n=e.getBoundingClientRect(),o=n.top-r.top+i.scrollTop;t.style.top=`${o}px`;let s=n.left-r.left+i.scrollLeft;t.style.left=`${s}px`,t.style.height=`${n.height}px`,t.style.width=`${n.width}px`}},loadIframe(){let t=document.querySelector("[data-el-js-view-iframes]");RL(this.iframe,this.props.iframePort,this.props.iframeUrl).then(()=>{t.appendChild(this.iframe)})},handleChildMessage(t,e){if(t.type==="ready"&&!this.childReady)this.getAssetsBaseUrl().then(i=>{this.postMessage({type:"readyReply",token:this.childToken,baseUrl:i,jsPath:this.props.jsPath}),this.childReady=!0,e()});else{if(t.token!==this.childToken)throw new Error("Token mismatch");if(t.type==="resize")this.iframePlaceholder.style.height=`${t.height}px`,this.iframe.style.height=`${t.height}px`;else if(t.type==="domEvent"){let i=this.replicateDomEvent(t.event);t.isTargetEditable?this.hiddenInput.dispatchEvent(i):this.el.dispatchEvent(i)}else if(t.type==="event"){let{event:i,payload:r}=t,n=$L([i,this.props.ref],r);this.channel.push("event",n)}else t.type==="syncReply"?(this.pongCallbackQueue.push(this.syncCallbackQueue.shift()),this.channel.push("ping",{ref:this.props.ref})):t.type==="selectSecret"&&this.pushEvent("select_secret",{js_view_ref:this.props.ref,preselect_name:t.preselectName,options:t.options})}},getAssetsBaseUrl(){return Zm().then(t=>!t&&this.props.assetsCdnUrl?this.props.assetsCdnUrl:window.location.origin+this.props.assetsBasePath)},postMessage(t){this.iframe.contentWindow.postMessage(t,"*")},replicateDomEvent(t){if(t.type==="focus")return new FocusEvent("focus");if(t.type==="mousedown")return new MouseEvent("mousedown",{bubbles:!0});if(t.type==="keydown")return new KeyboardEvent(t.type,t.props)},handleInitTimeout(){this.initTimeoutContainer=document.createElement("div"),this.initTimeoutContainer.classList.add("info-box"),this.el.prepend(this.initTimeoutContainer),this.initTimeoutContainer.textContent=this.props.timeoutMessage},clearInitTimeout(){clearTimeout(this.initTimeout),this.initTimeoutContainer&&this.initTimeoutContainer.remove()},handleServerInit(t){this.clearInitTimeout(),this.initReceived=!0,this.childReadyPromise.then(()=>{this.postMessage({type:"init",data:t})})},handleServerEvent(t,e){this.initReceived&&this.childReadyPromise.then(()=>{this.postMessage({type:"event",event:t,payload:e})})},handleServerError(t,e){e&&this.clearInitTimeout(),this.errorContainer||(this.errorContainer=document.createElement("div"),this.errorContainer.classList.add("error-box","mb-4"),this.el.prepend(this.errorContainer)),this.errorContainer.textContent=t},handleServerPong(){this.pongCallbackQueue.shift()()},handleJSViewEvent(t){t.type==="sync"?(this.syncCallbackQueue.push(t.callback),this.postMessage({type:"sync"})):t.type=="secretSelected"&&this.postMessage({type:"secretSelected",secretName:t.secretName})},handleNavigationEvent(t){if(t.type==="element_focused"){let e=this.el.closest("[data-focusable-id]"),i=e?e.dataset.focusableId:null;this.iframe.toggleAttribute("data-js-focused",i===t.focusableId)}}};function Zm(){return Zm.promise=Zm.promise||fetch("/public/health").then(t=>t.status===200).catch(t=>!1),Zm.promise}var LL=Wre;var Bre={mounted(){this.props=this.getProps(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleDocumentKeyUp=this.handleDocumentKeyUp.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),window.addEventListener("keydown",this._handleDocumentKeyDown,!0),window.addEventListener("keyup",this._handleDocumentKeyUp,!0),window.addEventListener("focus",this._handleDocumentFocus,!0)},updated(){this.props=this.getProps()},destroyed(){window.removeEventListener("keydown",this._handleDocumentKeyDown,!0),window.removeEventListener("keyup",this._handleDocumentKeyUp,!0),window.removeEventListener("focus",this._handleDocumentFocus,!0)},getProps(){return ht(this.el,["cell-id","default-handlers","keydown-enabled","keyup-enabled","target"])},handleDocumentKeyDown(t){if(this.isKeyboardToggle(t)&&!Jo(document.activeElement)){yn(t),this.keyboardEnabled()?this.disableKeyboard():this.enableKeyboard();return}if(this.keyboardEnabled()){if(this.props.defaultHandlers!=="on"&&yn(t),t.repeat)return;if(this.props.keydownEnabled){let{key:e}=t;this.pushEventTo(this.props.target,"keydown",{key:e})}}},handleDocumentKeyUp(t){if(this.keyboardEnabled()&&(this.props.defaultHandlers!=="on"&&yn(t),this.props.keyupEnabled)){let{key:e}=t;this.pushEventTo(this.props.target,"keyup",{key:e})}},handleDocumentFocus(t){this.props.keydownEnabled&&Jo(t.target)&&this.disableKeyboard()},enableKeyboard(){this.keyboardEnabled()||this.pushEventTo(this.props.target,"enable_keyboard",{})},disableKeyboard(){this.keyboardEnabled()&&this.pushEventTo(this.props.target,"disable_keyboard",{})},keyboardEnabled(){return this.props.keydownEnabled||this.props.keyupEnabled},isKeyboardToggle(t){if(t.repeat)return!1;let{metaKey:e,ctrlKey:i,key:r}=t;return(XO()?e:i)&&r==="k"&&this.isCellFocused()?!this.keyboardEnabled()||["on","disable_only"].includes(this.props.defaultHandlers):!1},isCellFocused(){let t=this.el.closest("[data-el-session]");return t&&t.getAttribute("data-js-focused-id")===this.props.cellId}},IL=Bre;var Zre={mounted(){this.props=this.getProps(),this.templateEl=to(this.el,"[data-template]"),this.contentEl=to(this.el,"[data-content]"),this.markdown=new oa(this.contentEl,this.templateEl.textContent,{baseUrl:this.props.basePath,allowedUriSchemes:this.props.allowedUriSchemes})},updated(){this.props=this.getProps(),this.markdown.setContent(this.templateEl.textContent)},getProps(){return ht(this.el,["base-path","allowed-uri-schemes"])}},DL=Zre;var Vre={mounted(){this.scroll()},updated(){this.scroll()},scroll(){hf(this.el)}},NL=Vre;var ih=class{constructor(e=2e3){this.resetTimeout=e,this.buffer=[],this.resetTimeoutId=null}push(e){this.buffer.push(e),this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=setTimeout(()=>{this.reset()},this.resetTimeout)}reset(){this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=null,this.buffer=[]}tryMatch(e){if(e.length>this.buffer.length)return!1;let i=this.buffer.slice(-e.length),r=e.every((n,o)=>n===i[o]);return r&&this.reset(),r}};var Yre={mounted(){this.props=this.getProps(),this.focusedId=null,this.insertMode=!1,this.view=null,this.viewOptions=null,this.keyBuffer=new ih,this.lastLocationReportByClientId={},this.followedClientId=null,this.store=zl.create("session"),IO(this.faviconForEvaluationStatus(this.props.globalStatus)),this.updateSectionListHighlight(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleEditorEscape=this.handleEditorEscape.bind(this),this._handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),this._handleDocumentClick=this.handleDocumentClick.bind(this),document.addEventListener("keydown",this._handleDocumentKeyDown,!0),document.addEventListener("lb:editor_escape",this._handleEditorEscape),document.addEventListener("mousedown",this._handleDocumentMouseDown),document.addEventListener("focus",this._handleDocumentFocus,!0),document.addEventListener("click",this._handleDocumentClick),this.getElement("sections-list").addEventListener("click",t=>{this.handleSectionsListClick(t),this.handleCellIndicatorsClick(t)}),this.getElement("clients-list").addEventListener("click",t=>this.handleClientsListClick(t)),this.getElement("sections-list-toggle").addEventListener("click",t=>this.toggleSectionsList()),this.getElement("clients-list-toggle").addEventListener("click",t=>this.toggleClientsList()),this.getElement("secrets-list-toggle").addEventListener("click",t=>this.toggleSecretsList()),this.getElement("runtime-info-toggle").addEventListener("click",t=>this.toggleRuntimeInfo()),this.getElement("app-info-toggle").addEventListener("click",t=>this.toggleAppInfo()),this.getElement("files-list-toggle").addEventListener("click",t=>this.toggleFilesList()),this.getElement("notebook").addEventListener("scroll",t=>this.updateSectionListHighlight()),this.getElement("notebook-indicators").addEventListener("click",t=>this.handleCellIndicatorsClick(t)),this.getElement("views").addEventListener("click",t=>{this.handleViewsClick(t)}),this.getElement("section-toggle-collapse-all-button").addEventListener("click",t=>this.toggleCollapseAllSections()),this.initializeDragAndDrop(),window.addEventListener("phx:page-loading-stop",()=>{this.initializeFocus()},{once:!0}),this.handleEvent("session_init",({clients:t,client_id:e})=>{let i={};for(let r of t)i[r.id]=r;this.store.set("clients",i),this.store.set("clientId",e)}),this.handleEvent("cell_inserted",({cell_id:t})=>{this.handleCellInserted(t)}),this.handleEvent("cell_deleted",({cell_id:t,sibling_cell_id:e})=>{this.handleCellDeleted(t,e)}),this.handleEvent("cell_restored",({cell_id:t})=>{this.handleCellRestored(t)}),this.handleEvent("cell_moved",({cell_id:t})=>{this.handleCellMoved(t)}),this.handleEvent("section_inserted",({section_id:t})=>{this.handleSectionInserted(t)}),this.handleEvent("section_deleted",({section_id:t})=>{this.handleSectionDeleted(t)}),this.handleEvent("section_moved",({section_id:t})=>{this.handleSectionMoved(t)}),this.handleEvent("client_joined",({client:t})=>{this.handleClientJoined(t)}),this.handleEvent("client_left",({client_id:t})=>{this.handleClientLeft(t)}),this.handleEvent("clients_updated",({clients:t})=>{this.handleClientsUpdated(t)}),this.handleEvent("secret_selected",({select_secret_ref:t,secret_name:e})=>{this.handleSecretSelected(t,e)}),this.handleEvent("location_report",({client_id:t,focusable_id:e})=>{let i={focusableId:e};this.handleLocationReport(t,i)})},updated(){let t=this.props;this.props=this.getProps(),this.props.globalStatus!==t.globalStatus&&IO(this.faviconForEvaluationStatus(this.props.globalStatus))},disconnected(){this.el.removeAttribute("id"),this.keepChannel=!0},destroyed(){document.removeEventListener("keydown",this._handleDocumentKeyDown,!0),document.removeEventListener("lb:editor_scape",this._handleEditorEscape),document.removeEventListener("mousedown",this._handleDocumentMouseDown),document.removeEventListener("focus",this._handleDocumentFocus,!0),document.removeEventListener("click",this._handleDocumentClick),IO("favicon"),this.keepChannel||AL(),this.store.destroy()},getProps(){return ht(this.el,["autofocus-cell-id","global-status"])},faviconForEvaluationStatus(t){return t==="evaluating"?"favicon-evaluating":t==="stale"?"favicon-stale":t==="errored"?"favicon-errored":"favicon"},handleDocumentKeyDown(t){if(t.repeat)return;let e=XO()?t.metaKey:t.ctrlKey,i=t.altKey,r=t.shiftKey,n=t.key,o=this.keyBuffer;if(!(Jo(t.target)&&t.target.closest("[data-el-outputs-container]"))){if(e&&r&&!i&&n==="Enter"){yn(t),this.queueFullCellsEvaluation(!0);return}else if(!e&&r&&!i&&n==="Enter"){yn(t),sa(this.focusedCellType())&&this.queueFocusedCellEvaluation(),this.moveFocus(1);return}else if(e&&!i&&n==="Enter"){yn(t),sa(this.focusedCellType())&&this.queueFocusedCellEvaluation();return}else if(e&&n==="s"){yn(t),this.saveNotebook();return}else if(e||i)return}this.insertMode?(o.reset(),!t.target.closest("[data-el-editor-container]")&&n==="Escape"&&this.escapeInsertMode()):Jo(t.target)?(o.reset(),n==="Escape"&&t.target.blur()):(o.push(t.key),o.tryMatch(["d","d"])?this.deleteFocusedCell():o.tryMatch(["e","a"])?this.queueFullCellsEvaluation(!1):o.tryMatch(["e","e"])?sa(this.focusedCellType())&&this.queueFocusedCellEvaluation():o.tryMatch(["e","s"])?this.queueFocusedSectionEvaluation():o.tryMatch(["s","s"])?this.toggleSectionsList():o.tryMatch(["s","e"])?this.toggleSecretsList():o.tryMatch(["s","a"])?this.toggleAppInfo():o.tryMatch(["s","u"])?this.toggleClientsList():o.tryMatch(["s","f"])?this.toggleFilesList():o.tryMatch(["s","r"])?this.toggleRuntimeInfo():o.tryMatch(["s","b"])?this.showBin():o.tryMatch(["s","p"])?this.showPackageSearch():o.tryMatch(["e","x"])?this.cancelFocusedCellEvaluation():o.tryMatch(["0","0"])?this.reconnectRuntime():o.tryMatch(["Escape","Escape"])?this.setFocusedEl(null):o.tryMatch(["?"])?this.showShortcuts():o.tryMatch(["i"])||t.target.matches("body, [data-el-cell-body], [data-el-heading], [data-focusable-id]")&&this.focusedId&&n==="Enter"?(yn(t),this.isInsertModeAvailable()&&this.enterInsertMode()):o.tryMatch(["j"])?this.moveFocus(1):o.tryMatch(["k"])?this.moveFocus(-1):o.tryMatch(["J"])?this.moveFocusedCell(1):o.tryMatch(["K"])?this.moveFocusedCell(-1):o.tryMatch(["n"])?this.insertCellBelowFocused("code"):o.tryMatch(["N"])?this.insertCellAboveFocused("code"):o.tryMatch(["m"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellBelowFocused("markdown"):o.tryMatch(["M"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellAboveFocused("markdown"):o.tryMatch(["v","z"])?this.toggleView("code-zen"):o.tryMatch(["v","p"])?this.toggleView("presentation"):o.tryMatch(["v","c"])?this.toggleView("custom"):o.tryMatch(["c"])?(!this.view||this.viewOptions.showSection)&&this.toggleCollapseSection():o.tryMatch(["C"])&&(!this.view||this.viewOptions.showSection)&&this.toggleCollapseAllSections())},handleEditorEscape(){this.insertMode&&(this.keyBuffer.reset(),this.escapeInsertMode())},handleDocumentMouseDown(t){if(!t.target.closest("[data-el-notebook]")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest(".cm-tooltip")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest("[data-el-insert-buttons] button"))return;let e=t.target.closest("[data-focusable-id]"),i=e?e.dataset.focusableId:null,r=this.editableElementClicked(t,e);i!==this.focusedId&&this.setFocusedEl(i,{scroll:!1,focusElement:!1}),!t.target.closest("[data-el-actions]")&&this.insertMode!==r&&this.setInsertMode(r)},editableElementClicked(t,e){if(e){let i=t.target.closest("[data-el-editor-container], [data-el-heading]");return i&&e.contains(i)}return!1},handleDocumentFocus(t){let e=t.target.closest&&t.target.closest("[data-focusable-id]");if(e){let i=e.dataset.focusableId;i!==this.focusedId&&this.setFocusedEl(i,{scroll:!1,focusElement:!1})}},handleDocumentClick(t){t.target.closest("[data-el-enable-insert-mode-button]")&&this.setInsertMode(!0),t.target.closest("[data-btn-package-search]")&&this.insertMode&&this.setInsertMode(!1);let e=t.target.closest("[data-el-queue-cell-evaluation-button]");if(e){let r=e.getAttribute("data-cell-id"),n=e.hasAttribute("data-disable-dependencies-cache");this.queueCellEvaluation(r,n)}let i=window.location.hash;if(i){let r=i.replace(/^#/,"");!document.getElementById(r).contains(t.target)&&!t.target.closest("a")&&history.pushState(null,document.title,window.location.pathname+window.location.search)}},handleSectionsListClick(t){let e=t.target.closest("[data-el-sections-list-item]");if(e){let i=e.getAttribute("data-section-id");this.getSectionById(i).scrollIntoView({behavior:"smooth",block:"start"})}},handleClientsListClick(t){let e=t.target.closest("[data-el-clients-list-item]");if(e){let i=e.getAttribute("data-client-id");t.target.closest("[data-el-client-link]")&&this.handleClientLinkClick(i),t.target.closest("[data-el-client-follow-toggle]")&&this.handleClientFollowToggleClick(i,e)}},handleClientLinkClick(t){this.mirrorClientFocus(t)},handleClientFollowToggleClick(t,e){let i=this.el.querySelector("[data-el-clients-list-item][data-js-followed]");i&&i.removeAttribute("data-js-followed"),t===this.followedClientId?this.followedClientId=null:(e.setAttribute("data-js-followed",""),this.followedClientId=t,this.mirrorClientFocus(t))},mirrorClientFocus(t){let e=this.lastLocationReportByClientId[t];e&&e.focusableId&&this.setFocusedEl(e.focusableId)},handleCellIndicatorsClick(t){let e=t.target.closest("[data-el-focus-cell-button]");if(e){let i=e.getAttribute("data-target");this.setFocusedEl(i)}},initializeFocus(){let t=window.location.hash;if(t){let e=t.replace(/^#/,""),i=document.getElementById(e);if(i){let r=i.closest("[data-focusable-id]");r?this.setFocusedEl(r.dataset.focusableId):i.scrollIntoView()}}else this.props.autofocusCellId&&(this.setFocusedEl(this.props.autofocusCellId,{scroll:!1}),this.setInsertMode(!0))},updateSectionListHighlight(){let t=this.el.querySelector("[data-el-sections-list-item][data-js-is-viewed]");t&&t.removeAttribute("data-js-is-viewed");let e=this.getSections().reverse().find(i=>{let{top:r}=i.getBoundingClientRect(),n=document.documentElement.scrollTop;return r<=n+window.innerHeight*.35});if(e){let i=e.getAttribute("data-section-id");this.el.querySelector(`[data-el-sections-list-item][data-section-id="${i}"]`).setAttribute("data-js-is-viewed","")}},initializeDragAndDrop(){let t=!1,e=null,i=null,r=(o=null)=>{if(!t){t=!0,e=o;let s=o?"internal":"external";this.el.setAttribute("data-js-dragging",s),s==="external"&&this.toggleFilesList(!0)}},n=()=>{t&&(t=!1,this.el.removeAttribute("data-js-dragging"))};this.el.addEventListener("dragstart",o=>{r(o.target)}),this.el.addEventListener("dragenter",o=>{r()}),this.el.addEventListener("dragleave",o=>{PX()||this.el.contains(o.relatedTarget)||n()}),this.el.addEventListener("dragover",o=>{o.stopPropagation(),o.preventDefault()}),this.el.addEventListener("drop",o=>{o.stopPropagation(),o.preventDefault();let s=o.target.closest("[data-el-insert-drop-area]"),a=o.target.closest("[data-el-files-drop-area]");if(s){let l=s.getAttribute("data-section-id")||null,c=s.getAttribute("data-cell-id")||null;if(o.dataTransfer.files.length>0)i=o.dataTransfer.files,this.pushEvent("handle_file_drop",{section_id:l,cell_id:c});else if(e&&e.matches("[data-el-file-entry]")){let u=e.getAttribute("data-name");this.pushEvent("insert_file",{file_entry_name:u,section_id:l,cell_id:c})}}else a&&o.dataTransfer.files.length>0&&(i=o.dataTransfer.files,this.pushEvent("handle_file_drop",{}));n()}),this.handleEvent("finish_file_drop",o=>{let s=document.querySelector('#add-file-entry-modal input[type="file"]');s&&(s.files=i,s.dispatchEvent(new Event("change",{bubbles:!0})))})},toggleSectionsList(t=null){this.toggleSidePanelContent("sections-list",t)},toggleClientsList(t=null){this.toggleSidePanelContent("clients-list",t)},toggleSecretsList(t=null){this.toggleSidePanelContent("secrets-list",t)},toggleAppInfo(t=null){this.toggleSidePanelContent("app-info",t)},toggleFilesList(t=null){this.toggleSidePanelContent("files-list",t)},toggleRuntimeInfo(t=null){this.toggleSidePanelContent("runtime-info",t)},toggleSidePanelContent(t,e=null){(e===null?this.el.getAttribute("data-js-side-panel-content")!==t:e)?this.el.setAttribute("data-js-side-panel-content",t):this.el.removeAttribute("data-js-side-panel-content")},showBin(){let t=this.el.querySelector("[data-btn-show-bin]");t&&t.click()},showPackageSearch(){this.setFocusedEl("setup");let t=this.el.querySelector("[data-btn-package-search]");t&&t.click()},saveNotebook(){this.pushEvent("save",{})},deleteFocusedCell(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("delete_cell",{cell_id:this.focusedId})},queueCellEvaluation(t,e){this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:t,disable_dependencies_cache:e})})},queueFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:this.focusedId})})},queueFullCellsEvaluation(t){let e=t&&this.focusedId&&this.isCell(this.focusedId)?[this.focusedId]:[];this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_full_evaluation",{forced_cell_ids:e})})},queueFocusedSectionEvaluation(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);t&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_section_evaluation",{section_id:t})})}},dispatchQueueEvaluation(t){sa(this.focusedCellType())?ti.broadcast(`cells:${this.focusedId}`,{type:"dispatch_queue_evaluation",dispatch:t}):t()},cancelFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("cancel_cell_evaluation",{cell_id:this.focusedId})},reconnectRuntime(){this.pushEvent("reconnect_runtime",{})},showShortcuts(){let t=this.el.querySelector("[data-btn-show-shortcuts]");t&&t.click()},isInsertModeAvailable(){if(!this.focusedId)return!1;let t=this.getFocusableEl(this.focusedId);return!this.isCell(this.focusedId)||!t.hasAttribute("data-js-insert-mode-disabled")},enterInsertMode(){this.focusedId&&this.setInsertMode(!0)},escapeInsertMode(){this.setInsertMode(!1)},moveFocus(t){let e=this.nearbyFocusableId(this.focusedId,t);this.setFocusedEl(e)},moveFocusedCell(t){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("move_cell",{cell_id:this.focusedId,offset:t})},insertCellBelowFocused(t){if(this.focusedId)this.insertCellBelowFocusableId(this.focusedId,t);else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[e.length-1],t)}},insertCellAboveFocused(t){if(this.focusedId){let e=this.nearbyFocusableId(this.focusedId,-1);this.insertCellBelowFocusableId(e,t)}else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[0],t)}},insertCellBelowFocusableId(t,e){if(this.isCell(t))this.pushEvent("insert_cell_below",{type:e,cell_id:t});else if(this.isSection(t))this.pushEvent("insert_cell_below",{type:e,section_id:t});else if(this.isNotebook(t)){let i=this.getSectionIds();i.length>0&&this.pushEvent("insert_cell_below",{type:e,section_id:i[0]})}},setFocusedEl(t,{scroll:e=!0,focusElement:i=!0}={}){if(this.focusedId=t,t?this.el.setAttribute("data-js-focused-id",t):this.el.removeAttribute("data-js-focused-id"),t){if(!this.isSection(t)){let n=this.getSectionIdByFocusableId(t);n&&this.getSectionById(n).removeAttribute("data-js-collapsed")}let r=this.getFocusableEl(t);i&&(r.querySelector("[data-el-cell-body]")||r.querySelector("[data-el-heading]")||r).focus({preventScroll:!0})}ti.broadcast("navigation",{type:"element_focused",focusableId:t,scroll:e}),this.setInsertMode(!1),this.sendLocationReport({focusableId:t})},setInsertMode(t){this.insertMode=t,t?this.el.setAttribute("data-js-insert-mode",""):this.el.removeAttribute("data-js-insert-mode"),ti.broadcast("navigation",{type:"insert_mode_changed",enabled:t})},handleViewsClick(t){let e=t.target.closest("[data-el-view-toggle]");if(e){let i=e.getAttribute("data-el-view-toggle");this.toggleView(i)}},toggleView(t){t===this.view?(this.unsetView(),t==="custom"&&this.customViewSettingsSubscription.destroy()):t==="code-zen"?this.setView(t,{showSection:!1,showMarkdown:!1,showOutput:!0,spotlight:!1}):t==="presentation"?this.setView(t,{showSection:!0,showMarkdown:!0,showOutput:!0,spotlight:!0}):t==="custom"&&(this.customViewSettingsSubscription=xt.getAndSubscribe(i=>{this.setView(t,{showSection:i.custom_view_show_section,showMarkdown:i.custom_view_show_markdown,showOutput:i.custom_view_show_output,spotlight:i.custom_view_spotlight})}),this.pushEvent("open_custom_view_settings"));let e=this.focusedId||this.nearbyFocusableId(null,0);if(e){let i=this.ensureVisibleFocusableEl(e);i!==this.focused&&this.setFocusedEl(i,{scroll:!1}),i&&this.getFocusableEl(i).scrollIntoView({block:"center"})}},setView(t,e){this.view=t,this.viewOptions=e,this.el.setAttribute("data-js-view",t),this.el.toggleAttribute("data-js-hide-section",!e.showSection),this.el.toggleAttribute("data-js-hide-markdown",!e.showMarkdown),this.el.toggleAttribute("data-js-hide-output",!e.showOutput),this.el.toggleAttribute("data-js-spotlight",e.spotlight)},unsetView(){this.view=null,this.viewOptions=null,this.el.removeAttribute("data-js-view"),this.el.removeAttribute("data-js-hide-section"),this.el.removeAttribute("data-js-hide-markdown"),this.el.removeAttribute("data-js-hide-output"),this.el.removeAttribute("data-js-spotlight")},toggleCollapseSection(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);if(t){let e=this.getSectionById(t);e.hasAttribute("data-js-collapsed")?e.removeAttribute("data-js-collapsed"):(e.setAttribute("data-js-collapsed",""),this.setFocusedEl(t,{scroll:!0}))}}},toggleCollapseAllSections(){let t=this.getSections().every(e=>e.hasAttribute("data-js-collapsed"));if(this.getSections().forEach(e=>{e.toggleAttribute("data-js-collapsed",!t)}),this.focusedId){let e=this.getSectionIdByFocusableId(this.focusedId);e&&this.setFocusedEl(e,{scroll:!0})}},handleCellInserted(t){this.setFocusedEl(t),LX(this.focusedCellType())&&this.setInsertMode(!0)},handleCellDeleted(t,e){if(this.focusedId===t)if(this.view){let i=this.ensureVisibleFocusableEl(e);this.setFocusedEl(i)}else this.setFocusedEl(e)},handleCellRestored(t){this.setFocusedEl(t)},handleCellMoved(t){this.repositionJSViews(),this.focusedId===t&&ti.broadcast("cells",{type:"cell_moved",cellId:t})},handleSectionInserted(t){let i=this.getSectionById(t).querySelector("[data-el-section-headline]"),{focusableId:r}=i.dataset;this.setFocusedEl(r),this.setInsertMode(!0),bX(document.activeElement)},handleSectionDeleted(t){this.focusedId&&!this.getFocusableEl(this.focusedId)&&this.setFocusedEl(null)},handleSectionMoved(t){this.repositionJSViews();let e=this.getSectionById(t);na(e)},handleClientJoined(t){let e=this.store.get("clients");this.store.set("clients",Ce(H({},e),{[t.id]:t}))},handleClientLeft(t){let e=this.store.get("clients"),i=e[t];if(i){let[,r]=NO(e,t);this.store.set("clients",r),i.id===this.followedClientId&&(this.followedClientId=null)}},handleClientsUpdated(t){let e=this.store.get("clients"),i=H({},e);for(let r of t)i[r.id]=r;this.store.set("clients",i)},handleSecretSelected(t,e){ti.broadcast(`js_views:${t}`,{type:"secretSelected",secretName:e})},handleLocationReport(t,e){let i=this.store.get("clients")[t];this.lastLocationReportByClientId[t]=e,i&&i.id===this.followedClientId&&e.focusableId!==this.focusedId&&this.setFocusedEl(e.focusableId)},repositionJSViews(){ti.broadcast("js_views",{type:"reposition"})},sendLocationReport(t){Object.keys(this.store.get("clients")).length>1&&this.pushEvent("location_report",{focusable_id:t.focusableId})},focusedCellType(){return this.focusedId&&this.isCell(this.focusedId)?this.getFocusableEl(this.focusedId).getAttribute("data-type"):null},nearbyFocusableId(t,e){let i=this.getFocusableIds();if(i.length===0)return null;let r=i.indexOf(t);if(r===-1){let n=this.getFocusableEls().find(Jv);return n?n.getAttribute("data-focusable-id"):i[0]}else{let n=mX(r+e,0,i.length-1);return i[n]}},ensureVisibleFocusableEl(t){let e=this.getFocusableEl(t),i=Array.from(this.el.querySelectorAll("[data-focusable-id]")),r=i.indexOf(e),n=[...i.slice(r,-1),...i.slice(0,r).reverse()].find(o=>!bn(o));return n&&n.getAttribute("data-focusable-id")},isCell(t){return this.getFocusableEl(t).hasAttribute("data-el-cell")},isSection(t){return this.getFocusableEl(t).hasAttribute("data-el-section-headline")},isNotebook(t){return this.getFocusableEl(t).hasAttribute("data-el-notebook-headline")},getFocusableEl(t){return this.el.querySelector(`[data-focusable-id="${t}"]`)},getFocusableEls(){return Array.from(this.el.querySelectorAll("[data-focusable-id]")).filter(t=>!bn(t))},getFocusableIds(){return this.getFocusableEls().map(t=>t.getAttribute("data-focusable-id"))},getSectionIdByFocusableId(t){let i=this.getFocusableEl(t).closest("[data-el-section]");return i&&i.getAttribute("data-section-id")},getSectionIds(){return this.getSections().map(e=>e.getAttribute("data-section-id"))},getSections(){return Array.from(this.el.querySelectorAll("[data-el-section]"))},getSectionById(t){return this.el.querySelector(`[data-el-section][data-section-id="${t}"]`)},getElement(t){return this.el.querySelector(`[data-el-${t}]`)}},ML=Yre;var Fre={mounted(){this.autosize(),this.el.addEventListener("input",t=>{this.autosize()})},updated(){this.autosize()},autosize(){this.el.style.height="0px",this.el.style.height=`${this.el.scrollHeight+2}px`}},UL=Fre;var Hre=100,Gre={mounted(){this.props=this.getProps(),this.interval=setInterval(()=>this.updateDOM(),Hre)},updated(){this.props=this.getProps(),this.updateDOM()},destroyed(){clearInterval(this.interval)},getProps(){return ht(this.el,["start"])},updateDOM(){let e=(Date.now()-new Date(this.props.start))/1e3;this.el.innerHTML=`${e.toFixed(1)}s`}},zL=Gre;var jL="lb_user_data";function qL(t){let e=JSON.stringify(t),i=xX(e);Jre(jL,i,15768e4)}function WL(){let t=Kre(jL);if(t){let e=vX(t);return JSON.parse(e)}else return null}function Kre(t){let e=document.cookie.split("; ").find(i=>i.startsWith(`${t}=`));return e?e.replace(`${t}=`,""):null}function Jre(t,e,i){let r=`${t}=${e};max-age=${i};path=/${DO()}`;document.cookie=r}var ene={mounted(){this.el.addEventListener("submit",t=>{let e=this.el.user_form_name.value,i=this.el.user_form_hex_color.value;qL({name:e,hex_color:i})})}},BL=ene;var tne={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.datetimeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return ht(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.datetimeUtcToLocal(this.props.utcValue),this.el.min=this.datetimeUtcToLocal(this.props.utcMin),this.el.max=this.datetimeUtcToLocal(this.props.utcMax)},datetimeUtcToLocal(t){if(!t)return null;let e=new Date(t+"Z"),i=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),a=e.getSeconds().toString().padStart(2,"0");return`${i}-${r}-${n}T${o}:${s}:${a}`},datetimeLocalToUtc(t){if(!t)return null;let e=new Date(t),i=e.getUTCFullYear().toString(),r=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),o=e.getUTCHours().toString().padStart(2,"0"),s=e.getUTCMinutes().toString().padStart(2,"0"),a=e.getUTCSeconds().toString().padStart(2,"0");return`${i}-${r}-${n}T${o}:${s}:${a}`}},ZL=tne;var ine={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.timeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return ht(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.timeUtcToLocal(this.props.utcValue),this.el.min=this.timeUtcToLocal(this.props.utcMin),this.el.max=this.timeUtcToLocal(this.props.utcMax)},timeUtcToLocal(t){if(!t)return null;let e=new Date;e.setUTCHours(...t.split(":"));let i=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),n=e.getSeconds().toString().padStart(2,"0");return`${i}:${r}:${n}`},timeLocalToUtc(t){if(!t)return null;let e=new Date;e.setHours(...t.split(":"));let i=e.getUTCHours().toString().padStart(2,"0"),r=e.getUTCMinutes().toString().padStart(2,"0"),n=e.getUTCSeconds().toString().padStart(2,"0");return`${i}:${r}:${n}`}},VL=ine;var HL=va(FL());var rne={mounted(){this.props=this.getProps(),this.lineHeight=gX(this.el),this.templateEl=to(this.el,"[data-template]"),this.contentEl=to(this.el,"[data-content]"),this.capLines();let t=this.hyperListConfig();this.virtualizedList=new HL.default(this.contentEl,t),this.props.follow&&hf(this.contentEl)},updated(){this.props=this.getProps(),this.capLines();let t=this.props.follow&&yX(this.contentEl),e=this.hyperListConfig();this.virtualizedList.refresh(this.contentEl,e),t&&hf(this.contentEl)},getProps(){return ht(this.el,["max-height","follow","max-lines","ignore-trailing-empty-line"])},hyperListConfig(){let t=this.getLineElements(),e=t.length,i=Math.min(this.props.maxHeight,this.lineHeight*e);return{height:i,total:e,itemHeight:this.lineHeight,generate:r=>{let n=t[r].cloneNode(!0);return n.removeAttribute("id"),n},afterRender:()=>{this.contentEl.scrollWidth>this.contentEl.clientWidth?this.contentEl.style.height=`${i+12}px`:this.contentEl.style.height=`${i}px`}}},getLineElements(){let t=Array.from(this.templateEl.querySelectorAll("[data-line]"));if(t.length===0)return[];let e=t[t.length-1];return this.props.ignoreTrailingEmptyLine&&e.innerText===""?t.slice(0,-1):t},capLines(){if(this.props.maxLines){let e=Array.from(this.templateEl.querySelectorAll("[data-line]")).slice(0,-this.props.maxLines),[i,...r]=e;r.forEach(n=>n.remove()),i&&(i.innerHTML="...")}}},GL=rne;var nne={mounted(){let t=xt.get(),e=this.el.querySelector('[name="show_section"][value="true"]'),i=this.el.querySelector('[name="show_markdown"][value="true"]'),r=this.el.querySelector('[name="show_output"][value="true"]'),n=this.el.querySelector('[name="spotlight"][value="true"]');e.checked=t.custom_view_show_section,i.checked=t.custom_view_show_markdown,r.checked=t.custom_view_show_output,n.checked=t.custom_view_spotlight,e.addEventListener("change",o=>{xt.update({custom_view_show_section:o.target.checked})}),i.addEventListener("change",o=>{xt.update({custom_view_show_markdown:o.target.checked})}),r.addEventListener("change",o=>{xt.update({custom_view_show_output:o.target.checked})}),n.addEventListener("change",o=>{xt.update({custom_view_spotlight:o.target.checked})})}},KL=nne;var JL={AppAuth:yS,AudioInput:kS,Cell:IX,CellEditor:IR,Dropzone:DR,EditorSettings:NR,EmojiPicker:kL,FocusOnUpdate:SL,Headline:EL,Highlight:CL,ImageInput:PL,ImageOutput:_L,JSView:LL,KeyboardControl:IL,MarkdownRenderer:DL,ScrollOnUpdate:NL,Session:ML,TextareaAutosize:UL,Timer:zL,UserForm:BL,UtcDateTimeInput:ZL,UtcTimeInput:VL,VirtualizedLines:GL,CustomViewSettings:KL};var eI={onBeforeElUpdated(t,e){for(let i of t.attributes)i.name.startsWith("data-js-")&&e.setAttribute(i.name,i.value),i.name==="data-keep-attribute"&&(t.hasAttribute(i.value)?e.setAttribute(i.value,t.getAttribute(i.value)):e.removeAttribute(i.value))},onNodeAdded(t){if(t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("autofocus")&&(t.focus(),t.setSelectionRange&&t.value)){let e=t.value.length;t.setSelectionRange(e,e)}}};var Ym=va(iI());function rI(){Ym.default.config({barColors:{0:"#b2c1ff"},shadowColor:"rgba(0, 0, 0, .3)"}),window.addEventListener("phx:page-loading-start",()=>{Ym.default.show(500)}),window.addEventListener("phx:page-loading-stop",()=>{Ym.default.hide()})}function nI(){window.addEventListener("lb:focus",t=>{requestAnimationFrame(()=>{t.target.focus()})}),window.addEventListener("lb:set_value",t=>{t.target.value=t.detail.value}),window.addEventListener("lb:check",t=>{t.target.checked=!0}),window.addEventListener("lb:uncheck",t=>{t.target.checked=!1}),window.addEventListener("lb:set_text",t=>{t.target.textContent=t.detail.value}),window.addEventListener("lb:clipcopy",t=>{"clipboard"in navigator?t.detail.content?navigator.clipboard.writeText(t.detail.content):t.target.tagName==="INPUT"?navigator.clipboard.writeText(t.target.value):navigator.clipboard.writeText(t.target.textContent):alert(`Sorry, your browser does not support clipboard copy. +`," ");document.execCommand("insertText",!1,i)}),this.headingEl.addEventListener("keydown",e=>{e.key==="Enter"&&e.preventDefault()}),this.headingEl.addEventListener("blur",e=>{setTimeout(()=>{this.isFocused&&this.insertMode&&(this.headingEl.focus(),TL(this.headingEl))},0)}))},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleElementFocused(t,e){this.props.id===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&na(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.el.setAttribute("phx-update","ignore"),this.headingEl.setAttribute("contenteditable",""),this.headingEl.focus(),TL(this.headingEl)):this.insertMode&&!t&&(this.insertMode=t,this.headingEl.removeAttribute("contenteditable"),this.el.removeAttribute("phx-update"),this.pushEvent(this.props.onValueChange,{value:this.headingEl.textContent.trim(),metadata:this.props.metadata}))}};function TL(t){let e=document.createRange();e.selectNodeContents(t),e.collapse(!1);let i=window.getSelection();i.removeAllRanges(),i.addRange(e)}var EL=$re;var Xre={mounted(){this.props=this.getProps(),this.sourceEl=to(this.el,"[data-source]"),this.targetEl=to(this.el,"[data-target]"),this.updateDOM()},updated(){this.props=this.getProps(),this.updateDOM()},getProps(){return ht(this.el,["language"])},updateDOM(){let t=this.sourceEl.innerText,e=MO(t,this.props.language);this.targetEl.innerHTML=e,this.el.setAttribute("data-highlighted","")}},CL=Xre;var H2=["bg-yellow-100","border-yellow-300"],Rre={mounted(){this.props=this.getProps(),this.inputEl=this.el.querySelector("[data-input]"),this.previewEl=this.el.querySelector("[data-preview]"),this.initialPreviewContentEl=this.previewEl.firstElementChild,this.cameraPreviewEl=this.el.querySelector("[data-camera-preview]"),this.cameraListEl=this.el.querySelector("[data-camera-list]"),this.cameraItemTemplateEl=this.cameraListEl.firstElementChild,this.cameraItemTemplateEl.remove(),this.uploadButton=this.el.querySelector("[data-btn-upload]"),this.openCameraButton=this.el.querySelector("[data-btn-open-camera]"),this.captureCameraButton=this.el.querySelector("[data-btn-capture-camera]"),this.cancelButton=this.el.querySelector("[data-btn-cancel]"),this.cameraListPopulated=!1,this.cameraVideoEl=null,this.cameraStream=null,this.updateImagePreview(),this.uploadButton.addEventListener("click",t=>{this.inputEl.click()}),this.inputEl.addEventListener("change",t=>{let[e]=t.target.files;e&&this.loadFile(e)}),this.el.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}),this.el.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault();let[e]=t.dataTransfer.files;e&&this.loadFile(e),this.closeCameraView()}),this.el.addEventListener("dragenter",t=>{this.el.classList.add(...H2)}),this.el.addEventListener("dragleave",t=>{this.el.contains(t.relatedTarget)||this.el.classList.remove(...H2)}),this.el.addEventListener("drop",t=>{this.el.classList.remove(...H2)}),this.openCameraButton.addEventListener("click",t=>{this.cameraListPopulated||(this.renderCameraList(),this.cameraListPopulated=!0)}),this.cameraListEl.addEventListener("click",t=>{let e=t.target.closest("[data-camera-id]");if(e){let i=e.dataset.cameraId;this.openCameraView(i)}}),this.captureCameraButton.addEventListener("click",t=>{let e=this.toCanvas(this.cameraVideoEl,this.cameraVideoEl.videoWidth,this.cameraVideoEl.videoHeight);this.pushImage(e),this.closeCameraView()}),this.cancelButton.addEventListener("click",t=>{this.closeCameraView()})},updated(){this.props=this.getProps(),this.updateImagePreview()},getProps(){return ht(this.el,["id","phx-target","height","width","format","fit","image-url","value-height","value-width"])},updateImagePreview(){this.props.imageUrl?Dre(this.props.imageUrl,this.props.valueHeight,this.props.valueWidth,this.props.format).then(t=>{this.setPreview(t)}):this.setPreview(this.initialPreviewContentEl)},loadFile(t){let e=new FileReader;e.onload=i=>{let r=document.createElement("img");r.addEventListener("load",n=>{let o=this.toCanvas(r,r.width,r.height);this.pushImage(o)}),r.src=i.target.result},e.readAsDataURL(t)},openCameraView(t){this.cameraPreviewEl.classList.remove("hidden"),this.cancelButton.classList.remove("hidden"),this.captureCameraButton.classList.remove("hidden"),this.previewEl.classList.add("hidden"),this.openCameraButton.classList.add("hidden"),this.uploadButton.classList.add("hidden"),navigator.mediaDevices.getUserMedia(this.cameraConstraints(t)).then(e=>{this.cameraStream=e,this.cameraVideoEl=document.createElement("video"),this.cameraVideoEl.autoplay=!0,this.cameraVideoEl.playsinline=!0,this.cameraVideoEl.muted=!0,this.cameraVideoEl.srcObject=e,this.setCameraPreview(this.cameraVideoEl)}).catch(()=>{})},cameraConstraints(t){return t==="system_default"?{audio:!1,video:!0}:{audio:!1,video:{deviceId:t}}},renderCameraList(){navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then(t=>navigator.mediaDevices.enumerateDevices().then(e=>(this.stopMediaStream(t),e))).then(t=>{let e=t.filter(i=>i.kind==="videoinput").map(i=>({deviceId:i.deviceId,label:i.label}));[{deviceId:"system_default",label:"System Default"},...e].forEach(({deviceId:i,label:r})=>{let n=this.cameraItemTemplateEl.cloneNode(!0);n.querySelector("[data-camera-id]").setAttribute("data-camera-id",i),n.querySelector("[data-label]").innerHTML=r,this.cameraListEl.appendChild(n)})}).catch(t=>{console.error(t),this.openCameraButton.disabled=!0})},closeCameraView(){return this.cameraStream!==null&&(this.stopMediaStream(this.cameraStream),this.cameraStream=null),this.cameraVideoEl!==null&&(this.cameraVideoEl.remove(),this.cameraVideoEl=null),this.cameraPreviewEl.classList.add("hidden"),this.cancelButton.classList.add("hidden"),this.captureCameraButton.classList.add("hidden"),this.previewEl.classList.remove("hidden"),this.openCameraButton.classList.remove("hidden"),this.uploadButton.classList.remove("hidden"),!0},stopMediaStream(t){t.getTracks().forEach(e=>{e.stop()})},pushImage(t){Lre(t,this.props.format).then(e=>{let i={height:t.height,width:t.width},r=new Blob([e]);r.meta=()=>i,this.uploadTo(this.props.phxTarget,"file",[r])})},toCanvas(t,e,i){let{width:r,height:n}=this.props,o=document.createElement("canvas"),s=o.getContext("2d");if(r===null&&n===null||r===e&&n===i)o.width=e,o.height=i,o.getContext("2d").drawImage(t,0,0,e,i,0,0,e,i);else if(this.props.fit==="contain"){let a=r/e,l=n/i,c=Math.min(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=u,o.height=f,s.drawImage(t,0,0,e,i,0,0,u,f)}else if(this.props.fit==="crop"){let a=r/e,l=n/i,c=Math.max(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=r,o.height=n,s.drawImage(t,Math.round((u-r)/c/2),Math.round((f-n)/c/2),e-Math.round((u-r)/c),i-Math.round((f-n)/c),0,0,r,n)}else if(this.props.fit==="pad"){let a=r/e,l=n/i,c=Math.min(a,l),u=Math.round(e*c),f=Math.round(i*c);o.width=r,o.height=n,s.fillStyle="black",s.fillRect(0,0,o.width,o.height),s.drawImage(t,0,0,e,i,Math.round((r-u)/2),Math.round((n-f)/2),u,f)}else o.width=r,o.height=n,s.drawImage(t,0,0,e,i,0,0,r,n);return o},setPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.previewEl.replaceChildren(t)},setCameraPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.cameraPreviewEl.replaceChildren(t)}};function Lre(t,e){if(e==="png"||e==="jpeg")return new Promise((i,r)=>{t.toBlob(n=>{n.arrayBuffer().then(o=>{i(o)})},`image/${e}`)});if(e==="rgb"){let i=t.getContext("2d").getImageData(0,0,t.width,t.height),r=Ire(i);return Promise.resolve(r)}throw new Error(`Unexpected format: ${e}`)}function Ire(t){let e=t.width*t.height,i=new Uint8ClampedArray(e*3);for(let r=0;rn.arrayBuffer()).then(n=>{let o=document.createElement("canvas");o.height=e,o.width=i;let s=Nre(n,i,e);return o.getContext("2d").putImageData(s,0,0),o});throw new Error(`Unexpected format: ${r}`)}function Nre(t,e,i){let r=e*i,n=new Uint8Array(t),o=new Uint8ClampedArray(r*4);for(let s=0;s{t.sandbox="allow-scripts allow-same-origin allow-downloads allow-forms allow-modals allow-popups allow-top-navigation",t.allow="accelerometer; ambient-light-sensor; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; microphone; midi; usb; xr-spatial-tracking; clipboard-read; clipboard-write; bluetooth; serial",t.src=r})}function jre(t,e){let i=window.location.protocol;return e?e.replace(/^https?:/,i):i==="https:"?"https://livebookusercontent.com/iframe/v5.html":`http://${window.location.hostname}:${t}/iframe/v5.html`}var J2=null;function qre(t){return J2||(J2=fetch(t).then(e=>e.text()).then(e=>{if(TX(e)!==XL)throw new Error(`The iframe loaded from ${t} doesn't have the expected checksum ${XL}`)})),J2}var Wre={mounted(){this.props=this.getProps(),this.id=wX(),this.childToken=kX(),this.childReadyPromise=null,this.childReady=!1,this.initReceived=!1,this.syncCallbackQueue=[],this.pongCallbackQueue=[],this.initTimeout=setTimeout(()=>this.handleInitTimeout(),2e3),this.channel=QL(this.props.sessionToken),this.iframeActions=this.createIframe(),this.childReadyPromise=new Promise((n,o)=>{this._handleWindowMessage=s=>{s.source===this.iframe.contentWindow&&this.handleChildMessage(s.data,n)},window.addEventListener("message",this._handleWindowMessage)}),this.hiddenInput=document.createElement("input"),this.hiddenInput.style.display="none",this.el.appendChild(this.hiddenInput),this.iframeActions.visibilityPromise.then(()=>{this.loadIframe()});let t=this.channel.on(`init:${this.props.ref}:${this.id}`,n=>{let[,o]=K2(n);this.handleServerInit(o)}),e=this.channel.on(`event:${this.props.ref}`,n=>{let[[o],s]=K2(n);this.handleServerEvent(o,s)}),i=this.channel.on(`error:${this.props.ref}`,({message:n,init:o})=>{this.handleServerError(n,o)}),r=this.channel.on(`pong:${this.props.ref}`,()=>{this.handleServerPong()});this.unsubscribeFromChannelEvents=()=>{this.channel.off(`init:${this.props.ref}:${this.id}`,t),this.channel.off(`event:${this.props.ref}`,e),this.channel.off(`error:${this.props.ref}`,i),this.channel.off(`pong:${this.props.ref}`,r)},this.subscriptions=[ti.subscribe(`js_views:${this.props.ref}`,this.handleJSViewEvent.bind(this)),ti.subscribe("navigation",this.handleNavigationEvent.bind(this))],this.channel.push("connect",{connect_token:this.props.connectToken,ref:this.props.ref,id:this.id},3e4)},updated(){this.props=this.getProps(this)},disconnected(){this.el.removeAttribute("id")},destroyed(){window.removeEventListener("message",this._handleWindowMessage),this.iframeActions.remove(),this.unsubscribeFromChannelEvents(),this.channel.push("disconnect",{ref:this.props.ref}),this.subscriptions.forEach(t=>t.destroy())},getProps(){return ht(this.el,["ref","assets-base-path","assets-cdn-url","js-path","session-token","connect-token","iframe-port","iframe-url","timeout-message"])},createIframe(){this.iframePlaceholder=document.createElement("div"),this.el.appendChild(this.iframePlaceholder),this.iframe=document.createElement("iframe"),this.iframe.className="w-full h-0 absolute z-[1]";let t=document.querySelector("[data-el-notebook]"),e=t.querySelector("[data-el-notebook-content]"),i=new ResizeObserver(l=>{this.repositionIframe()});i.observe(e),i.observe(t);let r=bn(this.iframePlaceholder),n=new ResizeObserver(l=>{let c=bn(this.iframePlaceholder);r!==c&&(r=c,this.repositionIframe())});n.observe(this.iframePlaceholder);let o=ti.subscribe("js_views",l=>{l.type==="reposition"&&this.repositionIframe()});this.iframe.addEventListener("mouseenter",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}))}),this.iframe.addEventListener("mouseleave",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))});let s=RO(this.iframePlaceholder,{root:t,proximity:2e3});this.iframe.toggleAttribute("data-js-focused",!!this.el.closest("[data-js-focused]"));let a=()=>{i.disconnect(),n.disconnect(),o.destroy(),s.cancel(),this.iframe.remove(),this.iframePlaceholder.remove()};return{visibilityPromise:s.promise,remove:a}},repositionIframe(){let{iframe:t,iframePlaceholder:e}=this,i=document.querySelector("[data-el-notebook]");if(bn(e))t.classList.add("hidden");else{t.classList.remove("hidden");let r=i.getBoundingClientRect(),n=e.getBoundingClientRect(),o=n.top-r.top+i.scrollTop;t.style.top=`${o}px`;let s=n.left-r.left+i.scrollLeft;t.style.left=`${s}px`,t.style.height=`${n.height}px`,t.style.width=`${n.width}px`}},loadIframe(){let t=document.querySelector("[data-el-js-view-iframes]");RL(this.iframe,this.props.iframePort,this.props.iframeUrl).then(()=>{t.appendChild(this.iframe)})},handleChildMessage(t,e){if(t.type==="ready"&&!this.childReady)this.getAssetsBaseUrl().then(i=>{this.postMessage({type:"readyReply",token:this.childToken,baseUrl:i,jsPath:this.props.jsPath}),this.childReady=!0,e()});else{if(t.token!==this.childToken)throw new Error("Token mismatch");if(t.type==="resize")this.iframePlaceholder.style.height=`${t.height}px`,this.iframe.style.height=`${t.height}px`;else if(t.type==="domEvent"){let i=this.replicateDomEvent(t.event);t.isTargetEditable?this.hiddenInput.dispatchEvent(i):this.el.dispatchEvent(i)}else if(t.type==="event"){let{event:i,payload:r}=t,n=$L([i,this.props.ref],r);this.channel.push("event",n)}else t.type==="syncReply"?(this.pongCallbackQueue.push(this.syncCallbackQueue.shift()),this.channel.push("ping",{ref:this.props.ref})):t.type==="selectSecret"&&this.pushEvent("select_secret",{js_view_ref:this.props.ref,preselect_name:t.preselectName,options:t.options})}},getAssetsBaseUrl(){return Zm().then(t=>!t&&this.props.assetsCdnUrl?this.props.assetsCdnUrl:window.location.origin+this.props.assetsBasePath)},postMessage(t){this.iframe.contentWindow.postMessage(t,"*")},replicateDomEvent(t){if(t.type==="focus")return new FocusEvent("focus");if(t.type==="mousedown")return new MouseEvent("mousedown",{bubbles:!0});if(t.type==="keydown")return new KeyboardEvent(t.type,t.props)},handleInitTimeout(){this.initTimeoutContainer=document.createElement("div"),this.initTimeoutContainer.classList.add("info-box"),this.el.prepend(this.initTimeoutContainer),this.initTimeoutContainer.textContent=this.props.timeoutMessage},clearInitTimeout(){clearTimeout(this.initTimeout),this.initTimeoutContainer&&this.initTimeoutContainer.remove()},handleServerInit(t){this.clearInitTimeout(),this.initReceived=!0,this.childReadyPromise.then(()=>{this.postMessage({type:"init",data:t})})},handleServerEvent(t,e){this.initReceived&&this.childReadyPromise.then(()=>{this.postMessage({type:"event",event:t,payload:e})})},handleServerError(t,e){e&&this.clearInitTimeout(),this.errorContainer||(this.errorContainer=document.createElement("div"),this.errorContainer.classList.add("error-box","mb-4"),this.el.prepend(this.errorContainer)),this.errorContainer.textContent=t},handleServerPong(){this.pongCallbackQueue.shift()()},handleJSViewEvent(t){t.type==="sync"?(this.syncCallbackQueue.push(t.callback),this.postMessage({type:"sync"})):t.type=="secretSelected"&&this.postMessage({type:"secretSelected",secretName:t.secretName})},handleNavigationEvent(t){if(t.type==="element_focused"){let e=this.el.closest("[data-focusable-id]"),i=e?e.dataset.focusableId:null;this.iframe.toggleAttribute("data-js-focused",i===t.focusableId)}}};function Zm(){let t=window.LIVEBOOK_BASE_URL_PATH+"/public/health";return Zm.promise=Zm.promise||fetch(t).then(e=>e.status===200).catch(e=>!1),Zm.promise}var LL=Wre;var Bre={mounted(){this.props=this.getProps(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleDocumentKeyUp=this.handleDocumentKeyUp.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),window.addEventListener("keydown",this._handleDocumentKeyDown,!0),window.addEventListener("keyup",this._handleDocumentKeyUp,!0),window.addEventListener("focus",this._handleDocumentFocus,!0)},updated(){this.props=this.getProps()},destroyed(){window.removeEventListener("keydown",this._handleDocumentKeyDown,!0),window.removeEventListener("keyup",this._handleDocumentKeyUp,!0),window.removeEventListener("focus",this._handleDocumentFocus,!0)},getProps(){return ht(this.el,["cell-id","default-handlers","keydown-enabled","keyup-enabled","target"])},handleDocumentKeyDown(t){if(this.isKeyboardToggle(t)&&!Jo(document.activeElement)){yn(t),this.keyboardEnabled()?this.disableKeyboard():this.enableKeyboard();return}if(this.keyboardEnabled()){if(this.props.defaultHandlers!=="on"&&yn(t),t.repeat)return;if(this.props.keydownEnabled){let{key:e}=t;this.pushEventTo(this.props.target,"keydown",{key:e})}}},handleDocumentKeyUp(t){if(this.keyboardEnabled()&&(this.props.defaultHandlers!=="on"&&yn(t),this.props.keyupEnabled)){let{key:e}=t;this.pushEventTo(this.props.target,"keyup",{key:e})}},handleDocumentFocus(t){this.props.keydownEnabled&&Jo(t.target)&&this.disableKeyboard()},enableKeyboard(){this.keyboardEnabled()||this.pushEventTo(this.props.target,"enable_keyboard",{})},disableKeyboard(){this.keyboardEnabled()&&this.pushEventTo(this.props.target,"disable_keyboard",{})},keyboardEnabled(){return this.props.keydownEnabled||this.props.keyupEnabled},isKeyboardToggle(t){if(t.repeat)return!1;let{metaKey:e,ctrlKey:i,key:r}=t;return(XO()?e:i)&&r==="k"&&this.isCellFocused()?!this.keyboardEnabled()||["on","disable_only"].includes(this.props.defaultHandlers):!1},isCellFocused(){let t=this.el.closest("[data-el-session]");return t&&t.getAttribute("data-js-focused-id")===this.props.cellId}},IL=Bre;var Zre={mounted(){this.props=this.getProps(),this.templateEl=to(this.el,"[data-template]"),this.contentEl=to(this.el,"[data-content]"),this.markdown=new oa(this.contentEl,this.templateEl.textContent,{baseUrl:this.props.basePath,allowedUriSchemes:this.props.allowedUriSchemes})},updated(){this.props=this.getProps(),this.markdown.setContent(this.templateEl.textContent)},getProps(){return ht(this.el,["base-path","allowed-uri-schemes"])}},DL=Zre;var Vre={mounted(){this.scroll()},updated(){this.scroll()},scroll(){hf(this.el)}},NL=Vre;var ih=class{constructor(e=2e3){this.resetTimeout=e,this.buffer=[],this.resetTimeoutId=null}push(e){this.buffer.push(e),this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=setTimeout(()=>{this.reset()},this.resetTimeout)}reset(){this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=null,this.buffer=[]}tryMatch(e){if(e.length>this.buffer.length)return!1;let i=this.buffer.slice(-e.length),r=e.every((n,o)=>n===i[o]);return r&&this.reset(),r}};var Yre={mounted(){this.props=this.getProps(),this.focusedId=null,this.insertMode=!1,this.view=null,this.viewOptions=null,this.keyBuffer=new ih,this.lastLocationReportByClientId={},this.followedClientId=null,this.store=zl.create("session"),IO(this.faviconForEvaluationStatus(this.props.globalStatus)),this.updateSectionListHighlight(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleEditorEscape=this.handleEditorEscape.bind(this),this._handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),this._handleDocumentClick=this.handleDocumentClick.bind(this),document.addEventListener("keydown",this._handleDocumentKeyDown,!0),document.addEventListener("lb:editor_escape",this._handleEditorEscape),document.addEventListener("mousedown",this._handleDocumentMouseDown),document.addEventListener("focus",this._handleDocumentFocus,!0),document.addEventListener("click",this._handleDocumentClick),this.getElement("sections-list").addEventListener("click",t=>{this.handleSectionsListClick(t),this.handleCellIndicatorsClick(t)}),this.getElement("clients-list").addEventListener("click",t=>this.handleClientsListClick(t)),this.getElement("sections-list-toggle").addEventListener("click",t=>this.toggleSectionsList()),this.getElement("clients-list-toggle").addEventListener("click",t=>this.toggleClientsList()),this.getElement("secrets-list-toggle").addEventListener("click",t=>this.toggleSecretsList()),this.getElement("runtime-info-toggle").addEventListener("click",t=>this.toggleRuntimeInfo()),this.getElement("app-info-toggle").addEventListener("click",t=>this.toggleAppInfo()),this.getElement("files-list-toggle").addEventListener("click",t=>this.toggleFilesList()),this.getElement("notebook").addEventListener("scroll",t=>this.updateSectionListHighlight()),this.getElement("notebook-indicators").addEventListener("click",t=>this.handleCellIndicatorsClick(t)),this.getElement("views").addEventListener("click",t=>{this.handleViewsClick(t)}),this.getElement("section-toggle-collapse-all-button").addEventListener("click",t=>this.toggleCollapseAllSections()),this.initializeDragAndDrop(),window.addEventListener("phx:page-loading-stop",()=>{this.initializeFocus()},{once:!0}),this.handleEvent("session_init",({clients:t,client_id:e})=>{let i={};for(let r of t)i[r.id]=r;this.store.set("clients",i),this.store.set("clientId",e)}),this.handleEvent("cell_inserted",({cell_id:t})=>{this.handleCellInserted(t)}),this.handleEvent("cell_deleted",({cell_id:t,sibling_cell_id:e})=>{this.handleCellDeleted(t,e)}),this.handleEvent("cell_restored",({cell_id:t})=>{this.handleCellRestored(t)}),this.handleEvent("cell_moved",({cell_id:t})=>{this.handleCellMoved(t)}),this.handleEvent("section_inserted",({section_id:t})=>{this.handleSectionInserted(t)}),this.handleEvent("section_deleted",({section_id:t})=>{this.handleSectionDeleted(t)}),this.handleEvent("section_moved",({section_id:t})=>{this.handleSectionMoved(t)}),this.handleEvent("client_joined",({client:t})=>{this.handleClientJoined(t)}),this.handleEvent("client_left",({client_id:t})=>{this.handleClientLeft(t)}),this.handleEvent("clients_updated",({clients:t})=>{this.handleClientsUpdated(t)}),this.handleEvent("secret_selected",({select_secret_ref:t,secret_name:e})=>{this.handleSecretSelected(t,e)}),this.handleEvent("location_report",({client_id:t,focusable_id:e})=>{let i={focusableId:e};this.handleLocationReport(t,i)})},updated(){let t=this.props;this.props=this.getProps(),this.props.globalStatus!==t.globalStatus&&IO(this.faviconForEvaluationStatus(this.props.globalStatus))},disconnected(){this.el.removeAttribute("id"),this.keepChannel=!0},destroyed(){document.removeEventListener("keydown",this._handleDocumentKeyDown,!0),document.removeEventListener("lb:editor_scape",this._handleEditorEscape),document.removeEventListener("mousedown",this._handleDocumentMouseDown),document.removeEventListener("focus",this._handleDocumentFocus,!0),document.removeEventListener("click",this._handleDocumentClick),IO("favicon"),this.keepChannel||AL(),this.store.destroy()},getProps(){return ht(this.el,["autofocus-cell-id","global-status"])},faviconForEvaluationStatus(t){return t==="evaluating"?"favicon-evaluating":t==="stale"?"favicon-stale":t==="errored"?"favicon-errored":"favicon"},handleDocumentKeyDown(t){if(t.repeat)return;let e=XO()?t.metaKey:t.ctrlKey,i=t.altKey,r=t.shiftKey,n=t.key,o=this.keyBuffer;if(!(Jo(t.target)&&t.target.closest("[data-el-outputs-container]"))){if(e&&r&&!i&&n==="Enter"){yn(t),this.queueFullCellsEvaluation(!0);return}else if(!e&&r&&!i&&n==="Enter"){yn(t),sa(this.focusedCellType())&&this.queueFocusedCellEvaluation(),this.moveFocus(1);return}else if(e&&!i&&n==="Enter"){yn(t),sa(this.focusedCellType())&&this.queueFocusedCellEvaluation();return}else if(e&&n==="s"){yn(t),this.saveNotebook();return}else if(e||i)return}this.insertMode?(o.reset(),!t.target.closest("[data-el-editor-container]")&&n==="Escape"&&this.escapeInsertMode()):Jo(t.target)?(o.reset(),n==="Escape"&&t.target.blur()):(o.push(t.key),o.tryMatch(["d","d"])?this.deleteFocusedCell():o.tryMatch(["e","a"])?this.queueFullCellsEvaluation(!1):o.tryMatch(["e","e"])?sa(this.focusedCellType())&&this.queueFocusedCellEvaluation():o.tryMatch(["e","s"])?this.queueFocusedSectionEvaluation():o.tryMatch(["s","s"])?this.toggleSectionsList():o.tryMatch(["s","e"])?this.toggleSecretsList():o.tryMatch(["s","a"])?this.toggleAppInfo():o.tryMatch(["s","u"])?this.toggleClientsList():o.tryMatch(["s","f"])?this.toggleFilesList():o.tryMatch(["s","r"])?this.toggleRuntimeInfo():o.tryMatch(["s","b"])?this.showBin():o.tryMatch(["s","p"])?this.showPackageSearch():o.tryMatch(["e","x"])?this.cancelFocusedCellEvaluation():o.tryMatch(["0","0"])?this.reconnectRuntime():o.tryMatch(["Escape","Escape"])?this.setFocusedEl(null):o.tryMatch(["?"])?this.showShortcuts():o.tryMatch(["i"])||t.target.matches("body, [data-el-cell-body], [data-el-heading], [data-focusable-id]")&&this.focusedId&&n==="Enter"?(yn(t),this.isInsertModeAvailable()&&this.enterInsertMode()):o.tryMatch(["j"])?this.moveFocus(1):o.tryMatch(["k"])?this.moveFocus(-1):o.tryMatch(["J"])?this.moveFocusedCell(1):o.tryMatch(["K"])?this.moveFocusedCell(-1):o.tryMatch(["n"])?this.insertCellBelowFocused("code"):o.tryMatch(["N"])?this.insertCellAboveFocused("code"):o.tryMatch(["m"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellBelowFocused("markdown"):o.tryMatch(["M"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellAboveFocused("markdown"):o.tryMatch(["v","z"])?this.toggleView("code-zen"):o.tryMatch(["v","p"])?this.toggleView("presentation"):o.tryMatch(["v","c"])?this.toggleView("custom"):o.tryMatch(["c"])?(!this.view||this.viewOptions.showSection)&&this.toggleCollapseSection():o.tryMatch(["C"])&&(!this.view||this.viewOptions.showSection)&&this.toggleCollapseAllSections())},handleEditorEscape(){this.insertMode&&(this.keyBuffer.reset(),this.escapeInsertMode())},handleDocumentMouseDown(t){if(!t.target.closest("[data-el-notebook]")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest(".cm-tooltip")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest("[data-el-insert-buttons] button"))return;let e=t.target.closest("[data-focusable-id]"),i=e?e.dataset.focusableId:null,r=this.editableElementClicked(t,e);i!==this.focusedId&&this.setFocusedEl(i,{scroll:!1,focusElement:!1}),!t.target.closest("[data-el-actions]")&&this.insertMode!==r&&this.setInsertMode(r)},editableElementClicked(t,e){if(e){let i=t.target.closest("[data-el-editor-container], [data-el-heading]");return i&&e.contains(i)}return!1},handleDocumentFocus(t){let e=t.target.closest&&t.target.closest("[data-focusable-id]");if(e){let i=e.dataset.focusableId;i!==this.focusedId&&this.setFocusedEl(i,{scroll:!1,focusElement:!1})}},handleDocumentClick(t){t.target.closest("[data-el-enable-insert-mode-button]")&&this.setInsertMode(!0),t.target.closest("[data-btn-package-search]")&&this.insertMode&&this.setInsertMode(!1);let e=t.target.closest("[data-el-queue-cell-evaluation-button]");if(e){let r=e.getAttribute("data-cell-id"),n=e.hasAttribute("data-disable-dependencies-cache");this.queueCellEvaluation(r,n)}let i=window.location.hash;if(i){let r=i.replace(/^#/,"");!document.getElementById(r).contains(t.target)&&!t.target.closest("a")&&history.pushState(null,document.title,window.location.pathname+window.location.search)}},handleSectionsListClick(t){let e=t.target.closest("[data-el-sections-list-item]");if(e){let i=e.getAttribute("data-section-id");this.getSectionById(i).scrollIntoView({behavior:"smooth",block:"start"})}},handleClientsListClick(t){let e=t.target.closest("[data-el-clients-list-item]");if(e){let i=e.getAttribute("data-client-id");t.target.closest("[data-el-client-link]")&&this.handleClientLinkClick(i),t.target.closest("[data-el-client-follow-toggle]")&&this.handleClientFollowToggleClick(i,e)}},handleClientLinkClick(t){this.mirrorClientFocus(t)},handleClientFollowToggleClick(t,e){let i=this.el.querySelector("[data-el-clients-list-item][data-js-followed]");i&&i.removeAttribute("data-js-followed"),t===this.followedClientId?this.followedClientId=null:(e.setAttribute("data-js-followed",""),this.followedClientId=t,this.mirrorClientFocus(t))},mirrorClientFocus(t){let e=this.lastLocationReportByClientId[t];e&&e.focusableId&&this.setFocusedEl(e.focusableId)},handleCellIndicatorsClick(t){let e=t.target.closest("[data-el-focus-cell-button]");if(e){let i=e.getAttribute("data-target");this.setFocusedEl(i)}},initializeFocus(){let t=window.location.hash;if(t){let e=t.replace(/^#/,""),i=document.getElementById(e);if(i){let r=i.closest("[data-focusable-id]");r?this.setFocusedEl(r.dataset.focusableId):i.scrollIntoView()}}else this.props.autofocusCellId&&(this.setFocusedEl(this.props.autofocusCellId,{scroll:!1}),this.setInsertMode(!0))},updateSectionListHighlight(){let t=this.el.querySelector("[data-el-sections-list-item][data-js-is-viewed]");t&&t.removeAttribute("data-js-is-viewed");let e=this.getSections().reverse().find(i=>{let{top:r}=i.getBoundingClientRect(),n=document.documentElement.scrollTop;return r<=n+window.innerHeight*.35});if(e){let i=e.getAttribute("data-section-id");this.el.querySelector(`[data-el-sections-list-item][data-section-id="${i}"]`).setAttribute("data-js-is-viewed","")}},initializeDragAndDrop(){let t=!1,e=null,i=null,r=(o=null)=>{if(!t){t=!0,e=o;let s=o?"internal":"external";this.el.setAttribute("data-js-dragging",s),s==="external"&&this.toggleFilesList(!0)}},n=()=>{t&&(t=!1,this.el.removeAttribute("data-js-dragging"))};this.el.addEventListener("dragstart",o=>{r(o.target)}),this.el.addEventListener("dragenter",o=>{r()}),this.el.addEventListener("dragleave",o=>{PX()||this.el.contains(o.relatedTarget)||n()}),this.el.addEventListener("dragover",o=>{o.stopPropagation(),o.preventDefault()}),this.el.addEventListener("drop",o=>{o.stopPropagation(),o.preventDefault();let s=o.target.closest("[data-el-insert-drop-area]"),a=o.target.closest("[data-el-files-drop-area]");if(s){let l=s.getAttribute("data-section-id")||null,c=s.getAttribute("data-cell-id")||null;if(o.dataTransfer.files.length>0)i=o.dataTransfer.files,this.pushEvent("handle_file_drop",{section_id:l,cell_id:c});else if(e&&e.matches("[data-el-file-entry]")){let u=e.getAttribute("data-name");this.pushEvent("insert_file",{file_entry_name:u,section_id:l,cell_id:c})}}else a&&o.dataTransfer.files.length>0&&(i=o.dataTransfer.files,this.pushEvent("handle_file_drop",{}));n()}),this.handleEvent("finish_file_drop",o=>{let s=document.querySelector('#add-file-entry-modal input[type="file"]');s&&(s.files=i,s.dispatchEvent(new Event("change",{bubbles:!0})))})},toggleSectionsList(t=null){this.toggleSidePanelContent("sections-list",t)},toggleClientsList(t=null){this.toggleSidePanelContent("clients-list",t)},toggleSecretsList(t=null){this.toggleSidePanelContent("secrets-list",t)},toggleAppInfo(t=null){this.toggleSidePanelContent("app-info",t)},toggleFilesList(t=null){this.toggleSidePanelContent("files-list",t)},toggleRuntimeInfo(t=null){this.toggleSidePanelContent("runtime-info",t)},toggleSidePanelContent(t,e=null){(e===null?this.el.getAttribute("data-js-side-panel-content")!==t:e)?this.el.setAttribute("data-js-side-panel-content",t):this.el.removeAttribute("data-js-side-panel-content")},showBin(){let t=this.el.querySelector("[data-btn-show-bin]");t&&t.click()},showPackageSearch(){this.setFocusedEl("setup");let t=this.el.querySelector("[data-btn-package-search]");t&&t.click()},saveNotebook(){this.pushEvent("save",{})},deleteFocusedCell(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("delete_cell",{cell_id:this.focusedId})},queueCellEvaluation(t,e){this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:t,disable_dependencies_cache:e})})},queueFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:this.focusedId})})},queueFullCellsEvaluation(t){let e=t&&this.focusedId&&this.isCell(this.focusedId)?[this.focusedId]:[];this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_full_evaluation",{forced_cell_ids:e})})},queueFocusedSectionEvaluation(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);t&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_section_evaluation",{section_id:t})})}},dispatchQueueEvaluation(t){sa(this.focusedCellType())?ti.broadcast(`cells:${this.focusedId}`,{type:"dispatch_queue_evaluation",dispatch:t}):t()},cancelFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("cancel_cell_evaluation",{cell_id:this.focusedId})},reconnectRuntime(){this.pushEvent("reconnect_runtime",{})},showShortcuts(){let t=this.el.querySelector("[data-btn-show-shortcuts]");t&&t.click()},isInsertModeAvailable(){if(!this.focusedId)return!1;let t=this.getFocusableEl(this.focusedId);return!this.isCell(this.focusedId)||!t.hasAttribute("data-js-insert-mode-disabled")},enterInsertMode(){this.focusedId&&this.setInsertMode(!0)},escapeInsertMode(){this.setInsertMode(!1)},moveFocus(t){let e=this.nearbyFocusableId(this.focusedId,t);this.setFocusedEl(e)},moveFocusedCell(t){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("move_cell",{cell_id:this.focusedId,offset:t})},insertCellBelowFocused(t){if(this.focusedId)this.insertCellBelowFocusableId(this.focusedId,t);else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[e.length-1],t)}},insertCellAboveFocused(t){if(this.focusedId){let e=this.nearbyFocusableId(this.focusedId,-1);this.insertCellBelowFocusableId(e,t)}else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[0],t)}},insertCellBelowFocusableId(t,e){if(this.isCell(t))this.pushEvent("insert_cell_below",{type:e,cell_id:t});else if(this.isSection(t))this.pushEvent("insert_cell_below",{type:e,section_id:t});else if(this.isNotebook(t)){let i=this.getSectionIds();i.length>0&&this.pushEvent("insert_cell_below",{type:e,section_id:i[0]})}},setFocusedEl(t,{scroll:e=!0,focusElement:i=!0}={}){if(this.focusedId=t,t?this.el.setAttribute("data-js-focused-id",t):this.el.removeAttribute("data-js-focused-id"),t){if(!this.isSection(t)){let n=this.getSectionIdByFocusableId(t);n&&this.getSectionById(n).removeAttribute("data-js-collapsed")}let r=this.getFocusableEl(t);i&&(r.querySelector("[data-el-cell-body]")||r.querySelector("[data-el-heading]")||r).focus({preventScroll:!0})}ti.broadcast("navigation",{type:"element_focused",focusableId:t,scroll:e}),this.setInsertMode(!1),this.sendLocationReport({focusableId:t})},setInsertMode(t){this.insertMode=t,t?this.el.setAttribute("data-js-insert-mode",""):this.el.removeAttribute("data-js-insert-mode"),ti.broadcast("navigation",{type:"insert_mode_changed",enabled:t})},handleViewsClick(t){let e=t.target.closest("[data-el-view-toggle]");if(e){let i=e.getAttribute("data-el-view-toggle");this.toggleView(i)}},toggleView(t){t===this.view?(this.unsetView(),t==="custom"&&this.customViewSettingsSubscription.destroy()):t==="code-zen"?this.setView(t,{showSection:!1,showMarkdown:!1,showOutput:!0,spotlight:!1}):t==="presentation"?this.setView(t,{showSection:!0,showMarkdown:!0,showOutput:!0,spotlight:!0}):t==="custom"&&(this.customViewSettingsSubscription=xt.getAndSubscribe(i=>{this.setView(t,{showSection:i.custom_view_show_section,showMarkdown:i.custom_view_show_markdown,showOutput:i.custom_view_show_output,spotlight:i.custom_view_spotlight})}),this.pushEvent("open_custom_view_settings"));let e=this.focusedId||this.nearbyFocusableId(null,0);if(e){let i=this.ensureVisibleFocusableEl(e);i!==this.focused&&this.setFocusedEl(i,{scroll:!1}),i&&this.getFocusableEl(i).scrollIntoView({block:"center"})}},setView(t,e){this.view=t,this.viewOptions=e,this.el.setAttribute("data-js-view",t),this.el.toggleAttribute("data-js-hide-section",!e.showSection),this.el.toggleAttribute("data-js-hide-markdown",!e.showMarkdown),this.el.toggleAttribute("data-js-hide-output",!e.showOutput),this.el.toggleAttribute("data-js-spotlight",e.spotlight)},unsetView(){this.view=null,this.viewOptions=null,this.el.removeAttribute("data-js-view"),this.el.removeAttribute("data-js-hide-section"),this.el.removeAttribute("data-js-hide-markdown"),this.el.removeAttribute("data-js-hide-output"),this.el.removeAttribute("data-js-spotlight")},toggleCollapseSection(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);if(t){let e=this.getSectionById(t);e.hasAttribute("data-js-collapsed")?e.removeAttribute("data-js-collapsed"):(e.setAttribute("data-js-collapsed",""),this.setFocusedEl(t,{scroll:!0}))}}},toggleCollapseAllSections(){let t=this.getSections().every(e=>e.hasAttribute("data-js-collapsed"));if(this.getSections().forEach(e=>{e.toggleAttribute("data-js-collapsed",!t)}),this.focusedId){let e=this.getSectionIdByFocusableId(this.focusedId);e&&this.setFocusedEl(e,{scroll:!0})}},handleCellInserted(t){this.setFocusedEl(t),LX(this.focusedCellType())&&this.setInsertMode(!0)},handleCellDeleted(t,e){if(this.focusedId===t)if(this.view){let i=this.ensureVisibleFocusableEl(e);this.setFocusedEl(i)}else this.setFocusedEl(e)},handleCellRestored(t){this.setFocusedEl(t)},handleCellMoved(t){this.repositionJSViews(),this.focusedId===t&&ti.broadcast("cells",{type:"cell_moved",cellId:t})},handleSectionInserted(t){let i=this.getSectionById(t).querySelector("[data-el-section-headline]"),{focusableId:r}=i.dataset;this.setFocusedEl(r),this.setInsertMode(!0),bX(document.activeElement)},handleSectionDeleted(t){this.focusedId&&!this.getFocusableEl(this.focusedId)&&this.setFocusedEl(null)},handleSectionMoved(t){this.repositionJSViews();let e=this.getSectionById(t);na(e)},handleClientJoined(t){let e=this.store.get("clients");this.store.set("clients",Ce(H({},e),{[t.id]:t}))},handleClientLeft(t){let e=this.store.get("clients"),i=e[t];if(i){let[,r]=NO(e,t);this.store.set("clients",r),i.id===this.followedClientId&&(this.followedClientId=null)}},handleClientsUpdated(t){let e=this.store.get("clients"),i=H({},e);for(let r of t)i[r.id]=r;this.store.set("clients",i)},handleSecretSelected(t,e){ti.broadcast(`js_views:${t}`,{type:"secretSelected",secretName:e})},handleLocationReport(t,e){let i=this.store.get("clients")[t];this.lastLocationReportByClientId[t]=e,i&&i.id===this.followedClientId&&e.focusableId!==this.focusedId&&this.setFocusedEl(e.focusableId)},repositionJSViews(){ti.broadcast("js_views",{type:"reposition"})},sendLocationReport(t){Object.keys(this.store.get("clients")).length>1&&this.pushEvent("location_report",{focusable_id:t.focusableId})},focusedCellType(){return this.focusedId&&this.isCell(this.focusedId)?this.getFocusableEl(this.focusedId).getAttribute("data-type"):null},nearbyFocusableId(t,e){let i=this.getFocusableIds();if(i.length===0)return null;let r=i.indexOf(t);if(r===-1){let n=this.getFocusableEls().find(Jv);return n?n.getAttribute("data-focusable-id"):i[0]}else{let n=mX(r+e,0,i.length-1);return i[n]}},ensureVisibleFocusableEl(t){let e=this.getFocusableEl(t),i=Array.from(this.el.querySelectorAll("[data-focusable-id]")),r=i.indexOf(e),n=[...i.slice(r,-1),...i.slice(0,r).reverse()].find(o=>!bn(o));return n&&n.getAttribute("data-focusable-id")},isCell(t){return this.getFocusableEl(t).hasAttribute("data-el-cell")},isSection(t){return this.getFocusableEl(t).hasAttribute("data-el-section-headline")},isNotebook(t){return this.getFocusableEl(t).hasAttribute("data-el-notebook-headline")},getFocusableEl(t){return this.el.querySelector(`[data-focusable-id="${t}"]`)},getFocusableEls(){return Array.from(this.el.querySelectorAll("[data-focusable-id]")).filter(t=>!bn(t))},getFocusableIds(){return this.getFocusableEls().map(t=>t.getAttribute("data-focusable-id"))},getSectionIdByFocusableId(t){let i=this.getFocusableEl(t).closest("[data-el-section]");return i&&i.getAttribute("data-section-id")},getSectionIds(){return this.getSections().map(e=>e.getAttribute("data-section-id"))},getSections(){return Array.from(this.el.querySelectorAll("[data-el-section]"))},getSectionById(t){return this.el.querySelector(`[data-el-section][data-section-id="${t}"]`)},getElement(t){return this.el.querySelector(`[data-el-${t}]`)}},ML=Yre;var Fre={mounted(){this.autosize(),this.el.addEventListener("input",t=>{this.autosize()})},updated(){this.autosize()},autosize(){this.el.style.height="0px",this.el.style.height=`${this.el.scrollHeight+2}px`}},UL=Fre;var Hre=100,Gre={mounted(){this.props=this.getProps(),this.interval=setInterval(()=>this.updateDOM(),Hre)},updated(){this.props=this.getProps(),this.updateDOM()},destroyed(){clearInterval(this.interval)},getProps(){return ht(this.el,["start"])},updateDOM(){let e=(Date.now()-new Date(this.props.start))/1e3;this.el.innerHTML=`${e.toFixed(1)}s`}},zL=Gre;var jL="lb_user_data";function qL(t){let e=JSON.stringify(t),i=xX(e);Jre(jL,i,15768e4)}function WL(){let t=Kre(jL);if(t){let e=vX(t);return JSON.parse(e)}else return null}function Kre(t){let e=document.cookie.split("; ").find(i=>i.startsWith(`${t}=`));return e?e.replace(`${t}=`,""):null}function Jre(t,e,i){let r=`${t}=${e};max-age=${i};path=/${DO()}`;document.cookie=r}var ene={mounted(){this.el.addEventListener("submit",t=>{let e=this.el.user_form_name.value,i=this.el.user_form_hex_color.value;qL({name:e,hex_color:i})})}},BL=ene;var tne={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.datetimeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return ht(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.datetimeUtcToLocal(this.props.utcValue),this.el.min=this.datetimeUtcToLocal(this.props.utcMin),this.el.max=this.datetimeUtcToLocal(this.props.utcMax)},datetimeUtcToLocal(t){if(!t)return null;let e=new Date(t+"Z"),i=e.getFullYear().toString(),r=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0"),a=e.getSeconds().toString().padStart(2,"0");return`${i}-${r}-${n}T${o}:${s}:${a}`},datetimeLocalToUtc(t){if(!t)return null;let e=new Date(t),i=e.getUTCFullYear().toString(),r=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),o=e.getUTCHours().toString().padStart(2,"0"),s=e.getUTCMinutes().toString().padStart(2,"0"),a=e.getUTCSeconds().toString().padStart(2,"0");return`${i}-${r}-${n}T${o}:${s}:${a}`}},ZL=tne;var ine={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.timeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return ht(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.timeUtcToLocal(this.props.utcValue),this.el.min=this.timeUtcToLocal(this.props.utcMin),this.el.max=this.timeUtcToLocal(this.props.utcMax)},timeUtcToLocal(t){if(!t)return null;let e=new Date;e.setUTCHours(...t.split(":"));let i=e.getHours().toString().padStart(2,"0"),r=e.getMinutes().toString().padStart(2,"0"),n=e.getSeconds().toString().padStart(2,"0");return`${i}:${r}:${n}`},timeLocalToUtc(t){if(!t)return null;let e=new Date;e.setHours(...t.split(":"));let i=e.getUTCHours().toString().padStart(2,"0"),r=e.getUTCMinutes().toString().padStart(2,"0"),n=e.getUTCSeconds().toString().padStart(2,"0");return`${i}:${r}:${n}`}},VL=ine;var HL=va(FL());var rne={mounted(){this.props=this.getProps(),this.lineHeight=gX(this.el),this.templateEl=to(this.el,"[data-template]"),this.contentEl=to(this.el,"[data-content]"),this.capLines();let t=this.hyperListConfig();this.virtualizedList=new HL.default(this.contentEl,t),this.props.follow&&hf(this.contentEl)},updated(){this.props=this.getProps(),this.capLines();let t=this.props.follow&&yX(this.contentEl),e=this.hyperListConfig();this.virtualizedList.refresh(this.contentEl,e),t&&hf(this.contentEl)},getProps(){return ht(this.el,["max-height","follow","max-lines","ignore-trailing-empty-line"])},hyperListConfig(){let t=this.getLineElements(),e=t.length,i=Math.min(this.props.maxHeight,this.lineHeight*e);return{height:i,total:e,itemHeight:this.lineHeight,generate:r=>{let n=t[r].cloneNode(!0);return n.removeAttribute("id"),n},afterRender:()=>{this.contentEl.scrollWidth>this.contentEl.clientWidth?this.contentEl.style.height=`${i+12}px`:this.contentEl.style.height=`${i}px`}}},getLineElements(){let t=Array.from(this.templateEl.querySelectorAll("[data-line]"));if(t.length===0)return[];let e=t[t.length-1];return this.props.ignoreTrailingEmptyLine&&e.innerText===""?t.slice(0,-1):t},capLines(){if(this.props.maxLines){let e=Array.from(this.templateEl.querySelectorAll("[data-line]")).slice(0,-this.props.maxLines),[i,...r]=e;r.forEach(n=>n.remove()),i&&(i.innerHTML="...")}}},GL=rne;var nne={mounted(){let t=xt.get(),e=this.el.querySelector('[name="show_section"][value="true"]'),i=this.el.querySelector('[name="show_markdown"][value="true"]'),r=this.el.querySelector('[name="show_output"][value="true"]'),n=this.el.querySelector('[name="spotlight"][value="true"]');e.checked=t.custom_view_show_section,i.checked=t.custom_view_show_markdown,r.checked=t.custom_view_show_output,n.checked=t.custom_view_spotlight,e.addEventListener("change",o=>{xt.update({custom_view_show_section:o.target.checked})}),i.addEventListener("change",o=>{xt.update({custom_view_show_markdown:o.target.checked})}),r.addEventListener("change",o=>{xt.update({custom_view_show_output:o.target.checked})}),n.addEventListener("change",o=>{xt.update({custom_view_spotlight:o.target.checked})})}},KL=nne;var JL={AppAuth:yS,AudioInput:kS,Cell:IX,CellEditor:IR,Dropzone:DR,EditorSettings:NR,EmojiPicker:kL,FocusOnUpdate:SL,Headline:EL,Highlight:CL,ImageInput:PL,ImageOutput:_L,JSView:LL,KeyboardControl:IL,MarkdownRenderer:DL,ScrollOnUpdate:NL,Session:ML,TextareaAutosize:UL,Timer:zL,UserForm:BL,UtcDateTimeInput:ZL,UtcTimeInput:VL,VirtualizedLines:GL,CustomViewSettings:KL};var eI={onBeforeElUpdated(t,e){for(let i of t.attributes)i.name.startsWith("data-js-")&&e.setAttribute(i.name,i.value),i.name==="data-keep-attribute"&&(t.hasAttribute(i.value)?e.setAttribute(i.value,t.getAttribute(i.value)):e.removeAttribute(i.value))},onNodeAdded(t){if(t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("autofocus")&&(t.focus(),t.setSelectionRange&&t.value)){let e=t.value.length;t.setSelectionRange(e,e)}}};var Ym=va(iI());function rI(){Ym.default.config({barColors:{0:"#b2c1ff"},shadowColor:"rgba(0, 0, 0, .3)"}),window.addEventListener("phx:page-loading-start",()=>{Ym.default.show(500)}),window.addEventListener("phx:page-loading-stop",()=>{Ym.default.hide()})}function nI(){window.addEventListener("lb:focus",t=>{requestAnimationFrame(()=>{t.target.focus()})}),window.addEventListener("lb:set_value",t=>{t.target.value=t.detail.value}),window.addEventListener("lb:check",t=>{t.target.checked=!0}),window.addEventListener("lb:uncheck",t=>{t.target.checked=!1}),window.addEventListener("lb:set_text",t=>{t.target.textContent=t.detail.value}),window.addEventListener("lb:clipcopy",t=>{"clipboard"in navigator?t.detail.content?navigator.clipboard.writeText(t.detail.content):t.target.tagName==="INPUT"?navigator.clipboard.writeText(t.target.value):navigator.clipboard.writeText(t.target.textContent):alert(`Sorry, your browser does not support clipboard copy. This generally requires a secure origin \u2014 either HTTPS or localhost.`)}),window.addEventListener("lb:scroll_into_view",t=>{OX(t.target).then(()=>{zO(t.target,{scrollMode:"if-needed",behavior:"smooth",block:"nearest",inline:"nearest"})})}),window.addEventListener("phx:lb:exec_js",t=>{let e=t.detail.to||"body";document.querySelectorAll(e).forEach(i=>{window.liveSocket.execJS(i,t.detail.js)})}),window.addEventListener("lb:session_list:on_selection_change",()=>{let t=!!document.querySelector("[name='session_ids[]']:checked"),e=document.querySelector("#edit-sessions [name='disconnect']"),i=document.querySelector("#edit-sessions [name='close_all']");e.parentElement.classList.toggle("pointer-events-none",!t),e.parentElement.classList.toggle("opacity-50",!t),i.parentElement.classList.toggle("pointer-events-none",!t),i.parentElement.classList.toggle("opacity-50",!t)}),window.addEventListener("contextmenu",t=>{let e=t.target.closest("[data-contextmenu-trigger-click]");e&&(t.preventDefault(),e.dispatchEvent(new Event("mousedown",{bubbles:!0})),e.dispatchEvent(new Event("click",{bubbles:!0})))}),window.addEventListener("submit",t=>{t.target.hasAttribute("phx-nosubmit")&&(t.preventDefault(),t.stopPropagation())},{capture:!0})}function oI(){let t=/AppleWebKit/.test(navigator.userAgent),e="ontouchstart"in window||navigator.maxTouchPoints>0;if(t&&e){let i=document.querySelector("meta[name='viewport']");i&&(i.content+=", maximum-scale=1.0")}}var tk="confirm-opted-out-ids";function sI(){return Os(tk)||[]}function aI(){window.addEventListener("phx:add_confirm_opt_out_id",t=>{let e=Os(tk)||[],i=t.detail.opt_out_id;e.push(i),Ca(tk,e)})}function one(){let t=document.querySelector("meta[name='csrf-token']").getAttribute("content"),e=new pS(window.LIVEBOOK_BASE_URL_PATH+"/live",uh,{params:i=>({_csrf_token:t,user_data:WL(),app_auth_token:bS(),confirm_opt_out_ids:sI()}),hooks:JL,dom:eI});rI(),nI(),aI(),oI(),xt.getAndSubscribe(i=>{document.body.setAttribute("data-editor-theme",i.editor_theme)}),e.connect(),window.liveSocket=e}if(sne())one();else{let t=document.createElement("div");t.innerHTML=`