@vielzeug/ore 2.0.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ore.js CHANGED
@@ -1,3 +1,3 @@
1
- import{batch as e,computed as t,createScope as n,effect as r,isReactive as i,signal as a,untrack as o}from"@vielzeug/ripple";var s=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},c=class extends s{},l=class extends s{},u=class extends s{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function d(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var f={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice — custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifiersUnsupported:e=>`@${e}: event modifiers are unsupported; call native event methods in the handler instead`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}" — listener not attached`,propInvalidReflect:`Structured props cannot use reflect:true — use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
1
+ import{batch as e,computed as t,createScope as n,effect as r,isReactive as i,signal as a,untrack as o}from"@vielzeug/ripple";var s=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},c=class extends s{},l=class extends s{},u=class extends s{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function d(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var f={asyncSetupUnsupported:`setup() must return an HTMLResult or null; use reactive state for asynchronous work`,defineDuplicate:e=>`define('${e}') called twice — custom element already registered`,defineFieldRequiresFormAssociated:e=>`useField() requires define('${e}', { formAssociated: true })`,defineRequiresTag:`define() requires a tag name`,eachDuplicateKey:(e,t)=>`each() received duplicate key "${e}" at index ${t}`,eventModifiersUnsupported:e=>`@${e}: event modifiers are unsupported; call native event methods in the handler instead`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,invariantViolated:e=>`invariant violated: ${e}`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,listenNullTarget:e=>`listen() called with a null/undefined target for event "${e}" — listener not attached`,propInvalidReflect:`Structured props cannot use reflect:true — use prop.json() with reflect:false`,templateInterpolationInTag:"html`...`: interpolations inside a tag must be named attributes, boolean attributes, events, or refs",useFieldAlreadyCalled:e=>`useField() was already called on <${e}>. Call it only once per component.`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
2
2
  `)}`};function p(e,t){if(!e)throw new l(f.invariantViolated(t))}var m=e=>typeof e==`function`?e():i(e)?e.value:e,h=/[;{}]/g,g=e=>e.replace(h,``),_=e=>{for(let t=e.length-1;t>=0;t--)e[t]?.()},v=e=>{for(let t of e)t.remove()},y=()=>{let e=[],t=[];return{clear(){_(t),v(e),t=[],e=[]},get nodes(){return e},registerCleanup(e){t.push(e)},setNodes(t){e=t}}},b=new Set([`action`,`cite`,`codebase`,`data`,`formaction`,`href`,`manifest`,`ping`,`poster`,`src`,`xlink:href`]),x=/^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i,S=(e,t,n)=>{let r=t.toLowerCase();if(/^on[a-z]/i.test(t)){`${t}${t.slice(2)}`,e.removeAttribute(t);return}if(r===`srcdoc`){e.removeAttribute(t);return}if(n==null||n===!1){e.removeAttribute(t);return}let i=n===!0?`true`:String(n);if(b.has(r)&&x.test(i)){`${t}`,e.removeAttribute(t);return}e.setAttribute(t,i)},C=(e,t,n,r)=>{if(!e)return f.listenNullTarget(t),()=>{};let i=n;return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},w=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),T=e=>Array.isArray(e)||typeof e==`object`&&!!e,E=null,D=e=>({element:e,formResetCallbacks:[],mountCallbacks:[]}),ee=0,te=()=>{ee++;let e=!1;return()=>{e||(e=!0,ee--)}},O=(e,t)=>{let n=E;E=e;try{return t()}finally{E=n}},k=e=>{if(E)return E;throw new c(`${e}: ${f.lifecycleOutsideSetup}`)},A=()=>k(`getHost`).element,j=e=>E?(r(()=>e),!0):!1,M=e=>{if(!j(e))throw new c(`onCleanup: ${f.lifecycleOutsideSetup}`)},N=e=>{k(`onMounted`).mountCallbacks.push(e)},ne=e=>{k(`onFormReset`).formResetCallbacks.push(e)},P=e=>{let t=r(e),n=()=>t.dispose();return j(n),n};function re(e,t,n,r){if(k(`onEvent`),!e)return;let i=C(e,t,n,r);j(i)||i()}var ie=(e,t)=>P(()=>{let n=e.value;if(n)return t(n)}),F=new WeakMap,ae=e=>{let t=[],n=e;for(;n;)n instanceof HTMLElement&&t.push(n),n=n.parentNode??(n instanceof ShadowRoot?n.host:null);return t},oe=(e,t,n)=>{let r=F.get(e)??new Map;r.has(t)&&`${e.localName}`,r.set(t,n),F.set(e,r)},se=(e,t)=>{let n=k(`provide`).element;oe(n,e,t),M(()=>{let t=F.get(n);t&&(t.delete(e),t.size===0&&F.delete(n))})},I=Symbol(`inject.not_found`),ce=new WeakMap,le=(e,t)=>{let n=ae(e);for(let e of n){let n=F.get(e);if(n?.has(t))return n.get(t)}return I},L=(e,t)=>{let n=ce.get(e);n||(n=new Map,ce.set(e,n));let r=t;return n.has(r)||n.set(r,le(e.element,t)),n.get(r)};function ue(e,...t){let n=L(k(`inject`),e);return n===I?t.length>0?t[0]:void 0:n}var de=e=>{let t=k(`injectStrict`),n=L(t,e);if(n!==I)return n;throw new c(f.injectStrictFailed(String(e),t.element.localName))},fe=0;function pe(e){return Symbol.for(`ore:context:${e??`anonymous-${++fe}`}`)}function me(e){return{default:e,parse:()=>e,reflect:!1}}var he={bool(e){return{default:e??!1,parse:e=>e!==null&&e!==`false`,reflect:!0}},data(e){return me(e)},json(e){return{default:e,parse:t=>{if(t==null||t===``)return e;try{return JSON.parse(t)}catch{return e}},reflect:!1}},number(e){let t=e===void 0?void 0:e;return{default:t,parse:e=>{if(e==null)return t;let n=Number(e);return Number.isNaN(n)?(`${e}${String(t)}`,t):n},reflect:!0}},oneOf(e,t){return{default:t,parse:n=>n!=null&&e.includes(n)?n:t,reflect:!0}},string(e){let t=e===void 0?void 0:e;return{default:t,parse:e=>e??t,reflect:!0}}},ge=e=>typeof e==`object`&&!!e&&`default`in e&&`parse`in e;function R(e,t){if(!ge(e))throw new c(`Prop "${t}" must use a prop.* helper (string/number/bool/json/oneOf). Received: ${typeof e}`);let n=e;if(!n.parse)throw new c(`Prop "${t}" must have a parse function. Use prop.* helpers.`);let r=n.reflect??!1;if(r&&T(n.default))throw new c(`Prop "${t}": ${f.propInvalidReflect}`);return{...n,reflect:r}}function _e(e){let t=[];for(let[n,r]of Object.entries(e))try{R(r,n)}catch(e){t.push(e instanceof Error?e.message:String(e))}return t}var z=new WeakMap,ve=(e,t)=>z.get(e)?.get(t),ye=(e,t)=>typeof e==`string`?t(e):e,be=(e,t,n,r)=>{let i=z.get(e);i||(i=new Map,z.set(e,i));let{default:o,parse:s,reflect:c=!1}=r,l=a(o),u=i.get(n),d=Object.hasOwn(e,t),f=d?e[t]:void 0,p={parse:s,reflect:c,signal:l};return u?l.value=u.signal.peek():d?(delete e[t],l.value=ye(f,s)):e.hasAttribute(n)&&(l.value=s(e.getAttribute(n))),i.set(n,p),Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:()=>l.value,set:e=>{l.value=ye(e,s)}}),c&&P(()=>{let t=l.value;t==null?e.removeAttribute(n):typeof t==`boolean`?e.toggleAttribute(n,t):S(e,n,t)}),l};function xe(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]=be(e,r,w(r),i);return n}var B=e=>{let t=Symbol.for(e);return{is:e=>typeof e==`object`&&!!e&&t in e,stamp:e=>Object.assign(e,{[t]:!0})}},Se=B(`ore:css-result`),Ce=Se.is,we=function(){return this.content},Te=(e,...t)=>{let n=``;for(let r=0;r<e.length;r++)if(n+=e[r],r<t.length){let e=t[r];n+=Ce(e)?e.content:String(e)}return Se.stamp({content:n.trim(),toString:we})},V=new Map,Ee=256,De=e=>{if(e instanceof CSSStyleSheet)return e;let t=typeof e==`string`?e:e.content,n=V.get(t);if(n)return V.delete(t),V.set(t,n),n;let r=new CSSStyleSheet;try{r.replaceSync(t)}catch{return r}if(V.set(t,r),V.size>Ee){let e=V.keys().next().value;e!==void 0&&V.delete(e)}return r},H={SETUP_DONE:`setup_done`,SETUP_RUNNING:`setup_running`,UNINITIALIZED:`uninitialized`,UNMOUNTED:`unmounted`},Oe={CONNECT:`ore:connect`,DISCONNECT:`ore:disconnect`},ke=()=>({formResetCallbacks:[],generation:0,mountCallbacks:[],phase:H.UNINITIALIZED,scope:n(),templateResult:null}),Ae=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e&&typeof e.then==`function`,je=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=ke()}connectedCallback(){o(()=>{this._component.phase===H.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(Oe.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=ve(this,e);if(!r)return;let i=r.parse(n);Object.is(o(()=>r.signal.value),i)||(r.signal.value=i)}disconnectedCallback(){this._component.generation++,this._component.phase=H.UNMOUNTED,this.dispatchEvent(new CustomEvent(Oe.DISCONNECT,{bubbles:!1,composed:!1})),this._resetSetupState()}_resetSetupState(){this._component.scope.dispose(),this._component.formResetCallbacks=[],this._component.mountCallbacks=[],this._component.phase=H.UNINITIALIZED,this._component.scope=n(),this._component.templateResult=null}formResetCallback(){for(let e of this._component.formResetCallbacks)try{e()}catch(e){this._reportLifecycleError(e,`form-reset`)}}_reportLifecycleError(e,t){let n=e instanceof Error?e:Error(String(e));d(new u(`<${this.localName}> failed during ${this._component.phase} (${t})`,{cause:n,component:this.localName,phase:t}),this)}_runSetup(){this._component.phase=H.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n=D(this);try{let r;if(this._component.scope.run(()=>{r=O(n,()=>{let n=t?xe(this,t):{};return e.setup(n)})}),this._component.mountCallbacks.push(...n.mountCallbacks),this._component.formResetCallbacks.push(...n.formResetCallbacks),Ae(r))throw new c(f.asyncSetupUnsupported);this._component.templateResult=r??null,this._component.phase=H.SETUP_DONE}catch(e){throw this._reportLifecycleError(e,`setup`),this._resetSetupState(),e}}_isStale(e){return this._component.generation!==e||!this.isConnected}_applyResult(e){if(!e)return;let t=this.shadowRoot??this,n=D(this);t.replaceChildren(),this._component.scope.run(()=>{O(n,()=>{e.mount(t,null,M)})})}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===H.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(De))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation,t=te();queueMicrotask(()=>{try{if(this._isStale(e))return;let t=this._component.mountCallbacks.splice(0);for(let e=0;e<t.length;e++){let n=t[e];try{let e=D(this);this._component.scope.run(()=>{O(e,()=>{let e=n();typeof e==`function`&&M(e)})}),e.mountCallbacks.length>0&&t.push(...e.mountCallbacks),e.formResetCallbacks.length>0&&this._component.formResetCallbacks.push(...e.formResetCallbacks)}catch(e){this._reportLifecycleError(e,`mounted`)}}}finally{t()}})}};function Me(e,t){let{props:n}=t,r=(()=>{if(!n)return;let t=_e(n);if(t.length>0)throw new c(f.validationFailed(e,t));let r={};for(let[e,t]of Object.entries(n))r[e]=R(t,e);return r})(),i=r?Object.keys(r).map(w):[];return class extends je{static _definition=t;static _normalizedPropDefs=r;static formAssociated=t.formAssociated??!1;static observedAttributes=i}}function Ne(e,t){if(!e)throw new c(f.defineRequiresTag);if(customElements.get(e))throw new c(f.defineDuplicate(e));let n=Me(e,t);Object.defineProperty(n,"name",{value:e}),customElements.define(e,n)}var Pe=e=>t(()=>Object.entries(e).filter(([,e])=>m(e)).map(([e])=>e.replace(/\s+/g,``)).filter(Boolean).join(` `));function Fe(){return a(null)}var U=B(`ore:directive`),W=e=>U.stamp({mount:e}),Ie=U.is,G=B(`ore:html-result`),K=G.is;function Le(e,t){return G.stamp({apply:t,fragment:e,mount:(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a}})}var Re=(e,t,r,i,o)=>{let s=a(e),c=a(t),l=n(),u=[],d=[];return l.run(()=>{d=r(s,c).mount(i,o,e=>u.push(e))}),{cleanups:u,data:s,index:c,key:``,nodes:d,scope:l}},q=e=>{e.scope.dispose(),_(e.cleanups),v(e.nodes)},ze=(t,n,r,i,a,s)=>{let l=[],u=new Set;for(let e=0;e<n.length;e++){let t=String(r(n[e],e));if(u.has(t))throw new c(f.eachDuplicateKey(t,e));u.add(t),l.push(t)}for(let[e,n]of t)u.has(e)||(q(n),t.delete(e));let d=[];for(let r=0;r<n.length;r++){let c=l[r],u=t.get(c);if(u)e(()=>{u.data.value=n[r],u.index.value=r}),d.push(u);else{let e=o(()=>Re(n[r],r,i,a,s));e.key=c,t.set(c,e),d.push(e)}}let p=s;for(let e=d.length-1;e>=0;e--){let t=d[e],n=t.nodes[0];if(n&&n!==p.previousSibling)for(let e of t.nodes)a.insertBefore(e,p);p=n??p}return d};function Be(e,n,i,s){let c=Array.isArray(e)?a(e):typeof e==`function`?t(e):e;return W((e,t)=>{let a=e.parentNode;p(a,`each() anchor comment has no parent node`);let l=document.createComment(`each/end`);a.insertBefore(l,e.nextSibling);let f=new Map,m=[],h=null,g=[],y=()=>{s&&(h=s().mount(a,l,e=>g.push(e)))},b=()=>{h&&(_(g),v(h),h=null,g=[])},x=r(()=>{let t=c.value??[];if(t.length===0){for(let e of o(()=>m))q(e);f=new Map,m=[],h||o(y);return}b();try{m=o(()=>ze(f,t,n,i,a,l))}catch(t){let n=t instanceof Error?t:Error(String(t));d(new u(`each() failed to reconcile a list update: ${n.message}`,{cause:n,component:`each()`,phase:`each-reconcile`}),e);for(let e of f.values())q(e);f=new Map,m=[]}});t(()=>x.dispose()),t(()=>{b();for(let e of m)q(e);l.remove()})})}var J=B(`ore:live`),Ve=e=>J.stamp({source:e}),He=J.is,Ue=e=>{let t=m(e);return t==null||t===!1?``:g(String(t))},We=e=>t(()=>{let t=[];for(let[n,r]of Object.entries(e)){let e=Ue(r);if(!e)continue;let i=g(w(n));i&&t.push(`${i}:${e}`)}return t.join(`;`)}),Ge=(e,t,n)=>{let r=document.createElement(`template`);r.innerHTML=e;let i=Array.from(r.content.cloneNode(!0).childNodes);for(let e of i)t.insertBefore(e,n);return i};function Ke(e){if(typeof e==`function`){let n=t(e);return W((e,t)=>{Ke(n).mount(e,t)})}return W((t,n)=>{let a=t.parentNode;p(a,`unsafeHtml() anchor comment has no parent node`);let o=document.createComment(`unsafe-html/end`);if(a.insertBefore(o,t.nextSibling),i(e)){let t=y(),i=e,s=r(()=>{t.clear(),t.setNodes(Ge(i.value,a,o))});n(()=>s.dispose()),n(()=>{t.clear(),o.remove()})}else Ge(e,a,o),n(()=>o.remove())})}var qe=`when() anchor comment has no parent node`;function Je(e,n,a){return typeof e!=`function`&&!i(e)?W((t,r)=>{let i=e?n():a?a():null;if(!i||!K(i))return;let o=t.parentNode;p(o,qe);let s=i.mount(o,t,r);r(()=>v(s))}):W((i,s)=>{let c=(typeof e==`function`?t(e):null)??e,l=i.parentNode;p(l,qe);let u=document.createComment(`when/end`);l.insertBefore(u,i.nextSibling);let d=y(),f=r(()=>{let e=c.value;d.clear();let t=e?n():a?a():null;!t||!K(t)||d.setNodes(o(()=>t.mount(l,u,d.registerCleanup)))});s(()=>f.dispose()),s(()=>{d.clear(),u.remove()})})}var Ye=new WeakMap,Y=new WeakSet,Xe=e=>{let t=e.el??A();if(!t.constructor.formAssociated)throw new c(f.defineFieldRequiresFormAssociated(t.localName));if(Y.has(t))throw new c(f.useFieldAlreadyCalled(t.localName));let n=Ye.get(t)??t.attachInternals();Ye.set(t,n),Y.add(t),M(()=>Y.delete(t));let r=e.toFormValue??(t=>t==null?e.emptyStringForNull?``:null:t instanceof File||t instanceof FormData?t:String(t));P(()=>{n.setFormValue(r(e.value.value))});let i=e.disabled;if(i&&`states`in n){let e=n.states;P(()=>{i.value?e.add(`disabled`):e.delete(`disabled`)})}return e.validity&&P(()=>{let t=e.validity?.value??{},r=Object.values(t).some(Boolean),i=e.validationMessage?.value??``;if(r&&!i){n.setValidity(t,`Invalid value.`);return}n.setValidity(t,i)}),e.onReset&&ne(e.onReset),{checkValidity:()=>n.checkValidity(),internals:n,reportValidity:()=>n.reportValidity(),setCustomValidity:e=>e?n.setValidity({customError:!0},e):n.setValidity({})}},Ze=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:`aria-${e}`,Qe=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e,$e=(e,t)=>{let n=t?.target??A(),r=[];if(e.attr)for(let[t,i]of Object.entries(e.attr)){let e=nt(n,et(t),i);e&&r.push(e)}if(e.aria)for(let[t,i]of Object.entries(e.aria)){let e=nt(n,Ze(t),i);e&&r.push(e)}if(e.class&&r.push(it(n,e.class)),e.style)for(let[t,i]of Object.entries(e.style)){let e=rt(n,t,i);e&&r.push(e)}if(e.on){let{target:i,...a}=t??{};for(let t of Object.keys(e.on)){let i=e.on[t];i&&r.push(C(n,t,i,a))}}let i=()=>{for(let e of r)e()};return j(i),i},et=Qe,tt=(e,t)=>{if(typeof e==`function`)return P(()=>{t(e())});if(i(e))return P(()=>{t(e.value)});t(e)};function nt(e,t,n){return tt(n,n=>S(e,t,n))}function rt(e,t,n){let r=g(t.startsWith(`--`)?t:w(t));if(!r)return;let i=!1;return tt(n,t=>{t!=null&&t!==``?(i=!0,e.style.setProperty(r,g(String(t)))):i&&e.style.removeProperty(r)})}function it(e,t){let n=typeof t==`function`?t:()=>{let e={};for(let[n,r]of Object.entries(t))e[n]=m(r);return e},r=new Set;return P(()=>{let t=new Set;for(let[i,a]of Object.entries(n()))a&&(t.add(i),r.has(i)||e.classList.add(i));for(let n of r)t.has(n)||e.classList.remove(n);r=t})}var at=`default`,X=e=>e||at,ot=e=>{let t=new Map,n=new Map,r=new Map,i=e=>{let n=t.get(e);return n||(n={elements:a([]),presence:a(!1)},t.set(e,n)),n},o=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},s=e=>{let t=X(e),r=n.get(t),a=[];if(r)for(let e of r)a.push(...e.assignedElements({flatten:!0}));let s=i(t);o(s.elements.value,a)||(s.elements.value=a);let c=a.length>0;s.presence.value!==c&&(s.presence.value=c)},c=e=>{if(r.has(e))return;let t=X(e.getAttribute(`name`)),i=n.get(t)??new Set;i.add(e),n.set(t,i);let a=()=>s(t);e.addEventListener(`slotchange`,a),r.set(e,()=>{e.removeEventListener(`slotchange`,a)}),s(t)},l=e=>{let t=r.get(e);if(!t)return;t(),r.delete(e);let i=X(e.getAttribute(`name`)),a=n.get(i);a&&(a.delete(e),a.size===0&&n.delete(i)),s(i)},u=()=>{e.shadowRoot?.querySelectorAll(`slot`).forEach(e=>{c(e)})},d=()=>{for(let e of n.keys())s(e)},f=null;return N(()=>{u(),d(),!f&&e.shadowRoot&&(f=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)e instanceof HTMLSlotElement&&l(e);u(),r.size>0&&d()}),f.observe(e.shadowRoot,{childList:!0,subtree:!0}))}),M(()=>{f?.disconnect(),f=null;for(let e of r.values())e();r.clear(),n.clear(),t.clear(),Z.delete(e)}),{elements:e=>i(X(e)).elements,has:e=>i(X(e)).presence}},Z=new WeakMap,st=()=>{let e=k(`useSlots`),t=Z.get(e.element);return t||(t=ot(e.element),Z.set(e.element,t)),t},ct=(e,t,n)=>{let i=r(()=>{t(e.value)});n(()=>i.dispose())},lt=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,ut=e=>e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`),dt=(e,t,n,r={last:void 0})=>{let i=ut(e),a=i?!!t:t==null?``:String(t),o=i?e.checked:e.value;n&&r.last!==void 0&&!Object.is(o,r.last)&&!Object.is(o,a)||(i?e.checked=a:e.value=a,n&&(r.last=a))},ft=(e,t,n,r)=>{let i=T(r)?r:t.parse(n.mode===`bool`?r?``:null:r==null||r===!1?null:String(r));if(Object.is(o(()=>t.signal.value),i)||(t.signal.value=i),!t.reflect){if(T(r))return;n.mode===`bool`?e.toggleAttribute(n.name,!!r):S(e,n.name,r)}},pt=(e,t)=>{let{el:n,mode:r,name:a,propMeta:o}=e,s={last:void 0},c=t=>{if(o){ft(n,o,e,t);return}if(!i(t)&&T(t)){a!==`__proto__`&&a!==`constructor`&&a!==`prototype`&&(n[a]=t);return}if(a===`value`&&lt(n)||a===`checked`&&n instanceof HTMLInputElement){dt(n,t,e.live,s);return}r===`bool`?n.toggleAttribute(a,!!t):S(n,a,t)};`signal`in e?ct(e.signal,c,t):c(e.value)},mt=(e,t)=>{t(C(e.el,e.name,e.handler))},ht=(e,t)=>{let{el:n,ref:r}=e;if(typeof r==`function`){r(n),t(()=>r(null));return}r.value=n,t(()=>{r.value=null})},gt=(e,t,n)=>{let r=[],i=t.parentNode;p(i,`html binding anchor has no parent node`);for(let a of e)if(K(a)){let e=Array.from(a.fragment.childNodes);i.insertBefore(a.fragment,t),a.apply(n),r.push(...e)}else if(a!=null&&a!==!1){let e=document.createTextNode(String(a));i.insertBefore(e,t),r.push(e)}return r},_t=(e,t)=>{let{anchor:n,signal:i}=e,a=y(),s=r(()=>{let e=i.value;a.clear(),e!=null&&e.length!==0&&o(()=>{a.setNodes(gt(e,n,a.registerCleanup))})});t(()=>{s.dispose(),a.clear()})},vt=(e,t)=>{e.directive.mount(e.anchor,t)},yt=(e,t)=>{switch(e.type){case`attr`:pt(e,t);break;case`directive`:vt(e,t);break;case`event`:mt(e,t);break;case`html`:_t(e,t);break;case`ref`:ht(e,t)}},bt=(e,n,r,a)=>{let o=ve(e,r);return He(a)?{el:e,live:!0,mode:n,name:r,propMeta:o,signal:a.source,type:`attr`}:typeof a==`function`?{el:e,mode:n,name:r,propMeta:o,signal:t(a),type:`attr`}:i(a)?{el:e,mode:n,name:r,propMeta:o,signal:a,type:`attr`}:{el:e,mode:n,name:r,propMeta:o,type:`attr`,value:a}},xt=e=>e==null?``:String(e),Q={ATTR:`attr`,BOOL_ATTR:`boolAttr`,EVENT:`event`,NODE:`node`,REF:`ref`},St=/\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/,Ct=/\s+ref\s*=\s*["']?$/,wt=/\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,Tt=/\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,Et=e=>{let t;if(t=St.exec(e)){let n=e.slice(0,-t[0].length),[r,...i]=t[1].split(`.`);if(i.length>0)throw new c(f.eventModifiersUnsupported(t[1]));return{kind:Q.EVENT,name:r,prefix:n}}if(t=Ct.exec(e))return{kind:Q.REF,prefix:e.slice(0,-t[0].length)};if(t=wt.exec(e))return{kind:Q.BOOL_ATTR,name:t[1],prefix:e.slice(0,-t[0].length)};if(t=Tt.exec(e))return{kind:Q.ATTR,name:t[1],prefix:e.slice(0,-t[0].length)};let n=e.lastIndexOf(`<`);if(n>e.lastIndexOf(`>`)&&e[n+1]!==`/`)throw new c(f.templateInterpolationInTag);return{kind:Q.NODE,prefix:e}},Dt=new WeakMap,Ot=/[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/,kt=e=>{let t=Array.from(e),n=!1;for(let e=0;e<t.length-1;e++){let r=t[e],i=r[r.length-1];for(let e of r)e===`<`?n=!0:e===`>`&&(n=!1);if((i===`"`||i===`'`)&&n&&Ot.test(r.slice(0,-1))){t[e]=r.slice(0,-1);let n=t[e+1];n.startsWith(i)&&(t[e+1]=n.slice(1))}}return t},$=`data-ore-b`,At=/^ore:(\d+)$/,jt=(e,t,n,r)=>{if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.getAttribute($);i!==null&&(n.set(Number(i),[...t]),r.removeAttribute($))}else if(e.nodeType===Node.COMMENT_NODE){let n=e.nodeValue,i=n===null?null:At.exec(n);i&&r.set(Number(i[1]),[...t])}let i=e.childNodes;for(let e=0;e<i.length;e++)jt(i[e],[...t,e],n,r)},Mt=e=>{let t=kt(e),n=``,r,i=0,a=0,o=[];for(let e=0;e<t.length-1;e++){let s=t[e],c=Et(s);if(c.kind===Q.NODE)n+=`${c.prefix}<!--ore:${a}-->`,o.push({commentId:a,kind:Q.NODE}),a++,r=void 0;else{r===void 0||c.prefix.lastIndexOf(`<`)>c.prefix.lastIndexOf(`>`)?(r=i++,n+=`${c.prefix} ${$}="${r}"`):n+=c.prefix;let e=c.kind===Q.BOOL_ATTR?`bool`:c.kind===Q.ATTR?`attr`:void 0;o.push({elementId:r,kind:c.kind,mode:e,name:c.name})}}n+=t[t.length-1]??``;let s=document.createElement(`template`);s.innerHTML=n;let c=new Map,l=new Map,u=s.content.childNodes;for(let e=0;e<u.length;e++)jt(u[e],[e],c,l);return{commentPaths:l,element:s,elementPaths:c,slots:o}},Nt=e=>{let t=Dt.get(e);return t||(t=Mt(e),Dt.set(e,t)),t},Pt=(e,t)=>{let n=e;for(let e of t)n=n.childNodes[e];return n},Ft="html`...`: node-slot comment anchor has no parent node",It=e=>Array.isArray(e)?e:[e],Lt=(e,t,n)=>{let r=t.parentNode;for(p(r,Ft);e.fragment.firstChild;)r.insertBefore(e.fragment.firstChild,t);n.push(e.apply.bind(e))},Rt=(e,n)=>{let r=Nt(e),a=r.element.content.cloneNode(!0),o=[],s=[],c=r.slots.map((e,t)=>{let i=n[t];if(e.kind===Q.NODE){let t=e.commentId===void 0?void 0:r.commentPaths.get(e.commentId);return p(t,`compiled template is missing a comment path for node slot ${e.commentId}`),{comment:Pt(a,t),slot:e,value:i}}let o=e.elementId===void 0?void 0:r.elementPaths.get(e.elementId);return p(o,`compiled template is missing an element path for slot ${e.elementId}`),{el:Pt(a,o),slot:e,value:i}});for(let{comment:e,el:n,slot:r,value:a}of c){if(r.kind===Q.NODE){let n=e;if(p(n,`compiled template produced a node slot without a comment anchor`),Ie(a)){o.push({anchor:n,directive:a,type:`directive`});continue}if(K(a)){Lt(a,n,s),n.remove();continue}if(typeof a==`function`||i(a)){let e=t(typeof a==`function`?()=>It(a()):()=>It(a.value));o.push({anchor:n,signal:e,type:`html`});continue}if(Array.isArray(a)){for(let e of a)if(K(e))Lt(e,n,s);else{let t=n.parentNode;p(t,Ft),t.insertBefore(document.createTextNode(xt(e)),n)}n.remove();continue}n.replaceWith(document.createTextNode(xt(a)));continue}if(p(n,`compiled template produced an element slot without an element`),r.kind===Q.EVENT){let e=r.name;if(p(e,`compiled template produced an event slot without an event name`),typeof a==`function`)o.push({el:n,handler:a,name:e,type:`event`});else if(i(a)){let t=a;o.push({el:n,handler:e=>{let n=t.value;typeof n==`function`&&n(e)},name:e,type:`event`})}continue}if(r.kind===Q.REF){a&&o.push({el:n,ref:a,type:`ref`});continue}p(r.name,`compiled template produced an attr slot without an attribute name`),o.push(bt(n,r.mode??`attr`,r.name,a))}return Le(a,e=>{for(let t of o)yt(t,e);for(let t of s)t(e)})},zt=(e,...t)=>Rt(e,t),Bt={bubbles:!0,cancelable:!0,composed:!1},Vt=()=>{let e=A();return((t,...n)=>{let r=n.length>0?{...Bt,detail:n[0]}:Bt;return e.dispatchEvent(new CustomEvent(String(t),r))})},Ht=0,Ut=0,Wt=Math.random().toString(36).slice(2,6),Gt=(e=`id`)=>`${e}-${++Ht}`,Kt=(e=`id`)=>`${e}-${Wt}${++Ut}`,qt=()=>{Ut=0};export{c as OreApiError,s as OreError,l as OreInternalError,u as OreLifecycleError,$e as bind,Pe as classMap,pe as createContext,Gt as createId,Kt as createStableId,Te as css,Ne as define,Be as each,A as getHost,zt as html,ue as inject,de as injectStrict,Ve as live,M as onCleanup,ie as onElement,re as onEvent,ne as onFormReset,N as onMounted,he as prop,se as provide,Fe as ref,qt as resetStableIdCounter,We as styleMap,Ke as unsafeHtml,Vt as useEmit,Xe as useField,st as useSlots,P as watchEffect,Je as when};
3
3
  //# sourceMappingURL=ore.js.map