@vielzeug/ore 1.0.3 → 1.0.4

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.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@vielzeug/ripple");var t=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}},n=class extends t{constructor(e){super(e)}},r=class extends t{component;phase;constructor(e,t){super(e,{cause:t.cause}),this.component=t.component,this.phase=t.phase}};function i(e,t){`${e.component}${e.phase}`,e.cause,t.dispatchEvent(new CustomEvent(`ore:error`,{bubbles:!0,composed:!0,detail:e}))}var a=class extends t{},o={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}`,injectStrictFailed:(e,t)=>`injectStrict() could not resolve key "${e}" in <${t}>`,lifecycleOutsideSetup:`Lifecycle hooks must be called during component setup`,propInvalidReflect:`Structured props cannot use reflect:true — use prop.json() with reflect:false`,validationFailed:(e,t)=>`Validation failed for <${e}>:\n${t.join(`
2
- `)}`},s=e=>{for(let t=e.length-1;t>=0;t--)e[t]()},c=e=>{for(let t of e)t.remove()},l=new Set([`action`,`cite`,`codebase`,`data`,`formaction`,`href`,`manifest`,`ping`,`poster`,`src`,`xlink:href`]),u=/^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i,d=(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(l.has(r)&&u.test(i)){`${t}`,e.removeAttribute(t);return}e.setAttribute(t,i)},f=(e,t,n,r)=>{if(!e)return()=>{};let i=n;return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},p=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),m=e=>Array.isArray(e)||typeof e==`object`&&!!e,h=null,g=(e,t)=>{let n=h;h=e;try{return t()}finally{h=n}},ee=()=>h,_=()=>{if(h)return h.element;throw new n(o.lifecycleOutsideSetup)},v=t=>h?((0,e.onCleanup)(t),!0):!1,y=e.onCleanup,b=e=>{if(!h)throw new n(o.lifecycleOutsideSetup);h.mountCallbacks.push(e)},x=t=>{let n=(0,e.effect)(t),r=()=>n.dispose();return v(r),r};function te(e,t,r,i){if(!h)throw new n(o.lifecycleOutsideSetup);if(!e)return;let a=f(e,t,r,i);v(a)||a()}var ne=(e,t)=>x(()=>{let n=e.value;if(n)return t(n)}),re=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:`aria-${e}`,ie=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e,S=(e,t,n)=>{if(n==null||n===!1){e.removeAttribute(t);return}e.setAttribute(t,n===!0?`true`:String(n))},ae=(t,n)=>{let r=[];for(let[i,a]of Object.entries(n)){let n=re(i);if(typeof a==`function`){let i=(0,e.effect)(()=>S(t,n,a()));r.push(()=>i.dispose());continue}if((0,e.isReactive)(a)){let i=(0,e.effect)(()=>S(t,n,a.value));r.push(()=>i.dispose());continue}S(t,n,a)}return()=>{for(;r.length>0;)r.pop()?.()}},C=()=>(e,t)=>{let n=ae(e,t);return v(n),n},w=new WeakMap,oe=e=>{let t=[],n=e;for(;n;){n instanceof HTMLElement&&t.push(n);let e=n.getRootNode();n=n.parentElement??(e instanceof ShadowRoot?e.host:null)}return t},se=(e,t,n)=>{w.has(e)||w.set(e,new Map),w.get(e).set(t,n)},T=Symbol(`inject.not_found`),E=new WeakMap,ce=(e,t)=>{let n=oe(e);for(let e of n){let n=w.get(e);if(n?.has(t))return n.get(t)}return T};function D(e,...t){let r=ee();if(!r)throw new n(o.lifecycleOutsideSetup);let i=E.get(r);i||(i=new Map,E.set(r,i));let a=e;if(i.has(a)){let e=i.get(a);return e===T?t.length>0?t[0]:void 0:e}let s=ce(r.element,e);return i.set(a,s),s===T?t.length>0?t[0]:void 0:s}var le=e=>{let t=D(e,T);if(t!==T)return t;let r=_();throw new n(o.injectStrictFailed(String(e),r.localName))};function O(e){return Symbol(e)}var ue=e=>(t,n)=>{let r=n?.target??e,i=[];if(t.attr)for(let[e,n]of Object.entries(t.attr)){let t=fe(r,de(e),n);t&&i.push(t)}if(t.class&&i.push(me(r,t.class)),t.style)for(let[e,n]of Object.entries(t.style)){let t=pe(r,e,n);t&&i.push(t)}if(t.on){let{target:e,...a}=n??{};for(let e of Object.keys(t.on)){let n=t.on[e];n&&i.push(f(r,e,n,a))}}let a=()=>{for(let e of i)e()};return v(a),a},de=ie,k=(t,n)=>{if(typeof t==`function`)return x(()=>n(t()));if((0,e.isReactive)(t))return x(()=>n(t.value));n(t)};function fe(e,t,n){return k(n,n=>d(e,t,n))}var A=/[;{}]/g;function pe(e,t,n){let r=(t.startsWith(`--`)?t:p(t)).replace(A,``);if(!r)return;let i=!1;return k(n,t=>{t!=null&&t!==``?(i=!0,e.style.setProperty(r,String(t).replace(A,``))):i&&e.style.removeProperty(r)})}function me(t,n){let r=typeof n==`function`?n:()=>{let t={};for(let[r,i]of Object.entries(n))t[r]=typeof i==`function`?i():(0,e.isReactive)(i)?i.value:!!i;return t},i=new Set;return x(()=>{let e=new Set;for(let[n,a]of Object.entries(r()))a&&(e.add(n),i.has(n)||t.classList.add(n));for(let n of i)e.has(n)||t.classList.remove(n);i=e})}var he=`default`,j=e=>e||he,ge=t=>{let n=new Map,r=new Map,i=new Map,a=t=>{let r=n.get(t);return r||(r={elements:(0,e.signal)([]),presence:(0,e.signal)(!1)},n.set(t,r)),r},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=j(e),n=r.get(t),i=[];if(n)for(let e of n)i.push(...e.assignedElements({flatten:!0}));let s=a(t);o(s.elements.value,i)||(s.elements.value=i);let c=i.length>0;s.presence.value!==c&&(s.presence.value=c)},c=e=>{if(i.has(e))return;let t=j(e.getAttribute(`name`)),n=r.get(t)??new Set;n.add(e),r.set(t,n);let a=()=>s(t);e.addEventListener(`slotchange`,a),i.set(e,()=>{e.removeEventListener(`slotchange`,a)}),s(t)},l=e=>{let t=i.get(e);if(!t)return;t(),i.delete(e);let n=j(e.getAttribute(`name`)),a=r.get(n);a&&(a.delete(e),a.size===0&&r.delete(n)),s(n)},u=()=>{t.shadowRoot?.querySelectorAll(`slot`).forEach(e=>c(e))},d=()=>{for(let e of r.keys())s(e)},f=null;return t.shadowRoot&&(f=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)e instanceof HTMLSlotElement&&l(e);u(),d()}),f.observe(t.shadowRoot,{childList:!0,subtree:!0})),u(),b(()=>{u(),d()}),y(()=>{f?.disconnect(),f=null;for(let e of i.values())e();i.clear(),r.clear(),n.clear()}),{elements:e=>a(j(e)).elements,has:e=>a(j(e)).presence}},M={bubbles:!0,cancelable:!0,composed:!1},_e=e=>((t,...n)=>{let r=n.length>0?{...M,detail:n[0]}:M;e.dispatchEvent(new CustomEvent(String(t),r))}),ve=e=>{let t=ge(e),n=ue(e);return{aria:C(),bind:n,el:e,emit:_e(e),inject:D,onCleanup:y,onElement:ne,onEvent:te,onMounted:b,provide:(t,n)=>se(e,t,n),slots:t,watch:x}};function N(e){return{default:e,parse:()=>e,reflect:!1}}var P={bool(e){return{default:e??!1,parse:e=>e!==null&&e!==`false`,reflect:!0}},data(e){return N(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}}},F=e=>typeof e==`object`&&!!e&&`default`in e&&`parse`in e;function I(e,t){if(!F(e))throw new n(`Prop "${t}" must use a prop.* helper (string/number/bool/json/oneOf). Received: ${typeof e}`);let r=e;if(!r.parse)throw new n(`Prop "${t}" must have a parse function. Use prop.* helpers.`);let i=r.reflect??!1;if(i&&m(r.default))throw new n(`Prop "${t}": ${o.propInvalidReflect}`);return{...r,reflect:i}}function ye(e){let t=[];for(let[n,r]of Object.entries(e))try{I(r,n)}catch(e){t.push(e instanceof Error?e.message:String(e))}return t}var L=new WeakMap,R=(e,t)=>L.get(e)?.get(t),be=(t,n,r,i)=>{L.has(t)||L.set(t,new Map);let{default:a,parse:o,reflect:s=!1}=i,c=(0,e.signal)(a),l=Object.hasOwn(t,n),u=l?t[n]:void 0,f={parse:o,reflect:s,signal:c};return l?(delete t[n],c.value=u):t.hasAttribute(r)&&(c.value=o(t.getAttribute(r))),L.get(t).set(r,f),Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get:()=>c.value,set:e=>{c.value=e}}),s&&x(()=>{let e=c.value;e==null?t.removeAttribute(r):typeof e==`boolean`?t.toggleAttribute(r,e):d(t,r,e)}),c};function xe(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]=be(e,r,p(r),i);return n}var z={LOADING:`loading`,SETUP_DONE:`setup_done`,SETUP_RUNNING:`setup_running`,UNINITIALIZED:`uninitialized`,UNMOUNTED:`unmounted`},B={CONNECT:`ore:connect`,DISCONNECT:`ore:disconnect`};function Se(){return(0,e.signal)(null)}var V=e=>{let t=Symbol.for(e);return{is:e=>typeof e==`object`&&!!e&&t in e,stamp:e=>Object.assign(e,{[t]:!0})}},Ce=V(`ore:directive`).is,we=V(`ore:spread`).is,H=V(`ore:html-result`),U=H.is;function Te(e,t){return H.stamp({apply:t,fragment:e,mount:(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a}})}var W=new WeakSet,Ee=e=>typeof e==`object`&&!!e&&W.has(e),De=function(){return this.content},Oe=(e,...t)=>{let n=``;for(let r=0;r<e.length;r++)if(n+=e[r],r<t.length){let e=t[r];n+=Ee(e)?e.content:String(e)}let r={content:n.trim(),toString:De};return W.add(r),r},G=new Map,ke=e=>{if(e instanceof CSSStyleSheet)return e;let t=typeof e==`string`?e:e.content,n=G.get(t);if(n)return n;let r=new CSSStyleSheet;try{r.replaceSync(t)}catch{}return G.set(t,r),r},Ae=()=>({generation:0,mountCallbacks:[],phase:z.UNINITIALIZED,scope:(0,e.scope)(),templateResult:null}),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=Ae()}connectedCallback(){(0,e.untrack)(()=>{this._component.phase===z.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(B.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(t,n,r){if(n===r)return;let i=R(this,t);if(!i)return;let a=i.parse(r);Object.is((0,e.untrack)(()=>i.signal.value),a)||(i.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=z.UNMOUNTED,this.dispatchEvent(new CustomEvent(B.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=z.UNINITIALIZED,this._component.scope=(0,e.scope)(),this._component.templateResult=null}_handleSetupError(e,t=`setup`){let n=e instanceof Error?e:Error(String(e)),a=new r(`<${this.localName}> failed during ${this._component.phase} (${t})`,{cause:n,component:this.localName,phase:t}),o=this.constructor._definition;if(o?.onError)try{return o.onError(a,this)}catch{}i(a,this)}_runSetup(){this._component.phase=z.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n={element:this,mountCallbacks:[]};try{let r;if(this._component.scope.run(()=>{r=g(n,()=>{let n=t?xe(this,t):{},r=ve(this);return e.setup(n,r)})}),this._component.mountCallbacks.push(...n.mountCallbacks),r!=null&&typeof r.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=z.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(r,t,this._component.generation)}else this._component.templateResult=r??null,this._component.phase=z.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=z.SETUP_DONE;else throw this._component.phase=z.UNINITIALIZED,e}}async _runSetupAsync(e,t,n){try{let r=await e;if(this._component.generation!==n||!this.isConnected){`${this.localName}`;return}this._component.templateResult=r??null,this._component.phase=z.SETUP_DONE,this._component.mountCallbacks.push(...t),r&&this._applyResult(r),this._scheduleMountCallbacks()}catch(e){if(this._component.generation!==n||!this.isConnected){`${this.localName}`;return}let t=this._handleSetupError(e,`async-setup`);t?(this._component.templateResult=t,this._component.phase=z.SETUP_DONE,this._applyResult(t)):this._component.phase=z.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(y)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===z.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(ke))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(!this.isConnected||e!==this._component.generation)return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{g(t,()=>{let t=e();typeof t==`function`&&y(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};function Me(e,t){if(!e)throw new n(o.defineRequiresTag);if(customElements.get(e))throw new n(o.defineDuplicate(e));let{props:r}=t,i=(()=>{if(!r)return;let t=ye(r);if(t.length>0)throw new n(o.validationFailed(e,t));let i={};for(let[e,t]of Object.entries(r))i[e]=I(t,e);return i})(),a=i?Object.keys(i).map(p):[],s=class extends je{static _definition=t;static _normalizedPropDefs=i;static formAssociated=t.formAssociated??!1;static observedAttributes=a};Object.defineProperty(s,"name",{value:e}),customElements.define(e,s)}var Ne=new WeakSet,Pe=e=>typeof e==`object`&&!!e&&Ne.has(e),K=(t,n,r)=>{let i=(0,e.effect)(()=>n(t.value));r(()=>i.dispose())},Fe=e=>e.value,Ie=(e,t)=>{K(e.signal,t=>{e.node.textContent=String(t??``)},t)},Le=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,Re=(e,t,n,r)=>{let i=t==null?``:String(t);n&&r.last!==void 0&&!Object.is(e.value,r.last)&&!Object.is(e.value,i)||(e.value=i,n&&(r.last=i))},ze=(e,t,n,r)=>{let i=!!t;n&&r.last!==void 0&&e.checked!==!!r.last&&e.checked!==i||(e.checked=i,n&&(r.last=i))},Be=(t,n,r,i)=>{let a=m(i)?i:n.parse(r.mode===`bool`?i?``:null:i==null||i===!1?null:String(i));if(Object.is((0,e.untrack)(()=>n.signal.value),a)||(n.signal.value=a),!n.reflect){if(m(i))return;r.mode===`bool`?t.toggleAttribute(r.name,!!i):d(t,r.name,i)}},Ve=(t,n)=>{let{el:r,mode:i,name:a,propMeta:o}=t,s={last:void 0},c=n=>{if(o){Be(r,o,t,n);return}if(!(0,e.isReactive)(n)&&m(n)){a!==`__proto__`&&a!==`constructor`&&a!==`prototype`&&(r[a]=n);return}if(a===`value`&&Le(r)){Re(r,n,t.live,s);return}if(a===`checked`&&r instanceof HTMLInputElement){ze(r,n,t.live,s);return}i===`bool`?r.toggleAttribute(a,!!n):d(r,a,n)};`signal`in t?K(t.signal,c,n):c(t.value)},He=(e,t)=>{t(f(e.el,e.name,e.handler,e.options))},Ue=(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})},We=(e,t,n)=>{let r=[],i=t.parentNode;for(let a of e)if(U(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},Ge=(t,n)=>{let{anchor:r,signal:i}=t,a=[],o=()=>{s(a),a=[]},l=[],u=(0,e.effect)(()=>{let t=Fe(i);o(),c(l),l=[],!(t==null||t.length===0)&&(0,e.untrack)(()=>{l=We(t,r,e=>a.push(e))})});n(()=>{u.dispose(),o(),c(l)})},Ke=(e,t)=>{e.directive.mount(e.anchor,t)},qe=(e,t)=>{e.spread.apply(e.el,t)},Je=(e,t)=>{switch(e.type){case`attr`:Ve(e,t);break;case`directive`:Ke(e,t);break;case`event`:He(e,t);break;case`html`:Ge(e,t);break;case`ref`:Ue(e,t);break;case`spread`:qe(e,t);break;case`text`:Ie(e,t);break}},Ye=(t,n,r,i)=>{let a=R(t,r);return Pe(i)?{el:t,live:!0,mode:n,name:r,propMeta:a,signal:i,type:`attr`}:typeof i==`function`?{el:t,mode:n,name:r,propMeta:a,signal:(0,e.computed)(i),type:`attr`}:(0,e.isReactive)(i)?{el:t,mode:n,name:r,propMeta:a,signal:i,type:`attr`}:{el:t,mode:n,name:r,propMeta:a,type:`attr`,value:i}},q=e=>e==null?``:String(e),Xe={prevent:e=>t=>{t.preventDefault(),e(t)},self:e=>t=>{t.target===t.currentTarget&&e(t)},stop:e=>t=>{t.stopPropagation(),e(t)}},J=(e,t)=>{let n=e;for(let e of t){let t=Xe[e];t&&(n=t(n))}let r={};return t.includes(`capture`)&&(r.capture=!0),t.includes(`once`)&&(r.once=!0),t.includes(`passive`)&&(r.passive=!0),{handler:n,...Object.keys(r).length?{options:r}:{}}},Ze=/\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/,Qe=/\s+ref\s*=\s*["']?$/,$e=/\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,et=/\s+:?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,tt=e=>{let t=e.lastIndexOf(`<`);return t<=e.lastIndexOf(`>`)?!1:e[t+1]!==`/`},nt=e=>{let t,n=e.trimEnd();if(n.endsWith(`</`))return{kind:`closeTag`,prefix:e};if(n.endsWith(`<`))return{kind:`tagname`,prefix:e};if(t=Ze.exec(e)){let n=e.slice(0,-t[0].length),r=t[1].split(`.`);return{kind:`event`,modifiers:r.slice(1),name:r[0],prefix:n}}return(t=Qe.exec(e))?{kind:`ref`,prefix:e.slice(0,-t[0].length)}:(t=$e.exec(e))?{kind:`boolAttr`,name:t[1],prefix:e.slice(0,-t[0].length)}:(t=et.exec(e))?{kind:`attr`,name:t[1],prefix:e.slice(0,-t[0].length)}:tt(e)?{kind:`spread`,prefix:e.trimEnd()}:{kind:`node`,prefix:e}},Y=new WeakMap,rt=e=>{let t=Array.from(e);for(let e=0;e<t.length-1;e++){let n=t[e],r=n[n.length-1];if(r===`"`||r===`'`){t[e]=n.slice(0,-1);let i=t[e+1];i.startsWith(r)&&(t[e+1]=i.slice(1))}if(t[e].trimEnd().endsWith(`</`)){let n=t[e+1];n.startsWith(`>`)&&(t[e+1]=n.slice(1))}}return t},X=(e,t,n,r)=>{if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.getAttribute(`u`);i!==null&&(n.set(Number(i),[...t]),r.removeAttribute(`u`))}else if(e.nodeType===Node.COMMENT_NODE){let n=e.nodeValue;n!==null&&/^\d+$/.test(n)&&r.set(Number(n),[...t])}let i=e.childNodes;for(let e=0;e<i.length;e++)X(i[e],[...t,e],n,r)},it=e=>{let t=rt(e),n=``,r,i=0,a=0,o=[],s=[];for(let e=0;e<t.length-1;e++){let c=t[e],l=nt(c);if(l.kind===`tagname`){let e=i++;r=e,s.push(e);let t=c.replace(/<\s*$/,``);n+=t+`<ore-dyn-${e} u="${e}"`,o.push({elementId:e,kind:`tagname`})}else if(l.kind===`closeTag`){let e=s.pop()??0,t=c.replace(/<\/\s*$/,``);n+=t+`</ore-dyn-${e}>`,o.push({kind:`closeTag`}),r=void 0}else if(l.kind===`node`)n+=l.prefix+`<!--${a}-->`,o.push({commentId:a,kind:`node`}),a++,r=void 0;else{r===void 0||l.prefix.lastIndexOf(`<`)>l.prefix.lastIndexOf(`>`)?(r=i++,n+=`${l.prefix} u="${r}"`):n+=l.prefix;let e=l.kind===`boolAttr`?`bool`:l.kind===`attr`?`attr`:void 0;o.push({elementId:r,kind:l.kind,mode:e,modifiers:l.modifiers,name:l.name})}}n+=t[t.length-1]??``;let c=document.createElement(`template`);c.innerHTML=n;let l=new Map,u=new Map,d=c.content.childNodes;for(let e=0;e<d.length;e++)X(d[e],[e],l,u);return{commentPaths:u,element:c,elementPaths:l,slots:o}},at=e=>{let t=Y.get(e);return t||(t=it(e),Y.set(e,t)),t},Z=(e,t)=>{let n=e;for(let e of t)n=n.childNodes[e];return n},ot=(t,n)=>{let r=at(t),i=r.element.content.cloneNode(!0),a=[],o=[],s=r.slots.map((e,t)=>{let a=n[t];return e.kind===`closeTag`?{slot:e,value:a}:e.kind===`node`?{comment:Z(i,r.commentPaths.get(e.commentId)),slot:e,value:a}:{el:Z(i,r.elementPaths.get(e.elementId)),slot:e,value:a}}),c=new Map;for(let{el:e,slot:t,value:n}of s){if(t.kind!==`tagname`)continue;let r=String(n);if(!/^[a-z][a-z0-9._-]*$/i.test(r)){`${r}`;continue}let i=document.createElement(r);for(let t of Array.from(e.attributes))i.setAttribute(t.name,t.value);for(;e.firstChild;)i.appendChild(e.firstChild);e.replaceWith(i),c.set(e,i)}for(let{comment:t,el:n,slot:r,value:i}of s){if(r.kind===`tagname`||r.kind===`closeTag`)continue;let s=n&&(c.get(n)??n);if(r.kind===`node`){let n=t;if(Ce(i)){a.push({anchor:n,directive:i,type:`directive`});continue}if(U(i)){let e=n.parentNode;for(;i.fragment.firstChild;)e.insertBefore(i.fragment.firstChild,n);n.remove(),o.push(i.apply.bind(i));continue}if(typeof i==`function`){let t=(0,e.computed)(()=>{let e=i();return Array.isArray(e)?e:[e]});a.push({anchor:n,signal:t,type:`html`});continue}if((0,e.isReactive)(i)){let t=(0,e.computed)(()=>{let e=i.value;return Array.isArray(e)?e:[e]});a.push({anchor:n,signal:t,type:`html`});continue}if(Array.isArray(i)){let e=n.parentNode;for(let t of i)if(U(t)){for(;t.fragment.firstChild;)e.insertBefore(t.fragment.firstChild,n);o.push(t.apply.bind(t))}else e.insertBefore(document.createTextNode(q(t)),n);n.remove();continue}n.replaceWith(document.createTextNode(q(i)));continue}let l=s;if(r.kind===`event`){if(typeof i==`function`){let{handler:e,options:t}=J(i,r.modifiers??[]);a.push({el:l,handler:e,name:r.name,options:t,type:`event`})}else if((0,e.isReactive)(i)){let e=i,{handler:t,options:n}=J(t=>{let n=e.value;typeof n==`function`&&n(t)},r.modifiers??[]);a.push({el:l,handler:t,name:r.name,options:n,type:`event`})}continue}if(r.kind===`ref`){i&&a.push({el:l,ref:i,type:`ref`});continue}if(r.kind===`spread`){we(i)&&a.push({el:l,spread:i,type:`spread`});continue}a.push(Ye(l,r.mode??`attr`,r.name,i))}return Te(i,e=>{for(let t of a)Je(t,e);for(let t of o)t(e)})},st=(e,...t)=>ot(e,t),Q=new WeakMap,ct=e=>{let t=e.el??_();if(!t.constructor.formAssociated)throw new n(o.defineFieldRequiresFormAssociated(t.localName));if(Q.has(t))throw new n(`useField() was already called on <${t.localName}>. Call it only once per component.`);let r=t.attachInternals();Q.set(t,r),y(()=>Q.delete(t));let i=e.toFormValue??(t=>t==null?e.emptyStringForNull?``:null:t instanceof File||t instanceof FormData?t:String(t));x(()=>{r.setFormValue(i(e.value.value))});let a=e.disabled;if(a&&`states`in r){let e=r.states;x(()=>{a.value?e.add(`disabled`):e.delete(`disabled`)})}return{checkValidity:()=>r.checkValidity(),internals:r,reportValidity:()=>r.reportValidity(),setCustomValidity:e=>e?r.setValidity({customError:!0},e):r.setValidity({}),setValidity:r.setValidity.bind(r)}},lt=O(`ore:form-context`);function ut(t={}){let n=(0,e.signal)([]),r=(0,e.signal)(!1),i=(0,e.signal)(!1),a=(0,e.signal)(null);return{clearStatus:()=>{i.value=!1,a.value=null,t.onReset?.()},dirty:i,error:a,markDirty:()=>{i.value=!0},registerField:e=>(n.value=[...n.value,e],()=>{n.value=n.value.filter(t=>t!==e)}),submit:async e=>{if(e?.preventDefault(),!r.value){r.value=!0,a.value=null;try{await t.onSubmit?.(e),i.value=!1}catch(e){a.value=e}finally{r.value=!1}}},submitting:r,valid:(0,e.computed)(()=>n.value.every(e=>e.value))}}var dt=0,$=0,ft=Math.random().toString(36).slice(2,6),pt=(e=`id`)=>`${e}-${++dt}`,mt=(e=`id`)=>`${e}-${ft}${++$}`,ht=()=>{$=0};exports.FORM_CONTEXT_KEY=lt,exports.OreApiError=n,exports.OreError=t,exports.OreLifecycleError=r,exports.OreTimeoutError=a,exports.createContext=O,exports.createFormContext=ut,exports.createId=pt,exports.createStableId=mt,exports.css=Oe,exports.define=Me,exports.html=st,exports.inject=D,exports.injectStrict=le,exports.prop=P,exports.ref=Se,exports.resetIdCounter=ht,exports.useField=ct;
2
+ `)}`},s=e=>{for(let t=e.length-1;t>=0;t--)e[t]()},c=e=>{for(let t of e)t.remove()},l=new Set([`action`,`cite`,`codebase`,`data`,`formaction`,`href`,`manifest`,`ping`,`poster`,`src`,`xlink:href`]),u=/^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i,d=(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(l.has(r)&&u.test(i)){`${t}`,e.removeAttribute(t);return}e.setAttribute(t,i)},f=(e,t,n,r)=>{if(!e)return()=>{};let i=n;return e.addEventListener(t,i,r),()=>e.removeEventListener(t,i,r)},p=e=>e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),m=e=>Array.isArray(e)||typeof e==`object`&&!!e,h=null,g=(e,t)=>{let n=h;h=e;try{return t()}finally{h=n}},ee=()=>h,_=()=>{if(h)return h.element;throw new n(o.lifecycleOutsideSetup)},v=t=>h?((0,e.onCleanup)(t),!0):!1,y=e.onCleanup,b=e=>{if(!h)throw new n(o.lifecycleOutsideSetup);h.mountCallbacks.push(e)},x=t=>{let n=(0,e.effect)(t),r=()=>n.dispose();return v(r),r};function te(e,t,r,i){if(!h)throw new n(o.lifecycleOutsideSetup);if(!e)return;let a=f(e,t,r,i);v(a)||a()}var ne=(e,t)=>x(()=>{let n=e.value;if(n)return t(n)}),re=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:`aria-${e}`,ie=e=>e===`role`||e.startsWith(`aria-`)?e:e.startsWith(`aria`)?`aria-${e.slice(4).toLowerCase()}`:e,S=(e,t,n)=>{if(n==null||n===!1){e.removeAttribute(t);return}e.setAttribute(t,n===!0?`true`:String(n))},ae=(t,n)=>{let r=[];for(let[i,a]of Object.entries(n)){let n=re(i);if(typeof a==`function`){let i=(0,e.effect)(()=>S(t,n,a()));r.push(()=>i.dispose());continue}if((0,e.isReactive)(a)){let i=(0,e.effect)(()=>S(t,n,a.value));r.push(()=>i.dispose());continue}S(t,n,a)}return()=>{for(;r.length>0;)r.pop()?.()}},C=()=>(e,t)=>{let n=ae(e,t);return v(n),n},w=new WeakMap,oe=e=>{let t=[],n=e;for(;n;){n instanceof HTMLElement&&t.push(n);let e=n.getRootNode();n=n.parentElement??(e instanceof ShadowRoot?e.host:null)}return t},se=(e,t,n)=>{w.has(e)||w.set(e,new Map),w.get(e).set(t,n)},T=Symbol(`inject.not_found`),E=new WeakMap,ce=(e,t)=>{let n=oe(e);for(let e of n){let n=w.get(e);if(n?.has(t))return n.get(t)}return T};function D(e,...t){let r=ee();if(!r)throw new n(o.lifecycleOutsideSetup);let i=E.get(r);i||(i=new Map,E.set(r,i));let a=e;if(i.has(a)){let e=i.get(a);return e===T?t.length>0?t[0]:void 0:e}let s=ce(r.element,e);return i.set(a,s),s===T?t.length>0?t[0]:void 0:s}var le=e=>{let t=D(e,T);if(t!==T)return t;let r=_();throw new n(o.injectStrictFailed(String(e),r.localName))};function O(e){return Symbol(e)}var ue=e=>(t,n)=>{let r=n?.target??e,i=[];if(t.attr)for(let[e,n]of Object.entries(t.attr)){let t=fe(r,de(e),n);t&&i.push(t)}if(t.class&&i.push(me(r,t.class)),t.style)for(let[e,n]of Object.entries(t.style)){let t=pe(r,e,n);t&&i.push(t)}if(t.on){let{target:e,...a}=n??{};for(let e of Object.keys(t.on)){let n=t.on[e];n&&i.push(f(r,e,n,a))}}let a=()=>{for(let e of i)e()};return v(a),a},de=ie,k=(t,n)=>{if(typeof t==`function`)return x(()=>n(t()));if((0,e.isReactive)(t))return x(()=>n(t.value));n(t)};function fe(e,t,n){return k(n,n=>d(e,t,n))}var A=/[;{}]/g;function pe(e,t,n){let r=(t.startsWith(`--`)?t:p(t)).replace(A,``);if(!r)return;let i=!1;return k(n,t=>{t!=null&&t!==``?(i=!0,e.style.setProperty(r,String(t).replace(A,``))):i&&e.style.removeProperty(r)})}function me(t,n){let r=typeof n==`function`?n:()=>{let t={};for(let[r,i]of Object.entries(n))t[r]=typeof i==`function`?i():(0,e.isReactive)(i)?i.value:!!i;return t},i=new Set;return x(()=>{let e=new Set;for(let[n,a]of Object.entries(r()))a&&(e.add(n),i.has(n)||t.classList.add(n));for(let n of i)e.has(n)||t.classList.remove(n);i=e})}var he=`default`,j=e=>e||he,ge=t=>{let n=new Map,r=new Map,i=new Map,a=t=>{let r=n.get(t);return r||(r={elements:(0,e.signal)([]),presence:(0,e.signal)(!1)},n.set(t,r)),r},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=j(e),n=r.get(t),i=[];if(n)for(let e of n)i.push(...e.assignedElements({flatten:!0}));let s=a(t);o(s.elements.value,i)||(s.elements.value=i);let c=i.length>0;s.presence.value!==c&&(s.presence.value=c)},c=e=>{if(i.has(e))return;let t=j(e.getAttribute(`name`)),n=r.get(t)??new Set;n.add(e),r.set(t,n);let a=()=>s(t);e.addEventListener(`slotchange`,a),i.set(e,()=>{e.removeEventListener(`slotchange`,a)}),s(t)},l=e=>{let t=i.get(e);if(!t)return;t(),i.delete(e);let n=j(e.getAttribute(`name`)),a=r.get(n);a&&(a.delete(e),a.size===0&&r.delete(n)),s(n)},u=()=>{t.shadowRoot?.querySelectorAll(`slot`).forEach(e=>c(e))},d=()=>{for(let e of r.keys())s(e)},f=null;return t.shadowRoot&&(f=new MutationObserver(e=>{for(let t of e)for(let e of t.removedNodes)e instanceof HTMLSlotElement&&l(e);u(),d()}),f.observe(t.shadowRoot,{childList:!0,subtree:!0})),u(),b(()=>{u(),d()}),y(()=>{f?.disconnect(),f=null;for(let e of i.values())e();i.clear(),r.clear(),n.clear()}),{elements:e=>a(j(e)).elements,has:e=>a(j(e)).presence}},M={bubbles:!0,cancelable:!0,composed:!1},_e=e=>((t,...n)=>{let r=n.length>0?{...M,detail:n[0]}:M;e.dispatchEvent(new CustomEvent(String(t),r))}),ve=e=>{let t=ge(e),n=ue(e);return{aria:C(),bind:n,el:e,emit:_e(e),inject:D,onCleanup:y,onElement:ne,onEvent:te,onMounted:b,provide:(t,n)=>se(e,t,n),slots:t,watch:x}};function N(e){return{default:e,parse:()=>e,reflect:!1}}var P={bool(e){return{default:e??!1,parse:e=>e!==null&&e!==`false`,reflect:!0}},data(e){return N(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}}},F=e=>typeof e==`object`&&!!e&&`default`in e&&`parse`in e;function I(e,t){if(!F(e))throw new n(`Prop "${t}" must use a prop.* helper (string/number/bool/json/oneOf). Received: ${typeof e}`);let r=e;if(!r.parse)throw new n(`Prop "${t}" must have a parse function. Use prop.* helpers.`);let i=r.reflect??!1;if(i&&m(r.default))throw new n(`Prop "${t}": ${o.propInvalidReflect}`);return{...r,reflect:i}}function ye(e){let t=[];for(let[n,r]of Object.entries(e))try{I(r,n)}catch(e){t.push(e instanceof Error?e.message:String(e))}return t}var L=new WeakMap,R=(e,t)=>L.get(e)?.get(t),be=(t,n,r,i)=>{L.has(t)||L.set(t,new Map);let{default:a,parse:o,reflect:s=!1}=i,c=(0,e.signal)(a),l=Object.hasOwn(t,n),u=l?t[n]:void 0,f={parse:o,reflect:s,signal:c};return l?(delete t[n],c.value=typeof u==`string`?o(u):u):t.hasAttribute(r)&&(c.value=o(t.getAttribute(r))),L.get(t).set(r,f),Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get:()=>c.value,set:e=>{c.value=typeof e==`string`?o(e):e}}),s&&x(()=>{let e=c.value;e==null?t.removeAttribute(r):typeof e==`boolean`?t.toggleAttribute(r,e):d(t,r,e)}),c};function xe(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]=be(e,r,p(r),i);return n}var z={LOADING:`loading`,SETUP_DONE:`setup_done`,SETUP_RUNNING:`setup_running`,UNINITIALIZED:`uninitialized`,UNMOUNTED:`unmounted`},B={CONNECT:`ore:connect`,DISCONNECT:`ore:disconnect`};function Se(){return(0,e.signal)(null)}var V=e=>{let t=Symbol.for(e);return{is:e=>typeof e==`object`&&!!e&&t in e,stamp:e=>Object.assign(e,{[t]:!0})}},Ce=V(`ore:directive`).is,we=V(`ore:spread`).is,H=V(`ore:html-result`),U=H.is;function Te(e,t){return H.stamp({apply:t,fragment:e,mount:(n,r,i)=>{let a=Array.from(e.childNodes);return n.insertBefore(e,r),t(i),a}})}var W=new WeakSet,Ee=e=>typeof e==`object`&&!!e&&W.has(e),De=function(){return this.content},Oe=(e,...t)=>{let n=``;for(let r=0;r<e.length;r++)if(n+=e[r],r<t.length){let e=t[r];n+=Ee(e)?e.content:String(e)}let r={content:n.trim(),toString:De};return W.add(r),r},G=new Map,ke=e=>{if(e instanceof CSSStyleSheet)return e;let t=typeof e==`string`?e:e.content,n=G.get(t);if(n)return n;let r=new CSSStyleSheet;try{r.replaceSync(t)}catch{}return G.set(t,r),r},Ae=()=>({generation:0,mountCallbacks:[],phase:z.UNINITIALIZED,scope:(0,e.scope)(),templateResult:null}),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=Ae()}connectedCallback(){(0,e.untrack)(()=>{this._component.phase===z.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(B.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(t,n,r){if(n===r)return;let i=R(this,t);if(!i)return;let a=i.parse(r);Object.is((0,e.untrack)(()=>i.signal.value),a)||(i.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=z.UNMOUNTED,this.dispatchEvent(new CustomEvent(B.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=z.UNINITIALIZED,this._component.scope=(0,e.scope)(),this._component.templateResult=null}_handleSetupError(e,t=`setup`){let n=e instanceof Error?e:Error(String(e)),a=new r(`<${this.localName}> failed during ${this._component.phase} (${t})`,{cause:n,component:this.localName,phase:t}),o=this.constructor._definition;if(o?.onError)try{return o.onError(a,this)}catch{}i(a,this)}_runSetup(){this._component.phase=z.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n={element:this,mountCallbacks:[]};try{let r;if(this._component.scope.run(()=>{r=g(n,()=>{let n=t?xe(this,t):{},r=ve(this);return e.setup(n,r)})}),this._component.mountCallbacks.push(...n.mountCallbacks),r!=null&&typeof r.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=z.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(r,t,this._component.generation)}else this._component.templateResult=r??null,this._component.phase=z.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=z.SETUP_DONE;else throw this._component.phase=z.UNINITIALIZED,e}}async _runSetupAsync(e,t,n){try{let r=await e;if(this._component.generation!==n||!this.isConnected){`${this.localName}`;return}this._component.templateResult=r??null,this._component.phase=z.SETUP_DONE,this._component.mountCallbacks.push(...t),r&&this._applyResult(r),this._scheduleMountCallbacks()}catch(e){if(this._component.generation!==n||!this.isConnected){`${this.localName}`;return}let t=this._handleSetupError(e,`async-setup`);t?(this._component.templateResult=t,this._component.phase=z.SETUP_DONE,this._applyResult(t)):this._component.phase=z.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(y)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===z.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(ke))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(!this.isConnected||e!==this._component.generation)return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{g(t,()=>{let t=e();typeof t==`function`&&y(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};function Me(e,t){if(!e)throw new n(o.defineRequiresTag);if(customElements.get(e))throw new n(o.defineDuplicate(e));let{props:r}=t,i=(()=>{if(!r)return;let t=ye(r);if(t.length>0)throw new n(o.validationFailed(e,t));let i={};for(let[e,t]of Object.entries(r))i[e]=I(t,e);return i})(),a=i?Object.keys(i).map(p):[],s=class extends je{static _definition=t;static _normalizedPropDefs=i;static formAssociated=t.formAssociated??!1;static observedAttributes=a};Object.defineProperty(s,"name",{value:e}),customElements.define(e,s)}var Ne=new WeakSet,Pe=e=>typeof e==`object`&&!!e&&Ne.has(e),K=(t,n,r)=>{let i=(0,e.effect)(()=>n(t.value));r(()=>i.dispose())},Fe=e=>e.value,Ie=(e,t)=>{K(e.signal,t=>{e.node.textContent=String(t??``)},t)},Le=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement,Re=(e,t,n,r)=>{let i=t==null?``:String(t);n&&r.last!==void 0&&!Object.is(e.value,r.last)&&!Object.is(e.value,i)||(e.value=i,n&&(r.last=i))},ze=(e,t,n,r)=>{let i=!!t;n&&r.last!==void 0&&e.checked!==!!r.last&&e.checked!==i||(e.checked=i,n&&(r.last=i))},Be=(t,n,r,i)=>{let a=m(i)?i:n.parse(r.mode===`bool`?i?``:null:i==null||i===!1?null:String(i));if(Object.is((0,e.untrack)(()=>n.signal.value),a)||(n.signal.value=a),!n.reflect){if(m(i))return;r.mode===`bool`?t.toggleAttribute(r.name,!!i):d(t,r.name,i)}},Ve=(t,n)=>{let{el:r,mode:i,name:a,propMeta:o}=t,s={last:void 0},c=n=>{if(o){Be(r,o,t,n);return}if(!(0,e.isReactive)(n)&&m(n)){a!==`__proto__`&&a!==`constructor`&&a!==`prototype`&&(r[a]=n);return}if(a===`value`&&Le(r)){Re(r,n,t.live,s);return}if(a===`checked`&&r instanceof HTMLInputElement){ze(r,n,t.live,s);return}i===`bool`?r.toggleAttribute(a,!!n):d(r,a,n)};`signal`in t?K(t.signal,c,n):c(t.value)},He=(e,t)=>{t(f(e.el,e.name,e.handler,e.options))},Ue=(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})},We=(e,t,n)=>{let r=[],i=t.parentNode;for(let a of e)if(U(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},Ge=(t,n)=>{let{anchor:r,signal:i}=t,a=[],o=()=>{s(a),a=[]},l=[],u=(0,e.effect)(()=>{let t=Fe(i);o(),c(l),l=[],!(t==null||t.length===0)&&(0,e.untrack)(()=>{l=We(t,r,e=>a.push(e))})});n(()=>{u.dispose(),o(),c(l)})},Ke=(e,t)=>{e.directive.mount(e.anchor,t)},qe=(e,t)=>{e.spread.apply(e.el,t)},Je=(e,t)=>{switch(e.type){case`attr`:Ve(e,t);break;case`directive`:Ke(e,t);break;case`event`:He(e,t);break;case`html`:Ge(e,t);break;case`ref`:Ue(e,t);break;case`spread`:qe(e,t);break;case`text`:Ie(e,t);break}},Ye=(t,n,r,i)=>{let a=R(t,r);return Pe(i)?{el:t,live:!0,mode:n,name:r,propMeta:a,signal:i,type:`attr`}:typeof i==`function`?{el:t,mode:n,name:r,propMeta:a,signal:(0,e.computed)(i),type:`attr`}:(0,e.isReactive)(i)?{el:t,mode:n,name:r,propMeta:a,signal:i,type:`attr`}:{el:t,mode:n,name:r,propMeta:a,type:`attr`,value:i}},q=e=>e==null?``:String(e),Xe={prevent:e=>t=>{t.preventDefault(),e(t)},self:e=>t=>{t.target===t.currentTarget&&e(t)},stop:e=>t=>{t.stopPropagation(),e(t)}},J=(e,t)=>{let n=e;for(let e of t){let t=Xe[e];t&&(n=t(n))}let r={};return t.includes(`capture`)&&(r.capture=!0),t.includes(`once`)&&(r.once=!0),t.includes(`passive`)&&(r.passive=!0),{handler:n,...Object.keys(r).length?{options:r}:{}}},Ze=/\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/,Qe=/\s+ref\s*=\s*["']?$/,$e=/\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,et=/\s+:?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/,tt=e=>{let t=e.lastIndexOf(`<`);return t<=e.lastIndexOf(`>`)?!1:e[t+1]!==`/`},nt=e=>{let t,n=e.trimEnd();if(n.endsWith(`</`))return{kind:`closeTag`,prefix:e};if(n.endsWith(`<`))return{kind:`tagname`,prefix:e};if(t=Ze.exec(e)){let n=e.slice(0,-t[0].length),r=t[1].split(`.`);return{kind:`event`,modifiers:r.slice(1),name:r[0],prefix:n}}return(t=Qe.exec(e))?{kind:`ref`,prefix:e.slice(0,-t[0].length)}:(t=$e.exec(e))?{kind:`boolAttr`,name:t[1],prefix:e.slice(0,-t[0].length)}:(t=et.exec(e))?{kind:`attr`,name:t[1],prefix:e.slice(0,-t[0].length)}:tt(e)?{kind:`spread`,prefix:e.trimEnd()}:{kind:`node`,prefix:e}},Y=new WeakMap,rt=e=>{let t=Array.from(e);for(let e=0;e<t.length-1;e++){let n=t[e],r=n[n.length-1];if(r===`"`||r===`'`){t[e]=n.slice(0,-1);let i=t[e+1];i.startsWith(r)&&(t[e+1]=i.slice(1))}if(t[e].trimEnd().endsWith(`</`)){let n=t[e+1];n.startsWith(`>`)&&(t[e+1]=n.slice(1))}}return t},X=(e,t,n,r)=>{if(e.nodeType===Node.ELEMENT_NODE){let r=e,i=r.getAttribute(`u`);i!==null&&(n.set(Number(i),[...t]),r.removeAttribute(`u`))}else if(e.nodeType===Node.COMMENT_NODE){let n=e.nodeValue;n!==null&&/^\d+$/.test(n)&&r.set(Number(n),[...t])}let i=e.childNodes;for(let e=0;e<i.length;e++)X(i[e],[...t,e],n,r)},it=e=>{let t=rt(e),n=``,r,i=0,a=0,o=[],s=[];for(let e=0;e<t.length-1;e++){let c=t[e],l=nt(c);if(l.kind===`tagname`){let e=i++;r=e,s.push(e);let t=c.replace(/<\s*$/,``);n+=t+`<ore-dyn-${e} u="${e}"`,o.push({elementId:e,kind:`tagname`})}else if(l.kind===`closeTag`){let e=s.pop()??0,t=c.replace(/<\/\s*$/,``);n+=t+`</ore-dyn-${e}>`,o.push({kind:`closeTag`}),r=void 0}else if(l.kind===`node`)n+=l.prefix+`<!--${a}-->`,o.push({commentId:a,kind:`node`}),a++,r=void 0;else{r===void 0||l.prefix.lastIndexOf(`<`)>l.prefix.lastIndexOf(`>`)?(r=i++,n+=`${l.prefix} u="${r}"`):n+=l.prefix;let e=l.kind===`boolAttr`?`bool`:l.kind===`attr`?`attr`:void 0;o.push({elementId:r,kind:l.kind,mode:e,modifiers:l.modifiers,name:l.name})}}n+=t[t.length-1]??``;let c=document.createElement(`template`);c.innerHTML=n;let l=new Map,u=new Map,d=c.content.childNodes;for(let e=0;e<d.length;e++)X(d[e],[e],l,u);return{commentPaths:u,element:c,elementPaths:l,slots:o}},at=e=>{let t=Y.get(e);return t||(t=it(e),Y.set(e,t)),t},Z=(e,t)=>{let n=e;for(let e of t)n=n.childNodes[e];return n},ot=(t,n)=>{let r=at(t),i=r.element.content.cloneNode(!0),a=[],o=[],s=r.slots.map((e,t)=>{let a=n[t];return e.kind===`closeTag`?{slot:e,value:a}:e.kind===`node`?{comment:Z(i,r.commentPaths.get(e.commentId)),slot:e,value:a}:{el:Z(i,r.elementPaths.get(e.elementId)),slot:e,value:a}}),c=new Map;for(let{el:e,slot:t,value:n}of s){if(t.kind!==`tagname`)continue;let r=String(n);if(!/^[a-z][a-z0-9._-]*$/i.test(r)){`${r}`;continue}let i=document.createElement(r);for(let t of Array.from(e.attributes))i.setAttribute(t.name,t.value);for(;e.firstChild;)i.appendChild(e.firstChild);e.replaceWith(i),c.set(e,i)}for(let{comment:t,el:n,slot:r,value:i}of s){if(r.kind===`tagname`||r.kind===`closeTag`)continue;let s=n&&(c.get(n)??n);if(r.kind===`node`){let n=t;if(Ce(i)){a.push({anchor:n,directive:i,type:`directive`});continue}if(U(i)){let e=n.parentNode;for(;i.fragment.firstChild;)e.insertBefore(i.fragment.firstChild,n);n.remove(),o.push(i.apply.bind(i));continue}if(typeof i==`function`){let t=(0,e.computed)(()=>{let e=i();return Array.isArray(e)?e:[e]});a.push({anchor:n,signal:t,type:`html`});continue}if((0,e.isReactive)(i)){let t=(0,e.computed)(()=>{let e=i.value;return Array.isArray(e)?e:[e]});a.push({anchor:n,signal:t,type:`html`});continue}if(Array.isArray(i)){let e=n.parentNode;for(let t of i)if(U(t)){for(;t.fragment.firstChild;)e.insertBefore(t.fragment.firstChild,n);o.push(t.apply.bind(t))}else e.insertBefore(document.createTextNode(q(t)),n);n.remove();continue}n.replaceWith(document.createTextNode(q(i)));continue}let l=s;if(r.kind===`event`){if(typeof i==`function`){let{handler:e,options:t}=J(i,r.modifiers??[]);a.push({el:l,handler:e,name:r.name,options:t,type:`event`})}else if((0,e.isReactive)(i)){let e=i,{handler:t,options:n}=J(t=>{let n=e.value;typeof n==`function`&&n(t)},r.modifiers??[]);a.push({el:l,handler:t,name:r.name,options:n,type:`event`})}continue}if(r.kind===`ref`){i&&a.push({el:l,ref:i,type:`ref`});continue}if(r.kind===`spread`){we(i)&&a.push({el:l,spread:i,type:`spread`});continue}a.push(Ye(l,r.mode??`attr`,r.name,i))}return Te(i,e=>{for(let t of a)Je(t,e);for(let t of o)t(e)})},st=(e,...t)=>ot(e,t),Q=new WeakMap,ct=e=>{let t=e.el??_();if(!t.constructor.formAssociated)throw new n(o.defineFieldRequiresFormAssociated(t.localName));if(Q.has(t))throw new n(`useField() was already called on <${t.localName}>. Call it only once per component.`);let r=t.attachInternals();Q.set(t,r),y(()=>Q.delete(t));let i=e.toFormValue??(t=>t==null?e.emptyStringForNull?``:null:t instanceof File||t instanceof FormData?t:String(t));x(()=>{r.setFormValue(i(e.value.value))});let a=e.disabled;if(a&&`states`in r){let e=r.states;x(()=>{a.value?e.add(`disabled`):e.delete(`disabled`)})}return{checkValidity:()=>r.checkValidity(),internals:r,reportValidity:()=>r.reportValidity(),setCustomValidity:e=>e?r.setValidity({customError:!0},e):r.setValidity({}),setValidity:r.setValidity.bind(r)}},lt=O(`ore:form-context`);function ut(t={}){let n=(0,e.signal)([]),r=(0,e.signal)(!1),i=(0,e.signal)(!1),a=(0,e.signal)(null);return{clearStatus:()=>{i.value=!1,a.value=null,t.onReset?.()},dirty:i,error:a,markDirty:()=>{i.value=!0},registerField:e=>(n.value=[...n.value,e],()=>{n.value=n.value.filter(t=>t!==e)}),submit:async e=>{if(e?.preventDefault(),!r.value){r.value=!0,a.value=null;try{await t.onSubmit?.(e),i.value=!1}catch(e){a.value=e}finally{r.value=!1}}},submitting:r,valid:(0,e.computed)(()=>n.value.every(e=>e.value))}}var dt=0,$=0,ft=Math.random().toString(36).slice(2,6),pt=(e=`id`)=>`${e}-${++dt}`,mt=(e=`id`)=>`${e}-${ft}${++$}`,ht=()=>{$=0};exports.FORM_CONTEXT_KEY=lt,exports.OreApiError=n,exports.OreError=t,exports.OreLifecycleError=r,exports.OreTimeoutError=a,exports.createContext=O,exports.createFormContext=ut,exports.createId=pt,exports.createStableId=mt,exports.css=Oe,exports.define=Me,exports.html=st,exports.inject=D,exports.injectStrict=le,exports.prop=P,exports.ref=Se,exports.resetIdCounter=ht,exports.useField=ct;
3
3
  //# sourceMappingURL=ore.cjs.map