diff --git a/app/templates/base.html b/app/templates/base.html index cd9656b..37f6c13 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -13,6 +13,8 @@ {%- endif -%} + + {%- include 'common/topnav.html' -%} {%- with messages = get_flashed_messages(with_categories=true) -%} {%- if messages -%} @@ -23,6 +25,7 @@ {%- endwith -%} {%- block content -%}{%- endblock -%} {%- include 'common/footer.html' -%} + diff --git a/app/templates/common/macros.html b/app/templates/common/macros.html index d3b92a0..943d708 100644 --- a/app/templates/common/macros.html +++ b/app/templates/common/macros.html @@ -73,10 +73,10 @@ {%- endmacro %} {% macro tabs(prefix='', labels = []) -%} -
+
{%- for tab_label in labels -%} - + {%- endfor -%}
{%- for tab_label in labels -%} @@ -97,16 +97,16 @@ {%- call(idx) tabs(prefix='babycode', labels=['Write', 'Preview']) -%} {%- if idx == 0 -%} - - - - - - - - - - + + + + + + + + + + {# stub: char count #} @@ -183,12 +183,12 @@ Edit {%- endif -%} {%- if can_reply -%} - + {%- endif -%} {%- if can_delete -%} Delete {%- endif -%} - + {%- endif -%}
@@ -213,10 +213,10 @@ {% set reactors_str = reactors_str + '\n...and many others' %} {% endif %} {% set has_reacted = get_active_user() is not none and get_active_user().username in reactors %} - + {%- endfor -%} - {%- if is_logged_in() and allow_reacting -%}{%- endif -%} + {%- if is_logged_in() and allow_reacting -%}{%- endif -%} {%- elif is_editing -%} Cancel diff --git a/data/static/css/style.css b/data/static/css/style.css index 0d15829..56e5fa5 100644 --- a/data/static/css/style.css +++ b/data/static/css/style.css @@ -905,6 +905,9 @@ ol.sortable-list { } } +.js-only { + display: none; +} @media (max-width: 768px) { body { diff --git a/data/static/js/bits/progressive-enhancement.js b/data/static/js/bits/progressive-enhancement.js new file mode 100644 index 0000000..a1e4cfe --- /dev/null +++ b/data/static/js/bits/progressive-enhancement.js @@ -0,0 +1,17 @@ +export const b = { + init: 'enhance', +} + +export function enhance(_, __, el) { + console.log(el); + if (el.classList.contains('js-only')) { + el.classList.remove('js-only'); + } + + if (el.disabled) { + el.disabled = false; + if (el.title.search('JavaScript') !== -1) { + el.title = ''; + } + } +} diff --git a/data/static/js/bits/ui.js b/data/static/js/bits/ui.js new file mode 100644 index 0000000..2484db1 --- /dev/null +++ b/data/static/js/bits/ui.js @@ -0,0 +1,25 @@ +export const b = {} + +export function setTab(_, sender, el) { + if (sender.ariaSelected === 'true') { + return; + } + if (!el.contains(sender)) { + return; + } + const tabIndex = parseInt(sender.dataset.tabIndex); + const tabPanels = el.querySelectorAll('.tab-content'); + const tabButtons = el.querySelectorAll('.tab-bar button'); + + for (let i = 0; i < tabPanels.length; i++) { + const tabPanel = tabPanels[i]; + const tabButton = tabButtons[i]; + if (i === tabIndex) { + tabPanel.classList.remove('hidden'); + tabButton.ariaSelected = 'true'; + } else if (!tabPanel.classList.contains('hidden')) { + tabPanel.classList.add('hidden'); + tabButton.ariaSelected = 'false'; + } + } +} diff --git a/data/static/js/vnd/bitty-8.0.0.js b/data/static/js/vnd/bitty-8.0.0.js new file mode 100644 index 0000000..85c4615 --- /dev/null +++ b/data/static/js/vnd/bitty-8.0.0.js @@ -0,0 +1 @@ +const t=["checkbox","color","date","datetime-local","file","form","option","radio","search","time"],e=["email","month","number","password","search","tel","text","url","week"],s=["range","search","number"],n="bitty_store";class r extends HTMLElement{static bits=[];constructor(){super()}async connectedCallback(){if(this.dataset.connect){const t=this.dataset.connect.trim(),s=await import(t);void 0!==s.b&&(s.b._trueValues=["true","yes","on","1"],s.b._falseValues=["false","no","off","0"],s.b._debouncers={},s.b._marks={},s.b.svgs={},void 0===s.b.templates&&(s.b.templates={}),void 0===s.b.config&&(s.b.config={}),void 0===s.b.config.getState&&(s.b.config.getState={attributes:["aria-autoComplete","aria-checked","aria-disabled","aria-expended","aria-hidden","aria-pressed","aria-read-only","aria-selected","aria-value-now","aria-value-text"],keys:["checked","diabled","hidden","readOnly","selected","spellcheck","value"]}),this.addToggleSwitchTemplate(s),s.b.data={},this.loadPageAssets(s),this.addBittyClasses(s),this.constructor.bits.push(s),window.addEventListener("bittyforwardsender",t=>{s.b._processBittyForwardSender(t)}),window.addEventListener("bittysend",t=>{s.b._processBittySend(t)}),window.addEventListener("bittytrigger",t=>{s.b._processBittyTrigger(t)}),window.addEventListener("click",t=>{s.b._processEvent(t)}),window.addEventListener("input",t=>{s.b._processInputEvent(t)}),window.addEventListener("change",t=>{s.b._processChangeEvent(t)}),document.addEventListener("submit",t=>{s.b._processEvent(t)}),document.addEventListener("keydown",t=>{if(13===t.keyCode&&t.target&&t.target.tagName&&"input"===t.target.tagName.toLowerCase()){const n=t.target.getAttribute("type");e.includes(n.toLowerCase())&&s.b._processInputTextEnter(t)}}),[...document.querySelectorAll("[data-listen]")].forEach(t=>{s.b._splitSignalString(t.dataset.listen).forEach(t=>{!1===["bittysend","bittytrigger","change","click","input","submit"].includes(t)&&window.addEventListener(t,t=>{s.b._processEvent(t)})})}),s.b._processInit())}}addBittyClasses(t){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(t=>"_"===t.substring(0,1)).forEach(e=>{t.b[e.substring(1)]=this[e].bind(t)})}_addListener(t,e){window.addEventListener(t,t=>{this.b._processCustomEvent(t,e)})}_addStyles(t){const e=new CSSStyleSheet;return e.replaceSync(t),document.adoptedStyleSheets.push(e),e}addToggleSwitchTemplate(t){t.b.templates.switch='\n'}_ce(t,e={}){return document.createElement(t,e)}async _copy(t){const e=document.querySelector(t);if(void 0!==e.value&&""!==e.value)try{await navigator.clipboard.writeText(e.value)}catch(e){return console.error(`Could not copy .value from ${t}`),!1}else try{await navigator.clipboard.writeText(e.innerText)}catch(e){return console.error(`Could not copy .innerHTML from ${t}`),!1}return!0}_debounce(t,e,s,n={}){this.b._debouncers[t]&&window.clearTimeout(this.b._debouncers[t]),this.b._debouncers[t]=setTimeout(()=>{this.b.send.apply(this,[n,e])},s)}_dedupe(t){return[...new Set(t)]}async _deletePageData(t){const e=await this.b._initPageDB();return new Promise((s,r)=>{const i=e.transaction(n,"readwrite").objectStore(n).delete(t);i.onsuccess=()=>s(i.result),i.onerror=()=>r(i.result)})}async _deleteSiteData(t){const e=await this.b._initSiteDB();return new Promise((s,r)=>{const i=e.transaction(n,"readwrite").objectStore(n).delete(t);i.onsuccess=()=>s(i.result),i.onerror=()=>r(i.result)})}async __deleteValueFromSiteDB(t){const e=await this.b._initSiteDB();return new Promise((s,r)=>{const i=e.transaction(n,"readwrite").objectStore(n).delete(t);i.onsuccess=()=>s(i.result),i.onerror=()=>r(i.result)})}__findSenders(t){const e=[];for(;t;)void 0!==t.dataset&&void 0!==t.dataset.s&&e.push(t),t=t.parentElement;return e}_forwardSender(t,e){const s=new i(t,e);dispatchEvent(s)}async _getData(t,e=void 0,s={}){let n=await fetch(t,s);try{if(!0===n.ok)try{return await n.json()}catch(t){console.error(t)}else console.error(n)}catch(t){console.error(t)}}_getMarks(t){return this.b._marks[t]}async _getTemplates(t,e={}){let s=await fetch(t,e);try{if(!0===s.ok)try{const t=await s.text(),e=document.createElement("div");return e.innerHTML=t,e.querySelectorAll("script").forEach(t=>{"text/html"===t.type&&void 0!==t.dataset.template&&(this.b.templates[t.dataset.template]=t.innerHTML.trim()),"image/svg"===t.type&&void 0!==t.dataset.template&&(this.b.svgs[t.dataset.template]=t.innerHTML.trim()),"application/json"===t.type&&void 0!==t.dataset.template&&(this.b.data[t.dataset.template]=JSON.parse(t.innerHTML.trim()))}),!0}catch(t){return console.error(t),!1}}catch(t){return console.error(t),!1}}__getBool(t){if(void 0===t)return;if(null===t)return;const e=parseInt(t,10);if(NaN!==e&&e>0)return!0;if(NaN!==e&&e<=0)return!1;const s=t.toLowerCase();return!!this.b._trueValues.includes(s)||!this.b._falseValues.includes(s)&&void 0}_getState(){return[...this.b.qsa("[data-save][id]")].filter(t=>"true"===t.dataset.save).map(t=>{const e={id:t.id,attributes:{},keys:{}};for(const s of this.b.config.getState.attributes)t.getAttribute(s)&&(e.attributes[s]=t.getAttribute(s));for(const s of this.b.config.getState.keys)t[s]&&(e.keys[s]=t[s]);return e})}async __initPageDB(){const t=new URL(window.location.href),e=btoa(t.pathname);return new Promise((t,s)=>{const r=indexedDB.open(`bitty_page_db_${e}`,1);r.onsuccess=()=>t(r.result),r.onerror=()=>s(r.result),r.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(n)||e.createObjectStore(n)}})}async __initSiteDB(){return new Promise((t,e)=>{const s=indexedDB.open("bitty_site_db",1);s.onsuccess=()=>t(s.result),s.onerror=()=>e(s.result),s.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(n)||e.createObjectStore(n)}})}loadPageAssets(t){document.querySelectorAll("script").forEach(e=>{"text/html"===e.type&&void 0!==e.dataset.template&&(t.b.templates[e.dataset.template]=e.innerHTML.trim()),"image/svg"===e.type&&void 0!==e.dataset.template&&(t.b.svgs[e.dataset.template]=e.innerHTML.trim()),"application/json"===e.type&&void 0!==e.dataset.template&&(t.b.data[e.dataset.template]=JSON.parse(e.innerHTML.trim()))})}_mapKey(t,e,s=[],n={}){const r="string"==typeof t?null:t;null===s&&(s=[]),void 0===n.preventDefault&&(n.preventDefault=!1),void 0===n.listener&&(n.listener="keydown");for(let t=0;t{if(n.key===t||n.keyCode===r){for(const t of s)if(!1===n[t])return;n.preventDefault(),this.b._processKeypress(n,e)}}):window.addEventListener(n.listener,n=>{if(n.key===t||n.keyCode===r){for(const t of s)if(!1===n[t])return;this.b._processKeypress(n,e)}})}_mark(t){try{this.b._marks[t].push(performance.now())}catch(e){this.b._marks[t]=[],this.b._marks[t].push(performance.now())}}__markEventAsUpdated(t){t.bittyUpdated=!0}_modKeyAliases(){return{alt:"altKey",altkey:"altKey",cmd:"metaKey",command:"metaKey",ctrl:"ctrlKey",ctrlkey:"ctrlKey",meta:"metaKey",metakey:"metaKey",option:"altKey",optionkey:"altKey",shift:"shiftKey",shiftkey:"shiftKey",win:"metaKey",windows:"metaKey"}}__processBittyForwardSender(t){this.b._updateElement(t.sender);const e=this.b._splitSignalString(t.signals);for(const s of e)if("function"==typeof this[s]){const e=document.querySelectorAll(`[data-r~='${s}']`);if(e.length>0)for(const n of e)this.b._updateElement(n),n.isSender=()=>!1,n.isTarget=()=>!1,this[s](void 0,t.sender,n);else this[s](void 0,t.sender,void 0)}}__processBittySend(t){this.b._updateElement(t.target);const e=this.b._splitSignalString(t.signals);for(const s of e)if("function"==typeof this[s]){const e=document.querySelectorAll(`[data-r~='${s}']`);if(e.length>0)for(const n of e)this.b._updateElement(n),n.isSender=()=>!1,n.isTarget=()=>!1,this[s](t.payload,void 0,n);else this[s](t.payload,void 0,void 0)}}__processBittyTrigger(t){this.b._updateElement(t.target);const e=this.b._splitSignalString(t.signals);for(const s of e)if("function"==typeof this[s]){const e=document.querySelectorAll(`[data-r~='${s}']`);if(e.length>0)for(const n of e)this.b._updateElement(n),n.isSender=()=>!1,n.isTarget=()=>!1,this[s](t,void 0,n);else this[s](t,void 0,void 0)}}__processChangeEvent(t){this.b._updateElement(t.target);const n=this.b._findSenders(t.target);for(const r of n){this.b._updateElement(r);const n=this.b._splitSignalString(r.dataset.s),i=this.b._splitSignalString(r.dataset.listen);if(0===i.length){const i=r.getAttribute("type");if(i&&e.includes(i.toLowerCase()))return;if(i&&s.includes(i.toLowerCase()))return;if(r.tagName&&"form"===r.tagName.toLowerCase())return;for(const e of n)if("function"==typeof this[e]){const s=document.querySelectorAll(`[data-r~='${e}']`);if(s.length>0)for(const n of s)this.b._updateElement(n),this[e](t,r,n);else this[e](t,r,void 0)}}else if(i.includes(t.type))for(const e of n)if("function"==typeof this[e]){const s=document.querySelectorAll(`[data-r~='${e}']`);if(s.length>0)for(const n of s)this.b._updateElement(n),this[e](t,r,n);else this[e](t,r,void 0)}}}__processCustomEvent(t,e){this.b._updateElement(t.target);const s=this.b._splitSignalString(e);for(const e of s)if("function"==typeof this[e]){const s=document.querySelectorAll(`[data-r~='${e}']`);if(s.length>0)for(const n of s)this.b._updateElement(n),this.b._updateElement(t.target),this[e](t,t.target,n);else this[e](t,void 0,void 0)}}__processEvent(n){this.b._updateElement(n.target);const r=this.b._findSenders(n.target);for(const i of r){this.b._updateElement(i);const r=this.b._splitSignalString(i.dataset.s),o=this.b._splitSignalString(i.dataset.listen);if(0===o.length){if(n.target){const n=i.getAttribute("type");if(n&&t.includes(n.toLowerCase()))return;if(n&&e.includes(n.toLowerCase()))return;if(n&&s.includes(n.toLowerCase()))return;if(i.tagName&&"select"===i.tagName.toLowerCase())return;if(i.tagName&&"textarea"===i.tagName.toLowerCase())return}if(!0===i.isContentEditable&&"click"===n.type)return;for(const t of r)if("function"==typeof this[t]){const e=document.querySelectorAll(`[data-r~='${t}']`);if(e.length>0)for(const s of e)this.b._updateElement(s),this[t](n,i,s);else this[t](n,i,void 0)}}else if(o.includes(n.type))for(const t of r)if("function"==typeof this[t]){const e=document.querySelectorAll(`[data-r~='${t}']`);if(e.length>0)for(const s of e)this.b._updateElement(s),this[t](n,i,s);else this[t](n,i,void 0)}}}__processInit(){if(void 0!==this.b.init){const t=this.b._splitSignalString(this.b.init);for(const e of t)if("function"==typeof this[e]){const t=document.querySelectorAll(`[data-r~='${e}']`);if(t.length>0)for(const s of t)this.b._updateElement(s),s.isSender=()=>!1,s.isTarget=()=>!1,this[e]({},void 0,s);else this[e]({},void 0,void 0)}}}__processInputEvent(t){this.b._updateElement(t.target);const e=this.b._findSenders(t.target);for(const n of e){this.b._updateElement(n);const e=this.b._splitSignalString(n.dataset.s),r=this.b._splitSignalString(n.dataset.listen);if(0===r.length){const r=n.getAttribute("type");if(r&&!s.includes(r.toLowerCase()))return;if(n.tagName&&"select"===n.tagName.toLowerCase())return;for(const s of e)if("function"==typeof this[s]){const e=document.querySelectorAll(`[data-r~='${s}']`);if(e.length>0)for(const r of e)this.b._updateElement(r),this[s](t,n,r);else this[s](t,n,void 0)}}else if(r.includes(t.type))for(const s of e)if("function"==typeof this[s]){const e=document.querySelectorAll(`[data-r~='${s}']`);if(e.length>0)for(const r of e)this.b._updateElement(r),this[s](t,n,r);else this[s](t,n,void 0)}}}__processInputTextEnter(t){this.b._updateElement(t.target);const s=this.b._findSenders(t.target);for(const n of s){this.b._updateElement(n);const s=this.b._splitSignalString(n.dataset.s),r=this.b._splitSignalString(n.dataset.listen);if(0===r.length){const r=n.getAttribute("type");if(r&&!e.includes(r.toLowerCase()))return;for(const e of s)if("function"==typeof this[e]){const s=document.querySelectorAll(`[data-r~='${e}']`);if(s.length>0)for(const r of s)this.b._updateElement(r),this[e](t,n,r);else this[e](t,n,void 0)}}else if(r.includes(t.type))for(const e of s)if("function"==typeof this[e]){const s=document.querySelectorAll(`[data-r~='${e}']`);if(s.length>0)for(const r of s)this.b._updateElement(r),this[e](t,n,r);else this[e](t,n,void 0)}}}__processKeypress(t,e){this.b._updateElement(t.target);const s=t.target,n=this.b._splitSignalString(e);for(const e of n)if("function"==typeof this[e]){const n=document.querySelectorAll(`[data-r~='${e}']`);if(n.length>0)for(const r of n)this.b._updateElement(r),this[e](t,s,r);else this[e](t,s,void 0)}}_qs(t,e){return void 0===e?document.querySelector(t):e.querySelector(t)}_qsa(t,e){return void 0===e?document.querySelectorAll(t):e.querySelectorAll(t)}async _quickCopy(t,e,s={}){void 0===s.success&&(s.success="Copied"),void 0===s.failed&&(s.failed="Could not copy"),void 0===s.ms&&(s.ms=2e3),void 0===e.copyId&&(e.copyId,this.b.uuid()),this.b._debouncers[e.copyId]&&window.clearTimeout(this.b._debouncers[e.copyId]);const n=void 0!==t.value?t.value:t.innerHTML;try{return await navigator.clipboard.writeText(n),void 0===e.originalInnerHTML&&(e.originalInnerHTML=JSON.stringify({value:e.innerHTML}),e.innerHTML=s.success),this.b._debouncers[e.copyId]=setTimeout(()=>{e.innerHTML=JSON.parse(e.originalInnerHTML).value,delete e.originalInnerHTML},s.ms),!0}catch(t){return void 0===e.originalInnerHTML&&(e.originalInnerHTML=JSON.stringify({value:e.innerHTML}),e.innerHTML=s.failed),this.b._debouncers[e.copyId]=setTimeout(()=>{e.innerHTML=JSON.parse(e.originalInnerHTML).value,delete e.originalInnerHTML},s.ms),!1}}_randomFloat(t,e){const s=new Uint32Array(1);crypto.getRandomValues(s);return s[0]/4294967296*Math.abs(e-t)+Math.min(t,e)}_randomInt(t,e){const s=new Uint32Array(1);crypto.getRandomValues(s);return s[0]%(Math.abs(e-t)+1)+Math.min(t,e)}_render(t,e={}){if(t instanceof Array==!1&&(t=[t]),"string"==typeof t[0]&&void 0!==this.b.svgs[t[0]]){let s=this.b.svgs[t[0]];for(const t of Object.keys(e)){const n=(e[t]instanceof Array==!0?e[t]:[e[t]]).map(t=>{if("string"==typeof t)return t;{const e=document.createElement("div");return e.appendChild(t),e.innerHTML}}).join("");s=s.replaceAll(t,n)}const n=document.createElement("div");return n.innerHTML=s,n.firstChild}let s=t.map(t=>{if("string"==typeof t)return void 0!==this.b.templates[t]?this.b.templates[t]:t;{const e=document.createElement("div");return e.appendChild(t),e.innerHTML}}).join("");for(const t of Object.keys(e)){const n=(e[t]instanceof Array==!0?e[t]:[e[t]]).map(t=>{if(null===t)return"null";if(t instanceof DocumentFragment){const e=document.createElement("div");return e.appendChild(t),e.innerHTML}if(t instanceof Element){const e=document.createElement("div");return e.appendChild(t),e.innerHTML}return t}).join("");s=s.replaceAll(t,n)}const n=document.createElement("template");return n.innerHTML=s,n.content}_setState(t){for(const e of t){const t=this.b.qs(`#${e.id}`);if(t){for(const s in e.attributes)t.setAttribute(s,e.attributes[s]);for(const s in e.keys)t[s]=e.keys[s]}}}async _loadSiteData(t,e){const s=await this.b._initSiteDB(),r=await new Promise((e,r)=>{const i=s.transaction(n,"readonly").objectStore(n).get(t);i.onsuccess=()=>e(i.result),i.onerror=()=>r(i.result)});return void 0===r&&void 0!==e?(await this.b.saveSiteData(e,t),e):r}async _loadPageData(t,e){const s=await this.b._initPageDB(),r=await new Promise((e,r)=>{const i=s.transaction(n,"readonly").objectStore(n).get(t);i.onsuccess=()=>e(i.result),i.onerror=()=>r(i.result)});return void 0===r&&void 0!==e?(await this.b.savePageData(e,t),e):r}_switch(t={}){return t.__APPEND__=t.__APPEND__?t.__APPEND__:"",t.__PREPEND__=t.__PREPEND__?t.__PREPEND__:"",t.__CLASS__=t.__CLASS__?t.__CLASS__:"bitty-switch",t.__ID__=t.__ID__?t.__ID__:`switch_${this.b.uuid(!1)}`,t.__STATE__=t.__STATE__?t.__STATE__:"false",t.__RECEIVE_ATTR__=t.__RECEIVE__?` data-r="${t.__RECEIVE__}"`:"",t.__SEND_ATTR__=t.__SEND__?` data-s="${t.__SEND__}"`:"",t.__KEY_ATTR__=t.__KEY__?` data-key="${t.__KEY__}"`:"",t.__SAVE_ATTR__=t.__SAVE__?` data-save="${t.__SAVE__}"`:"",t.__LABEL_MISC__=t.__LABEL_MISC__?` ${t.__LABEL_MISC__}`:"",t.__BUTTON_MISC__=t.__BUTTON_MISC__?` ${t.__BUTTON_MISC__}`:"",this.b.render("switch",t)}async _savePageData(t,e){const s=await this.b._initPageDB();return await new Promise((r,i)=>{const o=s.transaction(n,"readwrite").objectStore(n).put(t,e);o.onsuccess=()=>r(o.result),o.onerror=()=>i(o.result)})}async _saveSiteData(t,e){const s=await this.b._initSiteDB();return await new Promise((r,i)=>{const o=s.transaction(n,"readwrite").objectStore(n).put(t,e);o.onsuccess=()=>r(o.result),o.onerror=()=>i(o.result)})}_send(t,e){const s=new o(t,e);dispatchEvent(s)}_setCSS(t,e){document.documentElement.style.setProperty(t,e)}_shuffle(t){for(let e=t.length-1;e>=1;e--){const s=new Uint32Array(1);crypto.getRandomValues(s);const n=s[0]%e;[t[e],t[n]]=[t[n],t[e]]}}async _sleep(t){return new Promise(e=>setTimeout(e,t))}_sort(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}__splitSignalString(t){return void 0!==t?t.trim().split(/\s+/m).map(t=>t.trim()):[]}_tee(t,e=!0){return!1!==e&&0!==e&&console.log(t),t}_time(t=new Date,e=!1){const s={};new Intl.DateTimeFormat(void 0,{day:"2-digit",fractionalSecondDigits:3,hour:"2-digit",hour12:!1,minute:"2-digit",month:"2-digit",second:"2-digit",year:"numeric"}).formatToParts(t).filter(t=>"literal"!==t.type).forEach(t=>s[t.type]=t.value);const n=[s.year,s.month,s.day].join("-"),r=[s.hour,s.minute,s.second].join(":");return!0===e?`${n}T${r}.${s.fractionalSecond}`:`${n}T${r}`}_timeMs(t){return this.b.time(t,!0)}_trigger(t){const e=new a(t);dispatchEvent(e)}__updateElement(t){!0!==t.bittyUpdated&&(t.aria=e=>{const s=t.closest(`[aria-${e}]`);return s?s.getAttribute(`aria-${e}`):void 0},t.ariaAsBool=e=>{const s=t.closest(`[aria-${e}]`);if(s){const t=s.getAttribute(`aria-${e}`);return this.b._getBool(t)}},t.ariaAsFloat=e=>{const s=t.closest(`[aria-${e}]`);return s?parseFloat(s.getAttribute(`aria-${e}`)):void 0},t.ariaAsInt=e=>{const s=t.closest(`[aria-${e}]`);return s?parseInt(s.getAttribute(`aria-${e}`),10):void 0},t.copy=async function(){if(t.value)try{await navigator.clipboard.writeText(t.value)}catch(t){return console.error("Could not copy .value from el."),!1}else try{await navigator.clipboard.writeText(t.innerHTML)}catch(t){return console.error("Could not copy .innerHTML from el."),!1}return!0},t.innerHTMLAsBool=()=>{if(void 0!==t.innerHTML)return this.b._getBool(t.innerHTML)},t.innerHTMLAsFloat=()=>parseFloat(t.innerHTML.trim().replace(",","")),t.innerHTMLAsInt=()=>parseInt(t.innerHTML.trim().replace(",",""),10),t.prop=e=>{if(t.dataset&&void 0!==t.dataset[e])return t.dataset[e];const s=t.closest(`[data-${e}]`);return null!==s?s.dataset[e]:void 0},t.propAsBool=e=>{if(t.dataset&&void 0!==t.dataset[e])return this.b._getBool(t.dataset[e]);const s=t.closest(`[data-${e}]`);return null!==s?this.b._getBool(s.dataset[e]):void 0},t.propAsFloat=e=>{if(t.dataset&&void 0!==t.dataset[e])return parseFloat(t.dataset[e]);const s=t.closest(`[data-${e}]`);return null!==s?parseFloat(s.dataset[e]):void 0},t.propAsInt=e=>{if(t.dataset&&void 0!==t.dataset[e])return parseInt(t.dataset[e],10);const s=t.closest(`[data-${e}]`);return null!==s?parseInt(s.dataset[e],10):void 0},t.setAria=(e,s)=>{const n=t.closest(`[aria-${e}]`);n?n.setAttribute(`aria-${e}`,s):t.setAttribute(`aria-${e}`,s)},t.setProp=(e,s)=>{const n=t.closest(`[data-${e}]`);n?n.dataset[e]=s:t.dataset[e]=s},t.toggleAria=e=>{const s=t.closest(`[aria-${e}]`);if(s){let t=this.b._trueValues.indexOf(s.getAttribute(`aria-${e}`).toLowerCase());if(t>=0)return void s.setAttribute(`aria-${e}`,this.b._falseValues[t]);if(t=this.b._falseValues.indexOf(s.getAttribute(`aria-${e}`).toLowerCase()),t>=0)return void s.setAttribute(`aria-${e}`,this.b._trueValues[t])}},t.toggleProp=e=>{const s=t.closest(`[data-${e}]`);if(s){let t=this.b._trueValues.indexOf(s.getAttribute(`data-${e}`).toLowerCase());if(t>=0)return void s.setAttribute(`data-${e}`,this.b._falseValues[t]);if(t=this.b._falseValues.indexOf(s.getAttribute(`data-${e}`).toLowerCase()),t>=0)return void s.setAttribute(`data-${e}`,this.b._trueValues[t])}},t.valueAsBool=()=>this.b._getBool(t.value),t.valueAsFloat=()=>parseFloat(t.value),t.valueAsInt=()=>parseInt(t.value,10),t.bittyUpdated=!0)}_uuid(t=!0){if(!1===t){return self.crypto.randomUUID().replaceAll("-","")}return self.crypto.randomUUID()}}customElements.define("bitty-8",r);class i extends Event{constructor(t,e){super("bittyforwardsender",{bubbles:!0}),this.sender=t,this.signals=e}}class o extends Event{constructor(t,e){super("bittysend",{bubbles:!0}),this.payload=t,this.signals=e}}class a extends Event{constructor(t){super("bittytrigger",{bubbles:!0}),this.signals=t}} \ No newline at end of file