@but212/atom-effect-jquery 0.24.0 → 0.24.1
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/README.md +4 -1
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +266 -229
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`jquery`);c=s(c);var l={IDLE:`idle`,PENDING:`pending`,RESOLVED:`resolved`,REJECTED:`rejected`},u={DISPOSED:1,EXECUTING:8},d={DISPOSED:1,IS_COMPUTED:2,DIRTY:8,IDLE:16,PENDING:32,RESOLVED:64,REJECTED:128,RECOMPUTING:256,HAS_ERROR:512,FORCE_COMPUTE:1024},f={DISPOSED:1,SYNC:8,NOTIFICATION_SCHEDULED:16},p={MAX_EXECUTIONS_PER_SECOND:1e3,MAX_EXECUTIONS_PER_EFFECT:100,MAX_EXECUTIONS_PER_FLUSH:1e4,MAX_FLUSH_ITERATIONS:1e3,MIN_FLUSH_ITERATIONS:10,BATCH_QUEUE_SHRINK_THRESHOLD:1e3},m={WARN_INFINITE_LOOP:!0,EFFECT_FREQUENCY_WINDOW:1e3},h={MAX_ASYNC_RETRIES:3,MAX_PROMISE_ID:2**53-1-1},g={UNINITIALIZED:-1,MIN:1},_=1073741823,v={VERSION_BITS:16};typeof process<`u`&&process.env;var y=Object.freeze([]),b=class{constructor(e,t,n=void 0){this.node=e,this.version=t,this.unsub=n}},x=class{constructor(e,t){this.fn=e,this.sub=t}notify(e,t){this.fn?this.fn(e,t):this.sub&&this.sub.execute()}},S=class extends Error{constructor(e,t=null,n=!0){super(e),this.cause=t,this.recoverable=n,this.name=`AtomError`}},C=class extends S{constructor(e,t=null){super(e,t,!0),this.name=`ComputedError`}},w=class extends S{constructor(e,t=null){super(e,t,!1),this.name=`EffectError`}},ee=class extends S{constructor(e,t=null){super(e,t,!1),this.name=`SchedulerError`}},T={COMPUTED_MUST_BE_FUNCTION:`Computed target must be a function`,COMPUTED_ASYNC_PENDING_NO_DEFAULT:`Async computation pending with no default value`,COMPUTED_COMPUTATION_FAILED:`Computation execution failed`,COMPUTED_ASYNC_COMPUTATION_FAILED:`Async computation execution failed`,COMPUTED_CIRCULAR_DEPENDENCY:`Circular dependency detected`,COMPUTED_DISPOSED:`Attempted to access disposed computed`,ATOM_SUBSCRIBER_MUST_BE_FUNCTION:`Subscriber must be a function or Subscriber object`,ATOM_INDIVIDUAL_SUBSCRIBER_FAILED:`Subscriber execution failed`,EFFECT_MUST_BE_FUNCTION:`Effect target must be a function`,EFFECT_EXECUTION_FAILED:`Effect execution failed`,EFFECT_CLEANUP_FAILED:`Effect cleanup failed`,EFFECT_DISPOSED:`Attempted to run disposed effect`,SCHEDULER_FLUSH_OVERFLOW:(e,t)=>`Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,CALLBACK_ERROR_IN_ERROR_HANDLER:`Exception encountered in onError handler`,EFFECT_FREQUENCY_LIMIT_EXCEEDED:`Effect executed too frequently within 1 second. Suspected infinite loop.`,SCHEDULER_CALLBACK_MUST_BE_FUNCTION:`Scheduler callback must be a function`,SCHEDULER_END_BATCH_WITHOUT_START:`endBatch() called without matching startBatch(). Ignoring.`,BATCH_CALLBACK_MUST_BE_FUNCTION:`Batch callback must be a function`},te=class{constructor(){this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._count=0,this._epoch=g.UNINITIALIZED,this._overflow=null}get size(){return this._count}getAt(e){if(e===0)return this._s0;if(e===1)return this._s1;if(e===2)return this._s2;if(e===3)return this._s3;let t=this._overflow;if(t!==null&&e>=4){let n=e-4;if(n<t.length)return t[n]||null}return null}setAt(e,t){if(e===0)this._s0=t;else if(e===1)this._s1=t;else if(e===2)this._s2=t;else if(e===3)this._s3=t;else{this._overflow??=[];let n=this._overflow;n[e-4]=t}e>=this._count&&(this._count=e+1)}truncateFrom(e){let t=this._count;if(e>=t)return;if(e<=0){let e=this._s0;e!=null&&(this._onItemRemoved(e),this._s0=null)}if(e<=1){let e=this._s1;e!=null&&(this._onItemRemoved(e),this._s1=null)}if(e<=2){let e=this._s2;e!=null&&(this._onItemRemoved(e),this._s2=null)}if(e<=3){let e=this._s3;e!=null&&(this._onItemRemoved(e),this._s3=null)}let n=this._overflow;if(n!==null&&t>4){let t=e>4?e-4:0,r=n.length;for(let e=t;e<r;e++){let t=n[e];t!=null&&(this._onItemRemoved(t),n[e]=null)}e<=4?(n.length=0,this._overflow=null):n.length=e-4}this._count=e}_onItemRemoved(e){}add(e){if(this._s0===null){this._s0=e,this._count++;return}if(this._s1===null){this._s1=e,this._count++;return}if(this._s2===null){this._s2=e,this._count++;return}if(this._s3===null){this._s3=e,this._count++;return}if(this._overflow===null)this._overflow=[e];else{let t=this._overflow;for(let n=0,r=t.length;n<r;n++)if(t[n]===null){t[n]=e,this._count++;return}t.push(e)}this._count++}remove(e){if(this._s0===e)return this._s0=null,this._count--,!0;if(this._s1===e)return this._s1=null,this._count--,!0;if(this._s2===e)return this._s2=null,this._count--,!0;if(this._s3===e)return this._s3=null,this._count--,!0;let t=this._overflow;if(t==null)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return t[n]=null,this._count--,!0;return!1}has(e){let t=this._count;if(t===0)return!1;if(this._s0===e||this._s1===e||this._s2===e||this._s3===e)return!0;if(t<=4)return!1;let n=this._overflow;if(n!=null){let r=0;this._s0!=null&&r++,this._s1!=null&&r++,this._s2!=null&&r++,this._s3!=null&&r++;for(let i=0,a=n.length;i<a;i++){let a=n[i];if(a!=null){if(a===e)return!0;if(++r===t)break}}}return!1}forEach(e){let t=this._count;if(t===0)return;let n=this._s0;n!=null&&e(n);let r=this._s1;r!=null&&e(r);let i=this._s2;i!=null&&e(i);let a=this._s3;if(a!=null&&e(a),t<=4)return;let o=this._overflow;if(o!=null){let s=0;n!=null&&s++,r!=null&&s++,i!=null&&s++,a!=null&&s++;for(let n=0,r=o.length;n<r;n++){let r=o[n];if(r!=null&&(e(r),++s===t))return}}}forEachIndexed(e){let t=this._count;if(t===0)return 0;let n=0,r=this._s0;r!=null&&(e(r),n++);let i=this._s1;i!=null&&(e(i),n++);let a=this._s2;a!=null&&(e(a),n++);let o=this._s3;if(o!=null&&(e(o),n++),t<=4||n===t)return n;let s=this._overflow;if(s!=null)for(let r=0,i=s.length;r<i;r++){let i=s[r];if(i!=null&&(e(i),++n===t))break}return n}compact(){let e=this._overflow;if(e===null||e.length===0)return;let t=0;for(;t<e.length;)if(e[t]===null){let n=e.pop();t<e.length&&n!=null&&(e[t]=n)}else t++;e.length===0&&(this._overflow=null)}clear(){this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._count=0,this._overflow!==null&&(this._overflow.length=0,this._overflow=null)}dispose(){this.clear()}},ne=Symbol(`AtomEffect.DebugName`),re=Symbol(`AtomEffect.Type`),ie=Symbol(`AtomEffect.NoDefaultValue`),ae={enabled:!1,warnInfiniteLoop:m.WARN_INFINITE_LOOP,warn(e,t){},attachDebugInfo(e,t,n){},getDebugName:e=>e?.[ne],getDebugType:e=>e?.[re]},oe=1,se=()=>oe++;function E(e,t,n){if(e instanceof S)return e;let r=e instanceof Error,i=r?e.message:String(e),a=r?e:void 0;return new t(`${r?e.constructor.name:`Unexpected error`} (${n}): ${i}`,a)}var ce=class{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=g.UNINITIALIZED,this.id=se()&_,this._slots=null,this._notifying=0,this._deps=null,this._hotIndex=-1}subscribe(e){let t=typeof e==`function`;if(!t&&(!e||typeof e.execute!=`function`))throw E(TypeError(`Invalid subscriber`),S,T.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);let n=this._slots;n||(n=new te,this._slots=n);let r=!1;if(n.forEach(n=>{(t?n.fn===e:n.sub===e)&&(r=!0)}),r)return()=>{};let i=new x(t?e:void 0,t?void 0:e);return n.add(i),()=>this._unsubscribe(i)}_unsubscribe(e){if(this._slots){if(this._notifying>0){this._slots.remove(e);return}this._slots.remove(e),this._slots.compact()}}subscriberCount(){return this._slots?this._slots.size:0}_notifySubscribers(e,t){let n=this._slots;if(!(!n||n.size===0)){this._notifying++;try{n.forEach(n=>{try{n.notify(e,t)}catch(e){console.error(E(e,S,T.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}})}finally{this._notifying--,this._notifying===0&&n.compact()}}}_isDirty(){let e=this._deps;if(!e||e.size===0)return!1;if(this._hotIndex!==-1){let t=e.getAt(this._hotIndex);if(t!=null&&t.node.version!==t.version)return!0}return!e.hasComputeds&&!e.isDirtyFast()?!1:this._deepDirtyCheck()}},le=0,ue=()=>(le=le+1&1073741823||1,le),de=e=>e+1&_,fe=0,pe=!1,me=0,he=()=>me;function ge(){return pe?!1:(pe=!0,me=ue(),fe=0,!0)}var _e=()=>{pe=!1},ve=()=>pe?++fe:0,ye=(function(e){return e[e.IDLE=0]=`IDLE`,e[e.BATCHING=1]=`BATCHING`,e[e.FLUSHING=2]=`FLUSHING`,e})({}),D=new class{constructor(){this._queueBuffer=[[],[]],this._bufferIndex=0,this._size=0,this._epoch=0,this._isProcessing=!1,this._isBatching=!1,this._isFlushingSync=!1,this._batchDepth=0,this._batchQueue=[],this._batchQueueSize=0,this._maxFlushIterations=p.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get phase(){return this._isProcessing||this._isFlushingSync?ye.FLUSHING:this._isBatching?ye.BATCHING:ye.IDLE}get queueSize(){return this._size}get isBatching(){return this._isBatching}schedule(e){if(e._nextEpoch!==this._epoch){if(e._nextEpoch=this._epoch,this._isBatching||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=e;return}this._queueBuffer[this._bufferIndex][this._size++]=e,this._isProcessing||this._flush()}}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0)return;let e=ge();this._drainQueue(),e&&_e()}finally{this._isProcessing=!1,this._size>0&&!this._isBatching&&this._flush()}}_flushSync(){this._isFlushingSync=!0;let e=ge();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=!1,e&&_e()}}_mergeBatchQueue(){if(this._batchQueueSize===0)return;let e=++this._epoch,t=this._batchQueue,n=this._queueBuffer[this._bufferIndex],r=this._size;t.slice(0,this._batchQueueSize).forEach(t=>{t._nextEpoch!==e&&(t._nextEpoch=e,n[r++]=t)}),this._size=r,this._batchQueueSize=0,t.length>p.BATCH_QUEUE_SHRINK_THRESHOLD&&(t.length=0)}_drainQueue(){let e=0;for(;this._size>0;){if(++e>this._maxFlushIterations){this._handleFlushOverflow();return}this._processQueue(),this._mergeBatchQueue()}}_processQueue(){let e=this._bufferIndex,t=this._queueBuffer[e],n=this._size;this._bufferIndex=e^1,this._size=0,this._epoch++;for(let e=0;e<n;e++)try{let n=t[e];typeof n==`function`?n():n.execute()}catch(e){console.error(new ee(`Error occurred during scheduler execution`,e))}t.length=0}_handleFlushOverflow(){let e=this._size+this._batchQueueSize;if(console.error(new ee(T.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,e))),this._size=0,this._queueBuffer[this._bufferIndex].length=0,this._batchQueueSize=0,this.onOverflow)try{this.onOverflow(e)}catch{}}startBatch(){this._batchDepth++,this._isBatching=!0}endBatch(){this._batchDepth!==0&&--this._batchDepth===0&&(this._flushSync(),this._isBatching=!1)}setMaxFlushIterations(e){if(e<p.MIN_FLUSH_ITERATIONS)throw new ee(`Max flush iterations must be at least ${p.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=e}},be=Symbol.for(`atom-effect/atom`),xe=Symbol.for(`atom-effect/computed`),Se=Symbol.for(`atom-effect/effect`),Ce=Symbol.for(`atom-effect/writable`),O={current:null,run(e,t){let n=this.current;this.current=e;try{return t()}finally{this.current=n}}};function k(e){let t=O.current;if(t===null)return e();O.current=null;try{return e()}finally{O.current=t}}var we=class extends ce{constructor(e,t){super(),this._pendingOldValue=void 0,this[be]=!0,this[Ce]=!0,this._value=e,t&&(this.flags|=f.SYNC),ae.attachDebugInfo(this,`atom`,this.id)}get value(){return O.current?.addDependency(this),this._value}set value(e){let t=this._value;if(Object.is(t,e))return;this._value=e,this.version=de(this.version);let n=this._slots,r=this.flags;if(n==null||n.size===0||r&f.NOTIFICATION_SCHEDULED)return;this._pendingOldValue=t;let i=r|f.NOTIFICATION_SCHEDULED;if(this.flags=i,(i&f.SYNC)!==0&&!D.isBatching){this._flushNotifications();return}D.schedule(this)}execute(){this._flushNotifications()}_flushNotifications(){let e=this.flags;if(!(e&f.NOTIFICATION_SCHEDULED)||e&f.DISPOSED)return;let t=this._pendingOldValue;this._pendingOldValue=void 0,this.flags&=~f.NOTIFICATION_SCHEDULED,this._notifySubscribers(this._value,t)}peek(){return this._value}dispose(){this.flags&f.DISPOSED||(this._slots?.clear(),this.flags|=f.DISPOSED,this._value=void 0,this._pendingOldValue=void 0)}_deepDirtyCheck(){return!1}[Symbol.dispose](){this.dispose()}};function Te(e,t={}){return new we(e,t.sync??!1)}var Ee=class extends te{constructor(){super(),this._map=null,this._SCAN_THRESHOLD=32,this.hasComputeds=!1,this._depsHash=0,this._map=null,this.hasComputeds=!1,this._depsHash=0}prepareTracking(){this.hasComputeds=!1}_onItemRemoved(e){let t=e.unsub;t&&t()}claimExisting(e,t){let n=this._count;if(t>=n)return!1;let r=n-t;if(this._map!==null||r>this._SCAN_THRESHOLD)return this._claimViaMap(e,t);if(t<4){if(t<=0){let t=this._s0;if(t&&t.node===e&&t.unsub)return t.version=e.version,!0}if(t<=1&&n>1){let n=this._s1;if(n&&n.node===e&&n.unsub)return n.version=e.version,t!==1&&(this._s1=this._s0,this._s0=n),!0}if(t<=2&&n>2){let n=this._s2;if(n&&n.node===e&&n.unsub)return n.version=e.version,t!==2&&this._swapInline(2,t,n),!0}if(t<=3&&n>3){let n=this._s3;if(n&&n.node===e&&n.unsub)return n.version=e.version,t!==3&&this._swapInline(3,t,n),!0}}let i=t>4?t:4,a=this._overflow;if(a)for(let n=i-4,r=a.length;n<r;n++){let r=a[n];if(r&&r.node===e&&r.unsub)return r.version=e.version,this._swapGeneral(n+4,t,r),!0}return!1}_claimViaMap(e,t){if(this._map===null){this._map=new Map;let e=this._count;for(let n=t;n<e;n++){let e=this.getAt(n);e?.unsub&&this._map.set(e.node,n)}}let n=this._map.get(e);if(n===void 0||n<t)return!1;let r=this.getAt(n);if(r==null||!r.unsub)return!1;if(r.version=e.version,n!==t){let i=this.getAt(t);this.setAt(t,r),this.setAt(n,i),i?.unsub&&this._map.set(i.node,n),this._map.set(e,t)}return!0}_swapInline(e,t,n){let r=this.getAt(t);this.setAt(t,n),this.setAt(e,r)}_swapGeneral(e,t,n){if(e===t)return;let r=this.getAt(t);this.setAt(t,n),this.setAt(e,r)}insertNew(e,t){let n=this._count;if(e<n){let t=this.getAt(e);t!=null&&(this.add(t),this._map!==null&&t.unsub&&this._map.set(t.node,this._count-1))}e===0?this._s0=t:e===1?this._s1=t:e===2?this._s2=t:e===3?this._s3=t:this.setAt(e,t),e>=n&&(this._count=e+1)}truncateFrom(e){e>=this._count||(super.truncateFrom(e),this._map!==null&&(this._map.clear(),this._map=null))}seal(){let e=this._count;if(e<=0){this._depsHash=0;return}let t=0,n=v.VERSION_BITS,r=this._s0;if(r&&(t=t+(r.version<<n)+r.node.id|0),e>1){let e=this._s1;e&&(t=t+(e.version<<n)+e.node.id|0)}if(e>2){let e=this._s2;e&&(t=t+(e.version<<n)+e.node.id|0)}if(e>3){let e=this._s3;e&&(t=t+(e.version<<n)+e.node.id|0);let r=this._overflow;if(r)for(let e=0,i=r.length;e<i;e++){let i=r[e];i&&(t=t+(i.version<<n)+i.node.id|0)}}this._depsHash=t}isDirtyFast(){let e=this._count;if(e<=0)return!1;let t=0,n=v.VERSION_BITS,r=this._s0;if(r){let e=r.node;t=t+(e.version<<n)+e.id|0}if(e>1){let e=this._s1;if(e){let r=e.node;t=t+(r.version<<n)+r.id|0}}if(e>2){let e=this._s2;if(e){let r=e.node;t=t+(r.version<<n)+r.id|0}}if(e>3){let e=this._s3;if(e){let r=e.node;t=t+(r.version<<n)+r.id|0}let r=this._overflow;if(r)for(let e=0,i=r.length;e<i;e++){let i=r[e];if(i){let e=i.node;t=t+(e.version<<n)+e.id|0}}}return t!==this._depsHash}captureVersionSnapshot(){let e=this._count;if(e<=0)return 0;let t=0,n=this._s0;if(n&&(t=(t<<5)-t+n.node.version|0),e>1){let e=this._s1;e&&(t=(t<<5)-t+e.node.version|0)}if(e>2){let e=this._s2;e&&(t=(t<<5)-t+e.node.version|0)}if(e>3){let e=this._s3;e&&(t=(t<<5)-t+e.node.version|0);let n=this._overflow;if(n)for(let e=0,r=n.length;e<r;e++){let r=n[e];r&&(t=(t<<5)-t+r.node.version|0)}}return t}disposeAll(){this._count>0&&this.truncateFrom(0),this.hasComputeds=!1,this._map!==null&&(this._map.clear(),this._map=null)}remove(e){throw Error(`remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.`)}compact(){}};function A(e){return typeof e==`object`&&!!e&&be in e}function De(e){return typeof e==`object`&&!!e&&xe in e}function Oe(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}var{IDLE:j,DIRTY:M,PENDING:N,RESOLVED:P,REJECTED:F,HAS_ERROR:I,RECOMPUTING:L,DISPOSED:ke,IS_COMPUTED:Ae,FORCE_COMPUTE:je}=d,Me=class extends ce{constructor(e,t={}){if(typeof e!=`function`)throw new C(T.COMPUTED_MUST_BE_FUNCTION);if(super(),this[be]=!0,this[xe]=!0,this._error=null,this._promiseId=0,this._deps=new Ee,this._asyncStartAggregateVersion=0,this._asyncRetryCount=0,this._lastDriftEpoch=g.UNINITIALIZED,this._trackEpoch=g.UNINITIALIZED,this._trackCount=0,this._value=void 0,this.flags=Ae|M|j,this._equal=t.equal??Object.is,this._fn=e,this._defaultValue=`defaultValue`in t?t.defaultValue:ie,this._onError=t.onError??null,this._maxAsyncRetries=(t.maxAsyncRetries??h.MAX_ASYNC_RETRIES)&_,ae.attachDebugInfo(this,`computed`,this.id),t.lazy===!1)try{this._recompute()}catch{}}_track(){O.current?.addDependency(this)}get value(){this._track();let e=this.flags;if((e&(P|M|j))===P)return this._value;if(e&ke)throw new C(T.COMPUTED_DISPOSED);if(e&L){if(this._defaultValue!==ie)return this._defaultValue;throw new C(T.COMPUTED_CIRCULAR_DEPENDENCY)}if(e&(M|j)&&((e&j)===0&&(e&je)===0&&this._deps.size>0&&!this._isDirty()?this.flags&=~M:this._recompute(),this.flags&P))return this._value;let t=this._defaultValue,n=t!==ie;if(this.flags&N){if(n)return t;throw new C(T.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if(this.flags&F){if(n)return t;throw this._error}return this._value}peek(){return this._value}get state(){this._track();let e=this.flags;return e&P?l.RESOLVED:e&N?l.PENDING:e&F?l.REJECTED:l.IDLE}get hasError(){if(this._track(),this.flags&(F|I))return!0;let e=this._deps,t=e.size;for(let n=0;n<t;n++){let t=e.getAt(n);if(t!=null&&t.node.flags&I)return!0}return!1}get isValid(){return!this.hasError}get errors(){this._track();let e=[];this._error&&e.push(this._error);let t=this._deps,n=t.size;for(let r=0;r<n;r++){let n=t.getAt(r);if(n==null)continue;let i=n.node;i.flags&I&&this._collectErrorsFromDep(i,e)}return e.length===0?y:Object.freeze(e)}_collectErrorsFromDep(e,t){let n=e.errors,r=n.length;for(let e=0;e<r;e++){let r=n[e];r!=null&&!t.includes(r)&&t.push(r)}}get lastError(){return this._track(),this._error}get isPending(){return this._track(),(this.flags&N)!==0}get isResolved(){return this._track(),(this.flags&P)!==0}invalidate(){this.flags|=je,this._markDirty()}dispose(){this.flags&ke||(this._deps.disposeAll(),this._slots?.clear(),this.flags=ke|M|j,this._error=null,this._value=void 0,this._hotIndex=-1)}[Symbol.dispose](){this.dispose()}addDependency(e){if(e._lastSeenEpoch===this._trackEpoch)return;e._lastSeenEpoch=this._trackEpoch;let t=this._trackCount,n=this._deps.getAt(t);if(n!=null&&n.node===e)n.version=e.version;else if(!this._deps.claimExisting(e,t)){let n=new b(e,e.version,e.subscribe(this));this._deps.insertNew(t,n)}e.flags&Ae&&(this._deps.hasComputeds=!0),this._trackCount=t+1}_recompute(){if(this.flags&L)return;this.flags=(this.flags|L)&~je,this._trackEpoch=ue(),this._trackCount=0,this._deps.prepareTracking(),this._hotIndex=-1;let e=!1;try{let t=O.run(this,this._fn);this._deps.truncateFrom(this._trackCount),this._deps.seal(),e=!0,Oe(t)?this._handleAsyncComputation(t):this._finalizeResolution(t)}catch(t){if(!e)try{this._deps.truncateFrom(this._trackCount)}catch{}this._handleError(t,T.COMPUTED_COMPUTATION_FAILED,!0)}finally{this._trackEpoch=g.UNINITIALIZED,this._trackCount=0,this.flags&=~L}}_handleAsyncComputation(e){this.flags=(this.flags|N)&~(j|M|P|F),this._notifySubscribers(void 0,void 0),this._asyncStartAggregateVersion=this._captureVersionSnapshot(),this._asyncRetryCount=0,this._promiseId=(this._promiseId+1)%h.MAX_PROMISE_ID;let t=this._promiseId;e.then(e=>{if(t===this._promiseId){if(this._captureVersionSnapshot()!==this._asyncStartAggregateVersion){let e=he();return this._lastDriftEpoch!==e&&(this._lastDriftEpoch=e,this._asyncRetryCount=0),this._asyncRetryCount++<this._maxAsyncRetries?this._markDirty():this._handleError(new C(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),T.COMPUTED_ASYNC_COMPUTATION_FAILED)}this._finalizeResolution(e),this._notifySubscribers(e,void 0)}},e=>t===this._promiseId&&this._handleError(e,T.COMPUTED_ASYNC_COMPUTATION_FAILED))}_captureVersionSnapshot(){return this._deps.captureVersionSnapshot()}_handleError(e,t,n=!1){let r=E(e,C,t);if(!n&&!(this.flags&F)&&(this.version=de(this.version)),this._error=r,this.flags=this.flags&~(j|M|N|P)|F|I,this._onError)try{this._onError(r)}catch(e){console.error(T.CALLBACK_ERROR_IN_ERROR_HANDLER,e)}if(n)throw r;this._notifySubscribers(void 0,void 0)}_finalizeResolution(e){(!(this.flags&P)||!this._equal(this._value,e))&&(this.version=de(this.version)),this._value=e,this._error=null,this.flags=(this.flags|P)&~(j|M|N|F|I)}execute(){this._markDirty()}_markDirty(){this.flags&(L|M)||(this.flags|=M,this._notifySubscribers(void 0,void 0))}_deepDirtyCheck(){let e=this._deps,t=O.current;O.current=null;try{let t=e.size;for(let n=0;n<t;n++){let t=e.getAt(n);if(t==null)continue;let r=t.node;if(r.flags&Ae)try{r.value}catch{}if(r.version!==t.version)return this._hotIndex=n,!0}return this._hotIndex=-1,!1}finally{O.current=t}}};function R(e,t={}){return new Me(e,t)}var Ne=class extends ce{constructor(e,t={}){super(),this[Se]=!0,this._cleanup=null,this._deps=new Ee,this._currentEpoch=g.UNINITIALIZED,this._lastFlushEpoch=g.UNINITIALIZED,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._trackCount=0,this._fn=e,this._onError=t.onError??null,this._sync=t.sync??!1,this._maxExecutions=t.maxExecutionsPerSecond??p.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=t.maxExecutionsPerFlush??p.MAX_EXECUTIONS_PER_EFFECT,this._sync?this._notifyCallback=()=>this.execute():this._notifyCallback=()=>D.schedule(this),ae.attachDebugInfo(this,`effect`,this.id)}run(){if(this.flags&u.DISPOSED)throw new w(T.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.flags&u.DISPOSED||(this.flags|=u.DISPOSED,this._execCleanup(),this._deps?.disposeAll())}[Symbol.dispose](){this.dispose()}addDependency(e){if(!(this.flags&u.EXECUTING))return;let t=this._currentEpoch;if(e._lastSeenEpoch===t)return;e._lastSeenEpoch=t;let n=this._trackCount,r=this._deps,i=r.getAt(n);i!=null&&i.node===e?i.version=e.version:r.claimExisting(e,n)||this._insertNewDependency(e,n),e.flags&d.IS_COMPUTED&&(r.hasComputeds=!0),this._trackCount=n+1}_insertNewDependency(e,t){let n;try{let t=e.subscribe(this._notifyCallback);n=new b(e,e.version,t)}catch(t){let r=E(t,w,T.EFFECT_EXECUTION_FAILED);if(console.error(r),this._onError)try{this._onError(r)}catch{}n=new b(e,e.version,void 0)}this._deps.insertNew(t,n)}execute(e=!1){if(this.flags&(u.DISPOSED|u.EXECUTING))return;let t=this._deps;if(!e&&t.size>0&&!this._isDirty())return;this._checkInfiniteLoops(),this.flags|=u.EXECUTING,this._execCleanup(),this._currentEpoch=ue(),this._trackCount=0,t.prepareTracking(),this._hotIndex=-1;let n=!1;try{let e=O.run(this,this._fn);t.truncateFrom(this._trackCount),t.seal(),n=!0,Oe(e)?this._handleAsyncResult(e):this._cleanup=typeof e==`function`?e:null}catch(e){if(!n)try{t.truncateFrom(this._trackCount)}catch{}this._handleExecutionError(e),this._cleanup=null}finally{this.flags&=~u.EXECUTING}}_handleAsyncResult(e){let t=++this._execId;e.then(e=>{if(t!==this._execId||this.flags&u.DISPOSED){if(typeof e==`function`)try{e()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}return}typeof e==`function`&&(this._cleanup=e)},e=>t===this._execId&&this._handleExecutionError(e))}_deepDirtyCheck(){let e=O.current;O.current=null;let t=this._deps;try{let e=t.size;for(let n=0;n<e;n++){let e=t.getAt(n);if(e==null)continue;let r=e.node;if(r.flags&d.IS_COMPUTED&&this._tryPullComputed(r),r.version!==e.version)return this._hotIndex=n,!0}return!1}finally{O.current=e}}_tryPullComputed(e){try{e.value}catch{}}_execCleanup(){if(this._cleanup){try{this._cleanup()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}this._cleanup=null}}_checkInfiniteLoops(){let e=he();this._lastFlushEpoch!==e&&(this._lastFlushEpoch=e,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError(`per-effect`),ve()>p.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError(`global`),this._executionCount++}_checkFrequencyLimit(){if(!Number.isFinite(this._maxExecutions))return;let e=Date.now();if(e-this._windowStart>=m.EFFECT_FREQUENCY_WINDOW){this._windowStart=e,this._windowCount=1;return}if(++this._windowCount>this._maxExecutions){let e=new w(T.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(e),e}}get isDisposed(){return(this.flags&u.DISPOSED)!==0}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&u.EXECUTING)!==0}_throwInfiniteLoopError(e){let t=new w(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${fe}`);throw this.dispose(),console.error(t),t}_handleExecutionError(e,t=T.EFFECT_EXECUTION_FAILED){let n=E(e,w,t);if(console.error(n),this._onError)try{this._onError(n)}catch(e){console.error(E(e,w,T.CALLBACK_ERROR_IN_ERROR_HANDLER))}}};function z(e,t={}){if(typeof e!=`function`)throw new w(T.EFFECT_MUST_BE_FUNCTION);let n=new Ne(e,t);return n.execute(),n}function Pe(e){if(typeof e!=`function`)throw TypeError(T.BATCH_CALLBACK_MUST_BE_FUNCTION);D.startBatch();try{return e()}finally{D.endBatch()}}function Fe(e){return A(e)}function B(e){let t=e.tagName.toLowerCase();if(e.id)return`${t}#${e.id}`;let n=e.classList,r=n.length;if(r===0)return t;let i=t;for(let e=0;e<r;e++)i+=`.${n[e]}`;return i}var V=Object.prototype.hasOwnProperty;function Ie(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=e,a=t;for(let e=0;e<n.length;e++){let t=n[e];if(!V.call(a,t)||i[t]!==a[t])return!1}return!0}var H={ROUTE:`[atom-route]`,BINDING:`[atom-binding]`,LIST:`[atom-list]`,MOUNT:`[atom-mount]`},U=Object.freeze({mode:`hash`,basePath:``,autoBindLinks:!1,activeClass:`active`}),Le={EVENT:`input`,DEBOUNCE:0},Re={HIGHLIGHT_DURATION_MS:500},ze=new Set([`input`,`select`,`textarea`]),Be=new Set([`src`,`href`,`action`,`formaction`,`data`,`poster`,`background`,`cite`,`longdesc`,`profile`,`usemap`,`classid`,`codebase`,`xlink:href`]),Ve=new Set([`innerHTML`,`outerHTML`,`srcdoc`,`__proto__`,`constructor`,`prototype`]),W={ROUTE:{NOT_FOUND:e=>`Route "${e}" not found and no notFound route configured`,TEMPLATE_NOT_FOUND:e=>`Template "${e}" not found`,TARGET_NOT_FOUND:e=>`Target element "${e}" not found`,MALFORMED_URI:e=>`Malformed URI component: ${e}`},SECURITY:{UNSAFE_CONTENT:()=>`Unsafe content neutralized during sanitization.`,BLOCKED_CSS_VALUE:e=>`Blocked dangerous value in CSS style property "${e}".`,BLOCKED_EVENT_HANDLER:e=>`Blocked setting dangerous event handler attribute/property "${e}".`,BLOCKED_PROTOCOL:e=>`Blocked dangerous protocol in "${e}".`,BLOCKED_PROP:e=>`Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`},BINDING:{INVALID_INPUT_ELEMENT:e=>`Val binding used on non-input element <${e}>.`,MISSING_SOURCE:e=>`[${e}] source is required when prop/name is a string.`,MISSING_CONDITION:e=>`[${e}] condition is required when className is a string.`,UPDATER_ERROR:(e,t)=>`Updater threw in binding "${e}"${t?` (static)`:``}`,CLEANUP_ERROR:e=>`Binding cleanup error${e?`: ${e}`:``}`,PARSE_ERROR:e=>`parse() threw during DOM→Atom sync${e?`: ${e}`:``}`},LIST:{DUPLICATE_KEY:(e,t,n)=>`Duplicate key "${e}" at index ${t} in atomList <${n}>.`},MOUNT:{ERROR:e=>`Mount error${e?` in component <${e}>`:``}`,CLEANUP_ERROR:e=>`Cleanup error${e?` in component <${e}>`:``}`},CORE:{EFFECT_DISPOSE_ERROR:e=>`Effect dispose error${e?`: ${e}`:``}`}},He=`${Re.HIGHLIGHT_DURATION_MS/1e3}s`;function Ue(){if(typeof window<`u`){let e=window.__ATOM_DEBUG__;if(typeof e==`boolean`)return e}try{if(globalThis.process?.env?.VITE_ATOM_DEBUG===`true`)return!0}catch{}return!1}var We=Ue(),G={get enabled(){if(typeof window<`u`){let e=window.__ATOM_DEBUG__;if(typeof e==`boolean`)return e}return We},set enabled(e){We=e},log(e,...t){this.enabled&&console.log(`${e}`,...t)},atomChanged(e,t,n,r){this.enabled&&console.log(`${e} Atom "${t??`anonymous`}" changed:`,n,`→`,r)},domUpdated(e,t,n,r){if(!this.enabled)return;let i=t instanceof Element?t:t[0];i&&(console.log(`${e} DOM updated: ${B(i)}.${n} =`,r),Ze(i))},cleanup(e,t){this.enabled&&console.log(`${e} Cleanup: ${t}`)},warn(e,t,...n){console.warn(`${e} ${t}`,...n)},error(e,t,n){console.error(`${e} ${t}`,n)}},Ge=`atom-debug-highlight`,Ke=`data-atom-debug`,qe;function Je(){if((qe instanceof HTMLStyleElement?qe:qe?.deref())?.isConnected||document.querySelector(`style[${Ke}]`))return;let e=document.createElement(`style`);e.setAttribute(Ke,``),e.textContent=`.${Ge}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${He} ease-out}`,document.head.appendChild(e),qe=typeof WeakRef<`u`?new WeakRef(e):e}var Ye=new WeakMap,Xe=new WeakMap;function Ze(e){if(!G.enabled||!e.isConnected)return;Je();let t=Xe.get(e);t!==void 0&&cancelAnimationFrame(t);let n=Ye.get(e);n!==void 0&&clearTimeout(n);let r=requestAnimationFrame(()=>{Xe.delete(e),e.isConnected&&(e.classList.add(Ge),Ye.set(e,setTimeout(()=>{e.isConnected&&e.classList.remove(Ge),Ye.delete(e)},Re.HIGHLIGHT_DURATION_MS)))});Xe.set(e,r)}function Qe(e,t){return Te(e,t)}Object.defineProperty(Qe,`debug`,{enumerable:!0,configurable:!0,get(){return G.enabled},set(e){G.enabled=e}});function $e(){return new Promise(e=>setTimeout(e,0))}var et={atom:Qe,computed:R,effect:z,batch:Pe,untracked:k,isAtom:A,isComputed:De,isReactive:Fe,nextTick:$e};c.default.extend(et);var tt=class{constructor(e=50,t=256){this.limit=e,this.capacity=t,this.pool=[]}acquire(){return this.pool.pop()??[]}release(e){e.length>this.capacity||this.pool.length>=this.limit||Object.isFrozen(e)||(e.length=0,this.pool.push(e))}reset(){this.pool.length=0}},nt=class{constructor(e,t,n=64){this.factory=e,this.reset=t,this.limit=n,this.pool=[]}acquire(){return this.pool.pop()??this.factory()}release(e){this.pool.length>=this.limit||(this.reset(e),this.pool.push(e))}drain(){this.pool.length=0}get size(){return this.pool.length}},rt=new tt,it=new tt,at=new nt(()=>({effects:void 0,cleanups:void 0,componentCleanup:void 0}),e=>{e.effects=void 0,e.cleanups=void 0,e.componentCleanup=void 0},128),K=`_aes-bound`,q=new class{constructor(){this.records=new WeakMap,this.preservedNodes=new WeakSet,this.ignoredNodes=new WeakSet}keep(e){this.preservedNodes.add(e)}isKept(e){return this.preservedNodes.has(e)}markIgnored(e){this.ignoredNodes.add(e)}isIgnored(e){return this.ignoredNodes.has(e)}getOrCreateRecord(e){let t=this.records.get(e);return t||(t=at.acquire(),this.records.set(e,t),e.classList.add(K)),t}trackEffect(e,t){let n=this.getOrCreateRecord(e);n.effects??=rt.acquire(),n.effects.push(t)}trackCleanup(e,t){let n=this.getOrCreateRecord(e);n.cleanups??=it.acquire(),n.cleanups.push(t)}setComponentCleanup(e,t){let n=this.getOrCreateRecord(e);n.componentCleanup=t}hasBind(e){return this.records.has(e)}cleanup(e){let t=this.records.get(e);if(!t){e.nodeType===1&&e.classList.remove(K),this.preservedNodes.delete(e),this.ignoredNodes.delete(e);return}if(this.records.delete(e),this.preservedNodes.delete(e),this.ignoredNodes.delete(e),e.nodeType===1&&e.classList.remove(K),G.enabled){let t=e.nodeType===1?B(e):e.nodeName||`Node`;G.cleanup(H.BINDING,t)}if(t.componentCleanup)try{t.componentCleanup()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.MOUNT,W.MOUNT.CLEANUP_ERROR(n),t)}if(t.effects){let n=t.effects;for(let t=0,r=n.length;t<r;t++)try{n[t].dispose()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.BINDING,W.CORE.EFFECT_DISPOSE_ERROR(n),t)}rt.release(n),t.effects=void 0}if(t.cleanups){let n=t.cleanups;for(let t=0,r=n.length;t<r;t++)try{n[t]()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.BINDING,W.BINDING.CLEANUP_ERROR(n),t)}it.release(n),t.cleanups=void 0}at.release(t)}cleanupDescendants(e){let t=`getElementsByClassName`in e&&typeof e.getElementsByClassName==`function`?e.getElementsByClassName(K):e.querySelectorAll(`.${K}`);for(let e=t.length-1;e>=0;e--){let n=t[e];n&&(this.records.has(n)?this.cleanup(n):(n.classList.remove(K),G.enabled&&G.warn(H.BINDING,`${K} class found on unregistered element:`,n)))}}cleanupTree(e){(e.nodeType===1||e.nodeType===11)&&this.cleanupDescendants(e),this.cleanup(e)}},ot=new Map;function st(e){if(ot.has(e))return;let t=new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){let n=e[t].removedNodes;for(let e=0,t=n.length;e<t;e++){let t=n[e];t.nodeType===1&&(t.isConnected||q.isKept(t)||q.isIgnored(t)||q.cleanupTree(t))}}});t.observe(e,{childList:!0,subtree:!0}),ot.set(e,t)}function ct(){ot.forEach(e=>e.disconnect()),ot.clear()}var lt=Symbol(`atom-effect-internal`),ut=new WeakMap,J=null,dt=e=>{if(e[lt])return e;let t=ut.get(e);return t||(t=function(...t){return Pe(()=>e.apply(this,t))},t[lt]=!0,ut.set(e,t)),t};function ft(e){let t={},n=Object.entries(e);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r[0],a=r[1];a&&(t[i]=dt(a))}return t}function pt(e){let t={},n=Object.entries(e);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r[0],a=r[1];t[i]=a?ut.get(a)??a:void 0}return t}function mt(){if(J!==null)return;J={on:c.default.fn.on,off:c.default.fn.off,remove:c.default.fn.remove,empty:c.default.fn.empty,detach:c.default.fn.detach};let e=J;c.default.fn.remove=function(t){let n=t?this.filter(t):this;for(let e=0,t=n.length;e<t;e++){let t=n[e];t&&(q.markIgnored(t),q.cleanupTree(t))}let r=e.remove.call(this,t);return r===void 0?this:r},c.default.fn.empty=function(){for(let e=0,t=this.length;e<t;e++){let t=this[e];t?.hasChildNodes()&&q.cleanupDescendants(t)}let t=e.empty.call(this);return t===void 0?this:t},c.default.fn.detach=function(t){let n=t?this.filter(t):this;for(let e=0,t=n.length;e<t;e++){let t=n[e];t&&q.keep(t)}let r=e.detach.call(this,t);return r===void 0?this:r},c.default.fn.on=function(...t){let n=t[0];if(n&&typeof n==`object`)t[0]=ft(n);else{let e=t.length-1;e>=0&&typeof t[e]==`function`&&(t[e]=dt(t[e]))}let r=e.on.apply(this,t);return r===void 0?this:r},c.default.fn.off=function(...t){let n=t[0];if(n&&typeof n==`object`)t[0]=pt(n);else{let e=t.length-1;if(e>=0&&typeof t[e]==`function`){let n=t[e];t[e]=ut.get(n)??n}}let r=e.off.apply(this,t);return r===void 0?this:r}}function ht(){J!==null&&(c.default.fn.on=J.on,c.default.fn.off=J.off,c.default.fn.remove=J.remove,c.default.fn.empty=J.empty,c.default.fn.detach=J.detach,J=null)}var Y=function(e){return e[e.None=0]=`None`,e[e.Focused=1]=`Focused`,e[e.Composing=2]=`Composing`,e[e.SyncingToAtom=4]=`SyncingToAtom`,e[e.SyncingToDom=8]=`SyncingToDom`,e[e.Busy=14]=`Busy`,e}({}),gt=0;function X(e){e[lt]=!0}var _t=class{constructor(e,t,n){this.flags=0,this.timeoutId=void 0,this.handleCompositionStart=()=>{this.flags|=Y.Composing},this.handleCompositionEnd=()=>{this.flags&=~Y.Composing,this.handleInput()},this.handleFocus=()=>{this.flags|=Y.Focused},this.handleBlur=()=>{this.flags&=~Y.Focused;let e=!!(this.flags&Y.Composing);this.flags&=~Y.Composing,this.flushPendingDebounce(),e&&this.timeoutId===void 0&&this.syncAtomFromDom(),this.normalizeDomValue()},this.syncDomFromAtom=()=>{let e=this.atom.value;k(()=>{let t=this.format(e),n;if(n=this.isMultipleSelect?this.$el.val()||[]:this.el.value,this.equal(n,e))return;let r=!!(this.flags&Y.Focused);if(r)try{let t=this.isMultipleSelect?n:this.parse(this.el.value);if(this.equal(t,e))return}catch{}this.flags|=Y.SyncingToDom;try{if(this.isMultipleSelect)this.$el.val(e);else if(r&&(this.el instanceof HTMLInputElement||this.el instanceof HTMLTextAreaElement))try{let e=this.el.selectionStart,n=this.el.selectionEnd;this.el.value=t;let r=t.length;e!==null&&n!==null&&this.el.setSelectionRange(e<r?e:r,n<r?n:r)}catch{this.el.value=t}else this.el.value=t;G.enabled&&G.domUpdated(H.BINDING,this.$el,`val`,t)}finally{this.flags&=~Y.SyncingToDom}})},this.cleanup=()=>{this.$el.off(this.ns),clearTimeout(this.timeoutId),this.timeoutId=void 0},this.$el=e,this.el=e[0],this.atom=t,this.isMultipleSelect=this.el.tagName===`SELECT`&&this.el.multiple,this.ns=`.atomBind-${++gt}`;let r=n.debounce??0,i=n.event??Le.EVENT;this.parse=n.parse??(e=>e),this.format=n.format??(e=>this.isMultipleSelect?(Array.isArray(e)?e:e?[String(e)]:[]).join(`,`):String(e??``));let a=n.equal??Object.is;this.equal=(e,t)=>a(e,t)?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])):!1,r>0?this.handleInput=()=>{this.flags&Y.Composing||(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>this.syncAtomFromDom(),r))}:this.handleInput=()=>{this.flags&Y.Composing||this.syncAtomFromDom()},X(this.handleFocus),X(this.handleBlur),X(this.handleCompositionStart),X(this.handleCompositionEnd),X(this.handleInput),this.bindEvents(i)}flushPendingDebounce(){this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0,this.syncAtomFromDom())}normalizeDomValue(){let e=this.format(this.atom.peek());if(this.isMultipleSelect){let e=this.$el.val()||[],t=Array.isArray(this.atom.peek())?this.atom.peek():[];this.equal(e,t)||this.$el.val(t)}else this.el.value!==e&&(this.el.value=e)}syncAtomFromDom(){if(!(this.flags&Y.Busy)){this.flags|=Y.SyncingToAtom;try{let e;e=this.isMultipleSelect?this.$el.val()||[]:this.el.value;let t=this.parse(e);this.equal(this.atom.peek(),t)||(this.atom.value=t)}catch(e){G.warn(H.BINDING,W.BINDING.PARSE_ERROR(e instanceof Error?e.message:String(e)),e)}finally{this.flags&=~Y.SyncingToAtom}}}bindEvents(e){let t=this.ns,n=e.trim().split(/\s+/).map(e=>`${e}${t}`).join(` `);this.$el.on(`focus${t}`,this.handleFocus).on(`blur${t}`,this.handleBlur).on(`compositionstart${t}`,this.handleCompositionStart).on(`compositionend${t}`,this.handleCompositionEnd).on(n,this.handleInput)}};function vt(e,t,n){let r=new _t(e,t,n);return{fx:z(r.syncDomFromAtom),cleanup:r.cleanup}}function yt(e,t,n,r){if(Fe(t)){let i=t;q.trackEffect(e,z(()=>{let t=i.value;k(()=>{try{n(t)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,t)})},{name:r}))}else k(()=>{try{n(t)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r,!0),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,t)})}function bt(e,t,n,r){let i=Object.keys(t),a=[],o={};for(let e=0;e<i.length;e++){let n=i[e],r=t[n];Fe(r)?a.push(n):o[n]=r}a.length>0?q.trackEffect(e,z(()=>{let i={...o};for(let e=0;e<a.length;e++){let n=a[e];i[n]=t[n].value}k(()=>{try{n(i)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,i)})},{name:r})):k(()=>{try{n(o)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r,!0),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,o)})}var xt=new Set([`href`,`src`,`action`,`formaction`,`xlink:href`,`data`,`poster`,`background`,`cite`,`longdesc`,`profile`,`usemap`,`classid`,`codebase`]),St=/^\s*(?:javascript|vbscript)\s*:/i,Ct=/(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i,wt=/url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i,Tt=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,Et=/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,Dt={colon:`:`,Tab:` `,NewLine:`
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`jquery`);c=s(c);var l={IDLE:`idle`,PENDING:`pending`,RESOLVED:`resolved`,REJECTED:`rejected`},u={DISPOSED:1,EXECUTING:8},d={DISPOSED:1,IS_COMPUTED:2,DIRTY:8,IDLE:16,PENDING:32,RESOLVED:64,REJECTED:128,RECOMPUTING:256,HAS_ERROR:512,FORCE_COMPUTE:1024},f={DISPOSED:1,SYNC:8,NOTIFICATION_SCHEDULED:16},p={MAX_EXECUTIONS_PER_SECOND:1e3,MAX_EXECUTIONS_PER_EFFECT:100,MAX_EXECUTIONS_PER_FLUSH:1e4,MAX_FLUSH_ITERATIONS:1e3,MIN_FLUSH_ITERATIONS:10,BATCH_QUEUE_SHRINK_THRESHOLD:1e3},m={WARN_INFINITE_LOOP:!0,EFFECT_FREQUENCY_WINDOW:1e3},h={MAX_ASYNC_RETRIES:3,MAX_PROMISE_ID:2**53-1-1},g={UNINITIALIZED:-1,MIN:1},_=1073741823,v={VERSION_BITS:16};typeof process<`u`&&process.env;var y=Object.freeze([]),b=class{constructor(e,t,n=void 0){this.node=e,this.version=t,this.unsub=n}},x=class{constructor(e,t){this.fn=e,this.sub=t}notify(e,t){this.fn?this.fn(e,t):this.sub&&this.sub.execute()}},S=class extends Error{constructor(e,t=null,n=!0){super(e),this.cause=t,this.recoverable=n,this.name=`AtomError`}},C=class extends S{constructor(e,t=null){super(e,t,!0),this.name=`ComputedError`}},w=class extends S{constructor(e,t=null){super(e,t,!1),this.name=`EffectError`}},ee=class extends S{constructor(e,t=null){super(e,t,!1),this.name=`SchedulerError`}},T={COMPUTED_MUST_BE_FUNCTION:`Computed target must be a function`,COMPUTED_ASYNC_PENDING_NO_DEFAULT:`Async computation pending with no default value`,COMPUTED_COMPUTATION_FAILED:`Computation execution failed`,COMPUTED_ASYNC_COMPUTATION_FAILED:`Async computation execution failed`,COMPUTED_CIRCULAR_DEPENDENCY:`Circular dependency detected`,COMPUTED_DISPOSED:`Attempted to access disposed computed`,ATOM_SUBSCRIBER_MUST_BE_FUNCTION:`Subscriber must be a function or Subscriber object`,ATOM_INDIVIDUAL_SUBSCRIBER_FAILED:`Subscriber execution failed`,EFFECT_MUST_BE_FUNCTION:`Effect target must be a function`,EFFECT_EXECUTION_FAILED:`Effect execution failed`,EFFECT_CLEANUP_FAILED:`Effect cleanup failed`,EFFECT_DISPOSED:`Attempted to run disposed effect`,SCHEDULER_FLUSH_OVERFLOW:(e,t)=>`Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,CALLBACK_ERROR_IN_ERROR_HANDLER:`Exception encountered in onError handler`,EFFECT_FREQUENCY_LIMIT_EXCEEDED:`Effect executed too frequently within 1 second. Suspected infinite loop.`,SCHEDULER_CALLBACK_MUST_BE_FUNCTION:`Scheduler callback must be a function`,SCHEDULER_END_BATCH_WITHOUT_START:`endBatch() called without matching startBatch(). Ignoring.`,BATCH_CALLBACK_MUST_BE_FUNCTION:`Batch callback must be a function`},te=class{constructor(){this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._count=0,this._epoch=g.UNINITIALIZED,this._overflow=null}get size(){return this._count}getAt(e){switch(e){case 0:return this._s0;case 1:return this._s1;case 2:return this._s2;case 3:return this._s3;default:{let t=this._overflow;if(t!==null&&e>=4){let n=e-4;if(n<t.length)return t[n]??null}return null}}}setAt(e,t){switch(e){case 0:this._s0=t;break;case 1:this._s1=t;break;case 2:this._s2=t;break;case 3:this._s3=t;break;default:{this._overflow??=[];let n=this._overflow;n[e-4]=t}}e>=this._count&&(this._count=e+1)}truncateFrom(e){let t=this._count;if(e>=t)return;if(e<=3)switch(e){case 0:{let e=this._s0;e!=null&&(this._onItemRemoved(e),this._s0=null)}case 1:{let e=this._s1;e!=null&&(this._onItemRemoved(e),this._s1=null)}case 2:{let e=this._s2;e!=null&&(this._onItemRemoved(e),this._s2=null)}case 3:{let e=this._s3;e!=null&&(this._onItemRemoved(e),this._s3=null)}}let n=this._overflow;if(n!==null&&t>4){let t=e>4?e-4:0,r=n.length;for(let e=t;e<r;e++){let t=n[e];t!=null&&(this._onItemRemoved(t),n[e]=null)}e<=4?(n.length=0,this._overflow=null):n.length=e-4}this._count=e}_onItemRemoved(e){}add(e){if(this._s0===null){this._s0=e,this._count++;return}if(this._s1===null){this._s1=e,this._count++;return}if(this._s2===null){this._s2=e,this._count++;return}if(this._s3===null){this._s3=e,this._count++;return}if(this._overflow===null)this._overflow=[e];else{let t=this._overflow;for(let n=0,r=t.length;n<r;n++)if(t[n]===null){t[n]=e,this._count++;return}t.push(e)}this._count++}remove(e){if(this._s0===e)return this._s0=null,this._count--,!0;if(this._s1===e)return this._s1=null,this._count--,!0;if(this._s2===e)return this._s2=null,this._count--,!0;if(this._s3===e)return this._s3=null,this._count--,!0;let t=this._overflow;if(t==null)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return t[n]=null,this._count--,!0;return!1}has(e){let t=this._count;if(t===0)return!1;if(this._s0===e||this._s1===e||this._s2===e||this._s3===e)return!0;if(t<=4)return!1;let n=this._overflow;if(n!=null){let r=0;this._s0!=null&&r++,this._s1!=null&&r++,this._s2!=null&&r++,this._s3!=null&&r++;for(let i=0,a=n.length;i<a;i++){let a=n[i];if(a!=null){if(a===e)return!0;if(++r===t)break}}}return!1}forEach(e){let t=this._count;if(t===0)return;let n=this._s0;n!=null&&e(n);let r=this._s1;r!=null&&e(r);let i=this._s2;i!=null&&e(i);let a=this._s3;if(a!=null&&e(a),t<=4)return;let o=this._overflow;if(o!=null){let s=0;n!=null&&s++,r!=null&&s++,i!=null&&s++,a!=null&&s++;for(let n=0,r=o.length;n<r;n++){let r=o[n];if(r!=null&&(e(r),++s===t))return}}}forEachIndexed(e){let t=this._count;if(t===0)return 0;let n=0,r=this._s0;r!=null&&(e(r),n++);let i=this._s1;i!=null&&(e(i),n++);let a=this._s2;a!=null&&(e(a),n++);let o=this._s3;if(o!=null&&(e(o),n++),t<=4||n===t)return n;let s=this._overflow;if(s!=null)for(let r=0,i=s.length;r<i;r++){let i=s[r];if(i!=null&&(e(i),++n===t))break}return n}compact(){let e=this._overflow;if(e===null||e.length===0)return;let t=0;for(;t<e.length;)if(e[t]===null){let n=e.pop();t<e.length&&n!=null&&(e[t]=n)}else t++;e.length===0&&(this._overflow=null)}clear(){this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._count=0,this._overflow!==null&&(this._overflow.length=0,this._overflow=null)}dispose(){this.clear()}},ne=Symbol(`AtomEffect.DebugName`),re=Symbol(`AtomEffect.Type`),ie=Symbol(`AtomEffect.NoDefaultValue`),ae={enabled:!1,warnInfiniteLoop:m.WARN_INFINITE_LOOP,warn(e,t){},attachDebugInfo(e,t,n){},getDebugName:e=>e?.[ne],getDebugType:e=>e?.[re]},oe=1,se=()=>oe++;function E(e,t,n){if(e instanceof S)return e;let r=e instanceof Error,i=r?e.message:String(e),a=r?e:void 0;return new t(`${r?e.constructor.name:`Unexpected error`} (${n}): ${i}`,a)}var ce=class{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=g.UNINITIALIZED,this._notifying=0,this._hotIndex=-1,this._slots=null,this._deps=null,this.id=se()&_}subscribe(e){let t=typeof e==`function`;if(!t&&(!e||typeof e.execute!=`function`))throw E(TypeError(`Invalid subscriber`),S,T.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);let n=this._slots;n||(n=new te,this._slots=n);let r=!1;if(n.forEach(n=>{(t?n.fn===e:n.sub===e)&&(r=!0)}),r)return()=>{};let i=new x(t?e:void 0,t?void 0:e);return n.add(i),()=>this._unsubscribe(i)}_unsubscribe(e){if(this._slots){if(this._notifying>0){this._slots.remove(e);return}this._slots.remove(e),this._slots.compact()}}subscriberCount(){return this._slots?this._slots.size:0}_notifySubscribers(e,t){let n=this._slots;if(!(!n||n.size===0)){this._notifying++;try{n.forEach(n=>{try{n.notify(e,t)}catch(e){console.error(E(e,S,T.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}})}finally{this._notifying--,this._notifying===0&&n.compact()}}}_isDirty(){let e=this._deps;if(!e||e.size===0)return!1;if(this._hotIndex!==-1){let t=e.getAt(this._hotIndex);if(t!=null&&t.node.version!==t.version)return!0}return!e.hasComputeds&&!e.isDirtyFast()?!1:this._deepDirtyCheck()}},le=0,ue=()=>(le=le+1&1073741823||1,le),de=e=>e+1&_,fe=0,pe=!1,me=0,he=()=>me;function ge(){return pe?!1:(pe=!0,me=ue(),fe=0,!0)}var _e=()=>{pe=!1},ve=()=>pe?++fe:0,ye=(function(e){return e[e.IDLE=0]=`IDLE`,e[e.BATCHING=1]=`BATCHING`,e[e.FLUSHING=2]=`FLUSHING`,e})({}),D=new class{constructor(){this._queueBuffer=[[],[]],this._bufferIndex=0,this._size=0,this._epoch=0,this._isProcessing=!1,this._isBatching=!1,this._isFlushingSync=!1,this._batchDepth=0,this._batchQueue=[],this._batchQueueSize=0,this._maxFlushIterations=p.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get phase(){return this._isProcessing||this._isFlushingSync?ye.FLUSHING:this._isBatching?ye.BATCHING:ye.IDLE}get queueSize(){return this._size}get isBatching(){return this._isBatching}schedule(e){if(e._nextEpoch!==this._epoch){if(e._nextEpoch=this._epoch,this._isBatching||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=e;return}this._queueBuffer[this._bufferIndex][this._size++]=e,this._isProcessing||this._flush()}}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0)return;let e=ge();this._drainQueue(),e&&_e()}finally{this._isProcessing=!1,this._size>0&&!this._isBatching&&this._flush()}}_flushSync(){this._isFlushingSync=!0;let e=ge();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=!1,e&&_e()}}_mergeBatchQueue(){if(this._batchQueueSize===0)return;let e=++this._epoch,t=this._batchQueue,n=this._queueBuffer[this._bufferIndex],r=this._size;for(let i=0;i<this._batchQueueSize;i++){let a=t[i];a._nextEpoch!==e&&(a._nextEpoch=e,n[r++]=a)}this._size=r,this._batchQueueSize=0,t.length=0}_drainQueue(){let e=0;for(;this._size>0;){if(++e>this._maxFlushIterations){this._handleFlushOverflow();return}this._processQueue(),this._mergeBatchQueue()}}_processQueue(){let e=this._bufferIndex,t=this._queueBuffer[e],n=this._size;this._bufferIndex=e^1,this._size=0,this._epoch++;for(let e=0;e<n;e++)try{let n=t[e];typeof n==`function`?n():n.execute()}catch(e){console.error(new ee(`Error occurred during scheduler execution`,e))}t.length=0}_handleFlushOverflow(){let e=this._size+this._batchQueueSize;if(console.error(new ee(T.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,e))),this._size=0,this._queueBuffer[this._bufferIndex].length=0,this._batchQueueSize=0,this.onOverflow)try{this.onOverflow(e)}catch{}}startBatch(){this._batchDepth++,this._isBatching=!0}endBatch(){this._batchDepth!==0&&--this._batchDepth===0&&(this._flushSync(),this._isBatching=!1)}setMaxFlushIterations(e){if(e<p.MIN_FLUSH_ITERATIONS)throw new ee(`Max flush iterations must be at least ${p.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=e}},be=Symbol.for(`atom-effect/atom`),xe=Symbol.for(`atom-effect/computed`),Se=Symbol.for(`atom-effect/effect`),Ce=Symbol.for(`atom-effect/writable`),O={current:null,run(e,t){let n=this.current;this.current=e;try{return t()}finally{this.current=n}}};function k(e){let t=O.current;if(t===null)return e();O.current=null;try{return e()}finally{O.current=t}}var we=class extends ce{constructor(e,t){super(),this[be]=!0,this[Ce]=!0,this._value=e,this._pendingOldValue=void 0,t&&(this.flags|=f.SYNC),ae.attachDebugInfo(this,`atom`,this.id)}get value(){return O.current?.addDependency(this),this._value}set value(e){let t=this._value;if(Object.is(t,e))return;this._value=e,this.version=de(this.version);let n=this._slots,r=this.flags;if(n==null||n.size===0||r&f.NOTIFICATION_SCHEDULED)return;this._pendingOldValue=t;let i=r|f.NOTIFICATION_SCHEDULED;if(this.flags=i,(i&f.SYNC)!==0&&!D.isBatching){this._flushNotifications();return}D.schedule(this)}execute(){this._flushNotifications()}_flushNotifications(){let e=this.flags;if(!(e&f.NOTIFICATION_SCHEDULED)||e&f.DISPOSED)return;let t=this._pendingOldValue;this._pendingOldValue=void 0,this.flags&=~f.NOTIFICATION_SCHEDULED,this._notifySubscribers(this._value,t)}peek(){return this._value}dispose(){this.flags&f.DISPOSED||(this._slots?.clear(),this.flags|=f.DISPOSED,this._value=void 0,this._pendingOldValue=void 0)}_deepDirtyCheck(){return!1}[Symbol.dispose](){this.dispose()}};function Te(e,t={}){return new we(e,t.sync??!1)}var Ee=class extends te{constructor(){super(),this._map=null,this._SCAN_THRESHOLD=32,this.hasComputeds=!1,this._depsHash=0,this._map=null,this.hasComputeds=!1,this._depsHash=0}prepareTracking(){this.hasComputeds=!1}_onItemRemoved(e){let t=e.unsub;t&&t()}claimExisting(e,t){let n=this._count;if(t>=n)return!1;let r=n-t;if(this._map!==null||r>this._SCAN_THRESHOLD)return this._claimViaMap(e,t);if(t<4)switch(t){case 0:{let t=this._s0;if(t&&t.node===e&&t.unsub)return t.version=e.version,!0}case 1:if(n>1){let n=this._s1;if(n&&n.node===e&&n.unsub)return n.version=e.version,t!==1&&(this._s1=this._s0,this._s0=n),!0}case 2:if(n>2){let n=this._s2;if(n&&n.node===e&&n.unsub){if(n.version=e.version,t!==2){let e=t===0?this._s0:this._s1;t===0?this._s0=n:this._s1=n,this._s2=e}return!0}}case 3:if(n>3){let n=this._s3;if(n&&n.node===e&&n.unsub){if(n.version=e.version,t!==3){let e;t===0?(e=this._s0,this._s0=n):t===1?(e=this._s1,this._s1=n):(e=this._s2,this._s2=n),this._s3=e}return!0}}}let i=t>4?t:4,a=this._overflow;if(a)for(let n=i-4,r=a.length;n<r;n++){let r=a[n];if(r&&r.node===e&&r.unsub)return r.version=e.version,this._swapGeneral(n+4,t,r),!0}return!1}_claimViaMap(e,t){if(this._map===null){this._map=new Map;let e=this._count;t<4&&(t<=0&&this._s0?.unsub&&this._map.set(this._s0.node,0),t<=1&&this._s1?.unsub&&this._map.set(this._s1.node,1),t<=2&&this._s2?.unsub&&this._map.set(this._s2.node,2),t<=3&&this._s3?.unsub&&this._map.set(this._s3.node,3));let n=this._overflow;if(n&&e>4){let e=t>4?t:4;for(let t=e-4,r=n.length;t<r;t++){let e=n[t];e?.unsub&&this._map.set(e.node,t+4)}}}let n=this._map.get(e);if(n===void 0||n<t)return!1;let r=this.getAt(n);if(r==null||!r.unsub)return!1;if(r.version=e.version,n!==t){let i=this.getAt(t);this.setAt(t,r),this.setAt(n,i),i?.unsub&&this._map.set(i.node,n),this._map.set(e,t)}return!0}_swapInline(e,t,n){let r=this.getAt(t);this.setAt(t,n),this.setAt(e,r)}_swapGeneral(e,t,n){if(e===t)return;let r=this.getAt(t);if(this.setAt(t,n),e===0)this._s0=r;else if(e===1)this._s1=r;else if(e===2)this._s2=r;else if(e===3)this._s3=r;else{let t=this._overflow;t[e-4]=r}}insertNew(e,t){let n=this._count;if(e<n){let t=this.getAt(e);t!=null&&(this.add(t),this._map!==null&&t.unsub&&this._map.set(t.node,this._count-1))}if(e===0)this._s0=t;else if(e===1)this._s1=t;else if(e===2)this._s2=t;else if(e===3)this._s3=t;else{let n=this._overflow;n||(n=[],this._overflow=n),n[e-4]=t}e>=n&&(this._count=e+1)}truncateFrom(e){e>=this._count||(super.truncateFrom(e),this._map!==null&&(this._map.clear(),this._map=null))}seal(){let e=this._count,t=v.VERSION_BITS,n=0;switch(e){case 0:this._depsHash=0;return;case 1:{let e=this._s0;n=n+(e.version<<t)+e.node.id|0;break}case 2:{let e=this._s0,r=this._s1;n=n+(e.version<<t)+e.node.id|0,n=n+(r.version<<t)+r.node.id|0;break}case 3:{let e=this._s0,r=this._s1,i=this._s2;n=n+(e.version<<t)+e.node.id|0,n=n+(r.version<<t)+r.node.id|0,n=n+(i.version<<t)+i.node.id|0;break}default:{let r=this._s0,i=this._s1,a=this._s2,o=this._s3;if(n=n+(r.version<<t)+r.node.id|0,n=n+(i.version<<t)+i.node.id|0,n=n+(a.version<<t)+a.node.id|0,n=n+(o.version<<t)+o.node.id|0,e>4){let e=this._overflow;for(let r=0,i=e.length;r<i;r++){let i=e[r];n=n+(i.version<<t)+i.node.id|0}}}}this._depsHash=n}isDirtyFast(){let e=this._count,t=v.VERSION_BITS,n=0;switch(e){case 0:return!1;case 1:{let e=this._s0.node;n=n+(e.version<<t)+e.id|0;break}case 2:{let e=this._s0.node,r=this._s1.node;n=n+(e.version<<t)+e.id|0,n=n+(r.version<<t)+r.id|0;break}case 3:{let e=this._s0.node,r=this._s1.node,i=this._s2.node;n=n+(e.version<<t)+e.id|0,n=n+(r.version<<t)+r.id|0,n=n+(i.version<<t)+i.id|0;break}default:{let r=this._s0.node,i=this._s1.node,a=this._s2.node,o=this._s3.node;if(n=n+(r.version<<t)+r.id|0,n=n+(i.version<<t)+i.id|0,n=n+(a.version<<t)+a.id|0,n=n+(o.version<<t)+o.id|0,e>4){let e=this._overflow;for(let r=0,i=e.length;r<i;r++){let i=e[r].node;n=n+(i.version<<t)+i.id|0}}}}return n!==this._depsHash}disposeAll(){this._count>0&&this.truncateFrom(0),this.hasComputeds=!1,this._map!==null&&(this._map.clear(),this._map=null)}remove(e){throw Error(`remove() is strictly prohibited in DepSlotBuffer to preserve sequential cache paths.`)}compact(){}};function A(e){return typeof e==`object`&&!!e&&be in e}function De(e){return typeof e==`object`&&!!e&&xe in e}function Oe(e){return typeof e==`object`&&!!e&&typeof e.then==`function`}var{IDLE:j,DIRTY:M,PENDING:N,RESOLVED:P,REJECTED:F,HAS_ERROR:I,RECOMPUTING:L,DISPOSED:ke,IS_COMPUTED:Ae,FORCE_COMPUTE:je}=d,Me=class extends ce{constructor(e,t={}){if(typeof e!=`function`)throw new C(T.COMPUTED_MUST_BE_FUNCTION);if(super(),this[be]=!0,this[xe]=!0,this._error=null,this._promiseId=0,this._deps=new Ee,this._asyncRetryCount=0,this._lastDriftEpoch=g.UNINITIALIZED,this._trackEpoch=g.UNINITIALIZED,this._trackCount=0,this._value=void 0,this.flags=Ae|M|j,this._equal=t.equal??Object.is,this._fn=e,this._defaultValue=`defaultValue`in t?t.defaultValue:ie,this._onError=t.onError??null,this._maxAsyncRetries=(t.maxAsyncRetries??h.MAX_ASYNC_RETRIES)&_,ae.attachDebugInfo(this,`computed`,this.id),t.lazy===!1)try{this._recompute()}catch{}}_track(){O.current?.addDependency(this)}get value(){this._track();let e=this.flags;if((e&(P|M|j))===P)return this._value;if(e&ke)throw new C(T.COMPUTED_DISPOSED);if(e&L){if(this._defaultValue!==ie)return this._defaultValue;throw new C(T.COMPUTED_CIRCULAR_DEPENDENCY)}if(e&(M|j)&&((e&j)===0&&(e&je)===0&&this._deps.size>0&&!this._isDirty()?this.flags&=~M:this._recompute(),this.flags&P))return this._value;let t=this._defaultValue,n=t!==ie;if(this.flags&N){if(n)return t;throw new C(T.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if(this.flags&F){if(n)return t;throw this._error}return this._value}peek(){return this._value}get state(){this._track();let e=this.flags;return e&P?l.RESOLVED:e&N?l.PENDING:e&F?l.REJECTED:l.IDLE}get hasError(){if(this._track(),this.flags&(F|I))return!0;let e=this._deps;if(!e.hasComputeds)return!1;let t=e.size;for(let n=0;n<t;n++){let t=e.getAt(n);if(t!=null&&t.node.flags&I)return!0}return!1}get isValid(){return!this.hasError}get errors(){this._track();let e=[];this._error&&e.push(this._error);let t=this._deps;if(!t.hasComputeds)return e.length===0?y:Object.freeze(e);let n=t.size;for(let r=0;r<n;r++){let n=t.getAt(r);if(n==null)continue;let i=n.node;i.flags&I&&this._collectErrorsFromDep(i,e)}return e.length===0?y:Object.freeze(e)}_collectErrorsFromDep(e,t){let n=e.errors,r=n.length;for(let e=0;e<r;e++){let r=n[e];r!=null&&!t.includes(r)&&t.push(r)}}get lastError(){return this._track(),this._error}get isPending(){return this._track(),(this.flags&N)!==0}get isResolved(){return this._track(),(this.flags&P)!==0}invalidate(){this.flags|=je,this._markDirty()}dispose(){this.flags&ke||(this._deps.disposeAll(),this._slots?.clear(),this.flags=ke|M|j,this._error=null,this._value=void 0,this._hotIndex=-1)}[Symbol.dispose](){this.dispose()}addDependency(e){if(e._lastSeenEpoch===this._trackEpoch)return;e._lastSeenEpoch=this._trackEpoch;let t=this._trackCount,n=this._deps.getAt(t);if(n!=null&&n.node===e)n.version=e.version;else if(!this._deps.claimExisting(e,t)){let n=new b(e,e.version,e.subscribe(this));this._deps.insertNew(t,n)}e.flags&Ae&&(this._deps.hasComputeds=!0),this._trackCount=t+1}_recompute(){if(this.flags&L)return;this.flags=(this.flags|L)&~je,this._trackEpoch=ue(),this._trackCount=0,this._deps.prepareTracking(),this._hotIndex=-1;let e=!1;try{let t=O.run(this,this._fn);this._deps.truncateFrom(this._trackCount),this._deps.seal(),e=!0,Oe(t)?this._handleAsyncComputation(t):this._finalizeResolution(t)}catch(t){if(!e)try{this._deps.truncateFrom(this._trackCount)}catch{}this._handleError(t,T.COMPUTED_COMPUTATION_FAILED,!0)}finally{this._trackEpoch=g.UNINITIALIZED,this._trackCount=0,this.flags&=~L}}_handleAsyncComputation(e){this.flags=(this.flags|N)&~(j|M|P|F),this._notifySubscribers(void 0,void 0),this._asyncRetryCount=0,this._promiseId=(this._promiseId+1)%h.MAX_PROMISE_ID;let t=this._promiseId;e.then(e=>{if(t===this._promiseId){if(this._isDirty()){let e=he();return this._lastDriftEpoch!==e&&(this._lastDriftEpoch=e,this._asyncRetryCount=0),this._asyncRetryCount++<this._maxAsyncRetries?this._markDirty():this._handleError(new C(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),T.COMPUTED_ASYNC_COMPUTATION_FAILED)}this._finalizeResolution(e),this._notifySubscribers(e,void 0)}},e=>t===this._promiseId&&this._handleError(e,T.COMPUTED_ASYNC_COMPUTATION_FAILED))}_handleError(e,t,n=!1){let r=E(e,C,t);if(!n&&!(this.flags&F)&&(this.version=de(this.version)),this._error=r,this.flags=this.flags&~(j|M|N|P)|F|I,this._onError)try{this._onError(r)}catch(e){console.error(T.CALLBACK_ERROR_IN_ERROR_HANDLER,e)}if(n)throw r;this._notifySubscribers(void 0,void 0)}_finalizeResolution(e){(!(this.flags&P)||!this._equal(this._value,e))&&(this.version=de(this.version)),this._value=e,this._error=null,this.flags=(this.flags|P)&~(j|M|N|F|I)}execute(){this._markDirty()}_markDirty(){this.flags&(L|M)||(this.flags|=M,this._notifySubscribers(void 0,void 0))}_isDirty(){let e=this._deps;return e.hasComputeds?this._deepDirtyCheck():e.isDirtyFast()}_deepDirtyCheck(){let e=this._deps,t=O.current;O.current=null;try{let t=e.size;for(let n=0;n<t;n++){let t=e.getAt(n);if(t==null)continue;let r=t.node;if(r.flags&Ae)try{r.value}catch{}if(r.version!==t.version)return this._hotIndex=n,!0}return this._hotIndex=-1,!1}finally{O.current=t}}};function R(e,t={}){return new Me(e,t)}var Ne=class extends ce{constructor(e,t={}){super(),this[Se]=!0,this._cleanup=null,this._deps=new Ee,this._currentEpoch=g.UNINITIALIZED,this._lastFlushEpoch=g.UNINITIALIZED,this._fn=e,this._onError=t.onError??null,this._sync=t.sync??!1,this._maxExecutions=t.maxExecutionsPerSecond??p.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=t.maxExecutionsPerFlush??p.MAX_EXECUTIONS_PER_EFFECT,this._cleanup=null,this._deps=new Ee,this._currentEpoch=g.UNINITIALIZED,this._lastFlushEpoch=g.UNINITIALIZED,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._trackCount=0,this._sync?this._notifyCallback=()=>this.execute():this._notifyCallback=()=>D.schedule(this),ae.attachDebugInfo(this,`effect`,this.id)}run(){if(this.flags&u.DISPOSED)throw new w(T.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.flags&u.DISPOSED||(this.flags|=u.DISPOSED,this._execCleanup(),this._deps?.disposeAll())}[Symbol.dispose](){this.dispose()}addDependency(e){if(!(this.flags&u.EXECUTING))return;let t=this._currentEpoch;if(e._lastSeenEpoch===t)return;e._lastSeenEpoch=t;let n=this._trackCount,r=this._deps,i;i=n===0?r._s0:n===1?r._s1:n===2?r._s2:n===3?r._s3:r.getAt(n),i!=null&&i.node===e?i.version=e.version:r.claimExisting(e,n)||this._insertNewDependency(e,n),e.flags&d.IS_COMPUTED&&(r.hasComputeds=!0),this._trackCount=n+1}_insertNewDependency(e,t){let n;try{let t=e.subscribe(this._notifyCallback);n=new b(e,e.version,t)}catch(t){let r=E(t,w,T.EFFECT_EXECUTION_FAILED);if(console.error(r),this._onError)try{this._onError(r)}catch{}n=new b(e,e.version,void 0)}this._deps.insertNew(t,n)}execute(e=!1){if(this.flags&(u.DISPOSED|u.EXECUTING))return;let t=this._deps;if(!e&&t.size>0&&!this._isDirty())return;this._checkInfiniteLoops(),this.flags|=u.EXECUTING,this._execCleanup(),this._currentEpoch=ue(),this._trackCount=0,t.prepareTracking(),this._hotIndex=-1;let n=!1;try{let e=O.run(this,this._fn);t.truncateFrom(this._trackCount),t.seal(),n=!0,Oe(e)?this._handleAsyncResult(e):this._cleanup=typeof e==`function`?e:null}catch(e){if(!n)try{t.truncateFrom(this._trackCount)}catch{}this._handleExecutionError(e),this._cleanup=null}finally{this.flags&=~u.EXECUTING}}_isDirty(){let e=this._deps;return e.hasComputeds?this._deepDirtyCheck():e.isDirtyFast()}_handleAsyncResult(e){let t=++this._execId;e.then(e=>{if(t!==this._execId||this.flags&u.DISPOSED){if(typeof e==`function`)try{e()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}return}typeof e==`function`&&(this._cleanup=e)},e=>t===this._execId&&this._handleExecutionError(e))}_deepDirtyCheck(){let e=O.current;O.current=null;let t=this._deps;try{let e=t.size;for(let n=0;n<e;n++){let e=t.getAt(n);if(e==null)continue;let r=e.node;if(r.flags&d.IS_COMPUTED&&this._tryPullComputed(r),r.version!==e.version)return this._hotIndex=n,!0}return!1}finally{O.current=e}}_tryPullComputed(e){try{e.value}catch{}}_execCleanup(){if(this._cleanup){try{this._cleanup()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}this._cleanup=null}}_checkInfiniteLoops(){let e=he();this._lastFlushEpoch!==e&&(this._lastFlushEpoch=e,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError(`per-effect`),ve()>p.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError(`global`),this._executionCount++}_checkFrequencyLimit(){if(!Number.isFinite(this._maxExecutions))return;let e=Date.now();if(e-this._windowStart>=m.EFFECT_FREQUENCY_WINDOW){this._windowStart=e,this._windowCount=1;return}if(++this._windowCount>this._maxExecutions){let e=new w(T.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(e),e}}get isDisposed(){return(this.flags&u.DISPOSED)!==0}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&u.EXECUTING)!==0}_throwInfiniteLoopError(e){let t=new w(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${fe}`);throw this.dispose(),console.error(t),t}_handleExecutionError(e,t=T.EFFECT_EXECUTION_FAILED){let n=E(e,w,t);if(console.error(n),this._onError)try{this._onError(n)}catch(e){console.error(E(e,w,T.CALLBACK_ERROR_IN_ERROR_HANDLER))}}};function z(e,t={}){if(typeof e!=`function`)throw new w(T.EFFECT_MUST_BE_FUNCTION);let n=new Ne(e,t);return n.execute(),n}function Pe(e){if(typeof e!=`function`)throw TypeError(T.BATCH_CALLBACK_MUST_BE_FUNCTION);D.startBatch();try{return e()}finally{D.endBatch()}}function Fe(e){return A(e)}function B(e){let t=e.tagName.toLowerCase();if(e.id)return`${t}#${e.id}`;let n=e.classList,r=n.length;if(r===0)return t;let i=t;for(let e=0;e<r;e++)i+=`.${n[e]}`;return i}var V=Object.prototype.hasOwnProperty;function Ie(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=e,a=t;for(let e=0;e<n.length;e++){let t=n[e];if(!V.call(a,t)||i[t]!==a[t])return!1}return!0}var H={ROUTE:`[atom-route]`,BINDING:`[atom-binding]`,LIST:`[atom-list]`,MOUNT:`[atom-mount]`},U=Object.freeze({mode:`hash`,basePath:``,autoBindLinks:!1,activeClass:`active`}),Le={EVENT:`input`,DEBOUNCE:0},Re={HIGHLIGHT_DURATION_MS:500},ze=new Set([`input`,`select`,`textarea`]),Be=new Set([`src`,`href`,`action`,`formaction`,`data`,`poster`,`background`,`cite`,`longdesc`,`profile`,`usemap`,`classid`,`codebase`,`xlink:href`]),Ve=new Set([`innerHTML`,`outerHTML`,`srcdoc`,`__proto__`,`constructor`,`prototype`]),W={ROUTE:{NOT_FOUND:e=>`Route "${e}" not found and no notFound route configured`,TEMPLATE_NOT_FOUND:e=>`Template "${e}" not found`,TARGET_NOT_FOUND:e=>`Target element "${e}" not found`,MALFORMED_URI:e=>`Malformed URI component: ${e}`},SECURITY:{UNSAFE_CONTENT:()=>`Unsafe content neutralized during sanitization.`,BLOCKED_CSS_VALUE:e=>`Blocked dangerous value in CSS style property "${e}".`,BLOCKED_EVENT_HANDLER:e=>`Blocked setting dangerous event handler attribute/property "${e}".`,BLOCKED_PROTOCOL:e=>`Blocked dangerous protocol in "${e}".`,BLOCKED_PROP:e=>`Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`},BINDING:{INVALID_INPUT_ELEMENT:e=>`Val binding used on non-input element <${e}>.`,MISSING_SOURCE:e=>`[${e}] source is required when prop/name is a string.`,MISSING_CONDITION:e=>`[${e}] condition is required when className is a string.`,UPDATER_ERROR:(e,t)=>`Updater threw in binding "${e}"${t?` (static)`:``}`,CLEANUP_ERROR:e=>`Binding cleanup error${e?`: ${e}`:``}`,PARSE_ERROR:e=>`parse() threw during DOM→Atom sync${e?`: ${e}`:``}`},LIST:{DUPLICATE_KEY:(e,t,n)=>`Duplicate key "${e}" at index ${t} in atomList <${n}>.`},MOUNT:{ERROR:e=>`Mount error${e?` in component <${e}>`:``}`,CLEANUP_ERROR:e=>`Cleanup error${e?` in component <${e}>`:``}`},CORE:{EFFECT_DISPOSE_ERROR:e=>`Effect dispose error${e?`: ${e}`:``}`}},He=`${Re.HIGHLIGHT_DURATION_MS/1e3}s`;function Ue(){if(typeof window<`u`){let e=window.__ATOM_DEBUG__;if(typeof e==`boolean`)return e}try{if(globalThis.process?.env?.VITE_ATOM_DEBUG===`true`)return!0}catch{}return!1}var We=Ue(),G={get enabled(){if(typeof window<`u`){let e=window.__ATOM_DEBUG__;if(typeof e==`boolean`)return e}return We},set enabled(e){We=e},log(e,...t){this.enabled&&console.log(`${e}`,...t)},atomChanged(e,t,n,r){this.enabled&&console.log(`${e} Atom "${t??`anonymous`}" changed:`,n,`→`,r)},domUpdated(e,t,n,r){if(!this.enabled)return;let i=t instanceof Element?t:t[0];i&&(console.log(`${e} DOM updated: ${B(i)}.${n} =`,r),Ze(i))},cleanup(e,t){this.enabled&&console.log(`${e} Cleanup: ${t}`)},warn(e,t,...n){console.warn(`${e} ${t}`,...n)},error(e,t,n){console.error(`${e} ${t}`,n)}},Ge=`atom-debug-highlight`,Ke=`data-atom-debug`,qe;function Je(){if((qe instanceof HTMLStyleElement?qe:qe?.deref())?.isConnected||document.querySelector(`style[${Ke}]`))return;let e=document.createElement(`style`);e.setAttribute(Ke,``),e.textContent=`.${Ge}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${He} ease-out}`,document.head.appendChild(e),qe=typeof WeakRef<`u`?new WeakRef(e):e}var Ye=new WeakMap,Xe=new WeakMap;function Ze(e){if(!G.enabled||!e.isConnected)return;Je();let t=Xe.get(e);t!==void 0&&cancelAnimationFrame(t);let n=Ye.get(e);n!==void 0&&clearTimeout(n);let r=requestAnimationFrame(()=>{Xe.delete(e),e.isConnected&&(e.classList.add(Ge),Ye.set(e,setTimeout(()=>{e.isConnected&&e.classList.remove(Ge),Ye.delete(e)},Re.HIGHLIGHT_DURATION_MS)))});Xe.set(e,r)}function Qe(e,t){return Te(e,t)}Object.defineProperty(Qe,`debug`,{enumerable:!0,configurable:!0,get(){return G.enabled},set(e){G.enabled=e}});function $e(){return new Promise(e=>setTimeout(e,0))}var et={atom:Qe,computed:R,effect:z,batch:Pe,untracked:k,isAtom:A,isComputed:De,isReactive:Fe,nextTick:$e};c.default.extend(et);var tt=class{constructor(e=50,t=256){this.limit=e,this.capacity=t,this.pool=[]}acquire(){return this.pool.pop()??[]}release(e){e.length>this.capacity||this.pool.length>=this.limit||Object.isFrozen(e)||(e.length=0,this.pool.push(e))}reset(){this.pool.length=0}},nt=class{constructor(e,t,n=64){this.factory=e,this.reset=t,this.limit=n,this.pool=[]}acquire(){return this.pool.pop()??this.factory()}release(e){this.pool.length>=this.limit||(this.reset(e),this.pool.push(e))}drain(){this.pool.length=0}get size(){return this.pool.length}},rt=new tt,it=new tt,at=new nt(()=>({effects:void 0,cleanups:void 0,componentCleanup:void 0}),e=>{e.effects=void 0,e.cleanups=void 0,e.componentCleanup=void 0},128),K=`_aes-bound`,q=new class{constructor(){this.records=new WeakMap,this.preservedNodes=new WeakSet,this.ignoredNodes=new WeakSet}keep(e){this.preservedNodes.add(e)}isKept(e){return this.preservedNodes.has(e)}markIgnored(e){this.ignoredNodes.add(e)}isIgnored(e){return this.ignoredNodes.has(e)}getOrCreateRecord(e){let t=this.records.get(e);return t||(t=at.acquire(),this.records.set(e,t),e.classList.add(K)),t}trackEffect(e,t){let n=this.getOrCreateRecord(e);n.effects??=rt.acquire(),n.effects.push(t)}trackCleanup(e,t){let n=this.getOrCreateRecord(e);n.cleanups??=it.acquire(),n.cleanups.push(t)}setComponentCleanup(e,t){let n=this.getOrCreateRecord(e);n.componentCleanup=t}hasBind(e){return this.records.has(e)}cleanup(e){let t=this.records.get(e);if(!t){e.nodeType===1&&e.classList.remove(K),this.preservedNodes.delete(e),this.ignoredNodes.delete(e);return}if(this.records.delete(e),this.preservedNodes.delete(e),this.ignoredNodes.delete(e),e.nodeType===1&&e.classList.remove(K),G.enabled){let t=e.nodeType===1?B(e):e.nodeName||`Node`;G.cleanup(H.BINDING,t)}if(t.componentCleanup)try{t.componentCleanup()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.MOUNT,W.MOUNT.CLEANUP_ERROR(n),t)}if(t.effects){let n=t.effects;for(let t=0,r=n.length;t<r;t++)try{n[t].dispose()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.BINDING,W.CORE.EFFECT_DISPOSE_ERROR(n),t)}rt.release(n),t.effects=void 0}if(t.cleanups){let n=t.cleanups;for(let t=0,r=n.length;t<r;t++)try{n[t]()}catch(t){let n=e.nodeType===1?B(e):`Node`;G.error(H.BINDING,W.BINDING.CLEANUP_ERROR(n),t)}it.release(n),t.cleanups=void 0}at.release(t)}cleanupDescendants(e){let t=`getElementsByClassName`in e&&typeof e.getElementsByClassName==`function`?e.getElementsByClassName(K):e.querySelectorAll(`.${K}`);for(let e=t.length-1;e>=0;e--){let n=t[e];n&&(this.records.has(n)?this.cleanup(n):(n.classList.remove(K),G.enabled&&G.warn(H.BINDING,`${K} class found on unregistered element:`,n)))}}cleanupTree(e){(e.nodeType===1||e.nodeType===11)&&this.cleanupDescendants(e),this.cleanup(e)}},ot=new Map;function st(e){if(ot.has(e))return;let t=new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){let n=e[t].removedNodes;for(let e=0,t=n.length;e<t;e++){let t=n[e];t.nodeType===1&&(t.isConnected||q.isKept(t)||q.isIgnored(t)||q.cleanupTree(t))}}});t.observe(e,{childList:!0,subtree:!0}),ot.set(e,t)}function ct(){ot.forEach(e=>e.disconnect()),ot.clear()}var lt=Symbol(`atom-effect-internal`),ut=new WeakMap,J=null,dt=e=>{if(e[lt])return e;let t=ut.get(e);return t||(t=function(...t){return Pe(()=>e.apply(this,t))},t[lt]=!0,ut.set(e,t)),t};function ft(e){let t={},n=Object.entries(e);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r[0],a=r[1];a&&(t[i]=dt(a))}return t}function pt(e){let t={},n=Object.entries(e);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r[0],a=r[1];t[i]=a?ut.get(a)??a:void 0}return t}function mt(){if(J!==null)return;J={on:c.default.fn.on,off:c.default.fn.off,remove:c.default.fn.remove,empty:c.default.fn.empty,detach:c.default.fn.detach};let e=J;c.default.fn.remove=function(t){let n=t?this.filter(t):this;for(let e=0,t=n.length;e<t;e++){let t=n[e];t&&(q.markIgnored(t),q.cleanupTree(t))}let r=e.remove.call(this,t);return r===void 0?this:r},c.default.fn.empty=function(){for(let e=0,t=this.length;e<t;e++){let t=this[e];t?.hasChildNodes()&&q.cleanupDescendants(t)}let t=e.empty.call(this);return t===void 0?this:t},c.default.fn.detach=function(t){let n=t?this.filter(t):this;for(let e=0,t=n.length;e<t;e++){let t=n[e];t&&q.keep(t)}let r=e.detach.call(this,t);return r===void 0?this:r},c.default.fn.on=function(...t){let n=t[0];if(n&&typeof n==`object`)t[0]=ft(n);else{let e=t.length-1;e>=0&&typeof t[e]==`function`&&(t[e]=dt(t[e]))}let r=e.on.apply(this,t);return r===void 0?this:r},c.default.fn.off=function(...t){let n=t[0];if(n&&typeof n==`object`)t[0]=pt(n);else{let e=t.length-1;if(e>=0&&typeof t[e]==`function`){let n=t[e];t[e]=ut.get(n)??n}}let r=e.off.apply(this,t);return r===void 0?this:r}}function ht(){J!==null&&(c.default.fn.on=J.on,c.default.fn.off=J.off,c.default.fn.remove=J.remove,c.default.fn.empty=J.empty,c.default.fn.detach=J.detach,J=null)}var Y=function(e){return e[e.None=0]=`None`,e[e.Focused=1]=`Focused`,e[e.Composing=2]=`Composing`,e[e.SyncingToAtom=4]=`SyncingToAtom`,e[e.SyncingToDom=8]=`SyncingToDom`,e[e.Busy=14]=`Busy`,e}({}),gt=0;function X(e){e[lt]=!0}var _t=class{constructor(e,t,n){this.flags=0,this.timeoutId=void 0,this.handleCompositionStart=()=>{this.flags|=Y.Composing},this.handleCompositionEnd=()=>{this.flags&=~Y.Composing,this.handleInput()},this.handleFocus=()=>{this.flags|=Y.Focused},this.handleBlur=()=>{this.flags&=~Y.Focused;let e=!!(this.flags&Y.Composing);this.flags&=~Y.Composing,this.flushPendingDebounce(),e&&this.timeoutId===void 0&&this.syncAtomFromDom(),this.normalizeDomValue()},this.syncDomFromAtom=()=>{let e=this.atom.value;k(()=>{let t=this.format(e),n;if(n=this.isMultipleSelect?this.$el.val()||[]:this.el.value,this.equal(n,e))return;let r=!!(this.flags&Y.Focused);if(r)try{let t=this.isMultipleSelect?n:this.parse(this.el.value);if(this.equal(t,e))return}catch{}this.flags|=Y.SyncingToDom;try{if(this.isMultipleSelect)this.$el.val(e);else if(r&&(this.el instanceof HTMLInputElement||this.el instanceof HTMLTextAreaElement))try{let e=this.el.selectionStart,n=this.el.selectionEnd;this.el.value=t;let r=t.length;e!==null&&n!==null&&this.el.setSelectionRange(e<r?e:r,n<r?n:r)}catch{this.el.value=t}else this.el.value=t;G.enabled&&G.domUpdated(H.BINDING,this.$el,`val`,t)}finally{this.flags&=~Y.SyncingToDom}})},this.cleanup=()=>{this.$el.off(this.ns),clearTimeout(this.timeoutId),this.timeoutId=void 0},this.$el=e,this.el=e[0],this.atom=t,this.isMultipleSelect=this.el.tagName===`SELECT`&&this.el.multiple,this.ns=`.atomBind-${++gt}`;let r=n.debounce??0,i=n.event??Le.EVENT;this.parse=n.parse??(e=>e),this.format=n.format??(e=>this.isMultipleSelect?(Array.isArray(e)?e:e?[String(e)]:[]).join(`,`):String(e??``));let a=n.equal??Object.is;this.equal=(e,t)=>a(e,t)?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])):!1,r>0?this.handleInput=()=>{this.flags&Y.Composing||(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>this.syncAtomFromDom(),r))}:this.handleInput=()=>{this.flags&Y.Composing||this.syncAtomFromDom()},X(this.handleFocus),X(this.handleBlur),X(this.handleCompositionStart),X(this.handleCompositionEnd),X(this.handleInput),this.bindEvents(i)}flushPendingDebounce(){this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0,this.syncAtomFromDom())}normalizeDomValue(){let e=this.format(this.atom.peek());if(this.isMultipleSelect){let e=this.$el.val()||[],t=Array.isArray(this.atom.peek())?this.atom.peek():[];this.equal(e,t)||this.$el.val(t)}else this.el.value!==e&&(this.el.value=e)}syncAtomFromDom(){if(!(this.flags&Y.Busy)){this.flags|=Y.SyncingToAtom;try{let e;e=this.isMultipleSelect?this.$el.val()||[]:this.el.value;let t=this.parse(e);this.equal(this.atom.peek(),t)||(this.atom.value=t)}catch(e){G.warn(H.BINDING,W.BINDING.PARSE_ERROR(e instanceof Error?e.message:String(e)),e)}finally{this.flags&=~Y.SyncingToAtom}}}bindEvents(e){let t=this.ns,n=e.trim().split(/\s+/).map(e=>`${e}${t}`).join(` `);this.$el.on(`focus${t}`,this.handleFocus).on(`blur${t}`,this.handleBlur).on(`compositionstart${t}`,this.handleCompositionStart).on(`compositionend${t}`,this.handleCompositionEnd).on(n,this.handleInput)}};function vt(e,t,n){let r=new _t(e,t,n);return{fx:z(r.syncDomFromAtom),cleanup:r.cleanup}}function yt(e,t,n,r){if(Fe(t)){let i=t;q.trackEffect(e,z(()=>{let t=i.value;k(()=>{try{n(t)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,t)})},{name:r}))}else k(()=>{try{n(t)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r,!0),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,t)})}function bt(e,t,n,r){let i=Object.keys(t),a=[],o={};for(let e=0;e<i.length;e++){let n=i[e],r=t[n];Fe(r)?a.push(n):o[n]=r}a.length>0?q.trackEffect(e,z(()=>{let i={...o};for(let e=0;e<a.length;e++){let n=a[e];i[n]=t[n].value}k(()=>{try{n(i)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,i)})},{name:r})):k(()=>{try{n(o)}catch(e){G.error(H.BINDING,W.BINDING.UPDATER_ERROR(r,!0),e);return}G.enabled&&G.domUpdated(H.BINDING,e,r,o)})}var xt=new Set([`href`,`src`,`action`,`formaction`,`xlink:href`,`data`,`poster`,`background`,`cite`,`longdesc`,`profile`,`usemap`,`classid`,`codebase`]),St=/^\s*(?:javascript|vbscript)\s*:/i,Ct=/(?:expression\s*\(|behavior\s*:|-moz-binding\s*:|(?:\\[0-9a-f]{1,6}\s*|[\s\x00-\x20/'"])*(?:j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t|d\s*a\s*t\s*a)\s*:(?!image\/))/i,wt=/url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i,Tt=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,Et=/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,Dt={colon:`:`,Tab:` `,NewLine:`
|
|
2
2
|
`},Ot=/&(colon|Tab|NewLine);/g,kt=/<\?[\s\S]*?\?>/g,At=/(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi,jt=/(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi,Mt=/data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi,Nt=/\bon\w+\s*=/gim,Pt=new RegExp(Ct.source,`gim`);function Ft(e){let t=String(e??``);t=t.replace(Tt,``),t=t.replace(Et,(e,t,n)=>String.fromCodePoint(t?parseInt(t,16):parseInt(n,10))),t=t.replace(Ot,(e,t)=>Dt[t]??``),t=t.replace(kt,``);let n;do n=t,t=t.replace(At,``);while(t!==n);return t=t.replace(jt,`data-unsafe-protocol:`),t=t.replace(Mt,`data-unsafe-protocol:`),t=t.replace(Nt,`data-unsafe-attr=`),t=t.replace(Pt,`data-unsafe-css:`),t}function It(e,t){return xt.has(e.toLowerCase())?St.test(t):!1}function Lt(e){return e.toLowerCase().includes(`url(`)?wt.test(e):!1}var Rt=new Map;function zt(e){let t=Rt.get(e);return t===void 0?(t=e.includes(`-`)?e.replace(/-./g,e=>e[1].toUpperCase()):e,Rt.set(e,t),t):t}var Bt=new WeakMap;function Vt(e){let t=Bt.get(e);return t||(t=R(()=>Ft(e.value)),Bt.set(e,t)),t}function Ht(e){return{el:e,trackCleanup:t=>q.trackCleanup(e,t)}}function Ut(e,t,n){let r=e.el;yt(r,t,e=>{let t=n?n(e):typeof e==`string`?e:String(e??``);r.textContent!==t&&(r.textContent=t)},`text`)}function Wt(e,t){let n=e.el;yt(n,A(t)?Vt(t):t,e=>{n.innerHTML!==e&&(q.cleanupDescendants(n),n.innerHTML=e)},`html`)}function Gt(e,t){let n=e.el;bt(n,t,e=>{for(let t in e){let r=e[t],i=t.trim().split(/\s+/).filter(Boolean);r?n.classList.add(...i):n.classList.remove(...i)}},`class`)}function Kt(e,t){let n=e.el,r=n.style;q.trackEffect(n,z(()=>{for(let e in t)if(V.call(t,e)){let n=t[e],i=zt(e),[a,o]=Array.isArray(n)?n:[n,``],s=A(a)?a.value:a;k(()=>{let e=o?String(s)+o:String(s);Lt(e)||r[i]!==e&&(r[i]=e)})}},{name:`css`}))}function qt(e,t){let n=e.el,r={};for(let e in t)if(V.call(t,e)){if(e.toLowerCase().startsWith(`on`)){console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_EVENT_HANDLER(e)}`);continue}r[e]=t[e]}bt(n,r,e=>{for(let t in e){let r=e[t],i=t.toLowerCase().startsWith(`aria-`);if(r==null||r===!1&&!i){n.removeAttribute(t);continue}let a=r===!0?i?`true`:t:String(r);if(It(t,a)){console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(t)}`);continue}n.getAttribute(t)!==a&&n.setAttribute(t,a)}},`attr`)}function Jt(e,t){let n=e.el,r={};for(let e in t)if(V.call(t,e)){if(e.toLowerCase().startsWith(`on`)){console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_EVENT_HANDLER(e)}`);continue}if(Ve.has(e)){console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROP(e)}`);continue}r[e]=t[e]}bt(e.el,r,e=>{for(let t in e){let r=e[t],i=t.toLowerCase();if(Be.has(i)&&typeof r==`string`&&It(t,r)){console.warn(`${H.BINDING} ${W.SECURITY.BLOCKED_PROTOCOL(t)}`);continue}n[t]!==r&&(n[t]=r)}},`prop`)}function Yt(e,t,n){let r=e.el,i=n?`hide`:`show`,a=r.style.display,o=a===`none`?``:a;yt(r,t,e=>{let t=n===!!e?`none`:o;r.style.display!==t&&(r.style.display=t)},i)}function Xt(e,t,n={}){let r=e.el.tagName.toLowerCase();if(!ze.has(r)){console.warn(`${H.BINDING} ${W.BINDING.INVALID_INPUT_ELEMENT(r)}`);return}let{fx:i,cleanup:a}=vt((0,c.default)(e.el),t,n);q.trackEffect(e.el,i),e.trackCleanup(a)}function Zt(e,t){let n=e.el,r=(0,c.default)(n),i=n.type===`radio`,a=()=>{let e=n.checked;if(t.peek()!==e&&(t.value=e,i&&e&&n.name)){let e=n.name.replace(/"/g,`\\"`);(n.form?(0,c.default)(n.form):(0,c.default)(document)).find(`input[type="radio"][name="${e}"]`).not(n).trigger(`change.atomRadioSync`)}};a[lt]=!0,r.on(`change change.atomRadioSync`,a),e.trackCleanup(()=>r.off(`change change.atomRadioSync`,a));let o=z(()=>{let e=!!t.value;k(()=>{n.checked!==e&&(n.checked=e,G.enabled&&G.domUpdated(H.BINDING,n,`checked`,e))})});q.trackEffect(n,o)}function Qt(e,t){let n=(0,c.default)(e.el);n.on(t),e.trackCleanup(()=>n.off(t))}function $t(e,t,n){let r=(0,c.default)(e.el);r.on(t,n),e.trackCleanup(()=>r.off(t,n))}function en(e){q.cleanupTree(e)}function Z(e,t){for(let n=0,r=e.length;n<r;n++){let r=e[n];r.nodeType===1?t(Ht(r),r):G.enabled&&G.log(H.BINDING,`Skipping non-Element node (nodeType=${r.nodeType})`)}return e}c.default.fn.atomText=function(e,t){return Z(this,n=>Ut(n,e,t))},c.default.fn.atomHtml=function(e){return Z(this,t=>Wt(t,e))},c.default.fn.atomClass=function(e,t){if(typeof e==`string`&&t===void 0)return console.warn(`${H.BINDING} ${W.BINDING.MISSING_CONDITION(`atomClass`)}`),this;let n=typeof e==`string`?{[e]:t}:e;return Z(this,e=>Gt(e,n))},c.default.fn.atomCss=function(e,t,n){if(typeof e==`string`&&t===void 0)return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE(`atomCss`)}`),this;let r=typeof e==`string`?{[e]:n?[t,n]:t}:e;return Z(this,e=>Kt(e,r))},c.default.fn.atomAttr=function(e,t){if(typeof e==`string`&&t===void 0)return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE(`atomAttr`)}`),this;let n=typeof e==`string`?{[e]:t}:e;return Z(this,e=>qt(e,n))},c.default.fn.atomProp=function(e,t){if(typeof e==`string`&&t===void 0)return console.warn(`${H.BINDING} ${W.BINDING.MISSING_SOURCE(`atomProp`)}`),this;let n=typeof e==`string`?{[e]:t}:e;return Z(this,e=>Jt(e,n))},c.default.fn.atomShow=function(e){return Z(this,t=>Yt(t,e,!1))},c.default.fn.atomHide=function(e){return Z(this,t=>Yt(t,e,!0))},c.default.fn.atomVal=function(e,t={}){return Z(this,n=>Xt(n,e,t))},c.default.fn.atomChecked=function(e){return Z(this,t=>Zt(t,e))},c.default.fn.atomOn=function(e,t){return Z(this,n=>$t(n,e,t))},c.default.fn.atomBind=function(e){let{text:t,html:n,class:r,css:i,attr:a,prop:o,show:s,hide:c,val:l,checked:u,on:d}=e,f=l===void 0?null:Array.isArray(l)?{atom:l[0],opts:l[1]}:{atom:l,opts:void 0};return Z(this,e=>{t!==void 0&&Ut(e,t),n!==void 0&&Wt(e,n),r!==void 0&&Gt(e,r),i!==void 0&&Kt(e,i),a!==void 0&&qt(e,a),o!==void 0&&Jt(e,o),s!==void 0&&Yt(e,s,!1),c!==void 0&&Yt(e,c,!0),f!==null&&Xt(e,f.atom,f.opts),u!==void 0&&Zt(e,u),d!==void 0&&Qt(e,d)})},c.default.fn.atomUnbind=function(){for(let e=0,t=this.length;e<t;e++){let t=this[e];t.nodeType===1&&en(t)}return this};var tn=new WeakMap,nn=0,rn=new nt(()=>new Map,e=>e.clear()),an=new nt(()=>new Set,e=>e.clear()),Q=new tt(100,1024);function on(e,t,n){t?.isConnected?e.insertBefore(t):e.appendTo(n)}function $(e){return e instanceof Element?(0,c.default)(e):e}var sn=class{constructor(e,t,n){this.$container=e,this.containerSelector=t,this.onRemove=n,this.oldKeys=[],this.oldItems=[],this.oldNodes=[],this.removingKeys=new Set,this.$emptyEl=null,this.keyToIndex=new Map,this.statesBuffer=new Uint8Array(256),this.indicesBuffer=new Int32Array(256)}scheduleRemoval(e,t){let n=()=>{this.fx?.isDisposed||(t.remove(),this.removingKeys.delete(e),G.log(H.LIST,`${this.containerSelector} removed item:`,e))};if(!this.onRemove){n();return}let r=this.onRemove(t);r instanceof Promise?r.then(n,n):n()}removeItem(e,t){for(let e=0;e<t.length;e++){let n=t[e];n instanceof Element&&n.removeAttribute(`data-atom-key`)}this.removingKeys.add(e),this.scheduleRemoval(e,t)}dispose(){this.removingKeys.clear(),this.oldKeys.length=0,this.oldItems.length=0,this.oldNodes.length=0,this.keyToIndex.clear(),this.$emptyEl?.remove(),this.$container.off(`.atomList`);let e=new Uint8Array,t=new Int32Array;this.statesBuffer=e,this.indicesBuffer=t}ensureBuffers(e){this.statesBuffer.length<e&&(this.statesBuffer=new Uint8Array(Math.max(e,this.statesBuffer.length*2))),this.indicesBuffer.length<e&&(this.indicesBuffer=new Int32Array(Math.max(e,this.indicesBuffer.length*2)))}};function cn(e,t,n,r){if(e.$emptyEl&&t>0&&(e.$emptyEl.remove(),e.$emptyEl=null),t!==0)return;let{oldKeys:i,oldNodes:a,onRemove:o}=e;if(o)for(let t=0,n=i.length;t<n;t++){let n=i[t],r=a[t];r&&e.removeItem(n,$(r))}else{for(let t=0,n=i.length;t<n;t++)e.removingKeys.delete(i[t]);n.empty()}r&&!e.$emptyEl&&(e.$emptyEl=(0,c.default)(typeof r==`string`?Ft(r):r).appendTo(n)),Q.release(e.oldKeys),Q.release(e.oldItems),Q.release(e.oldNodes),e.oldKeys=[],e.oldItems=[],e.oldNodes=[]}function ln(e,t,n,r,i,a){let{oldKeys:o,oldItems:s,oldNodes:c,removingKeys:l,keyToIndex:u}=e,d=o.length,f=0,p=d-1,m=n-1;for(;f<=p&&f<=m;){let e=t[f],n=r(e,f);if(o[f]!==n)break;let i=s[f];if(!(a?a(i,e):Ie(i,e)))break;u.set(n,f),f++}for(;p>=f&&m>=f;){let e=t[m],n=r(e,m);if(o[p]!==n)break;let i=s[p];if(!(a?a(i,e):Ie(i,e)))break;u.set(n,m),p--,m--}let h=rn.acquire();for(let e=f;e<=p;e++)h.set(o[e],e);let g=Q.acquire();g.length=n;let _=an.acquire();e.ensureBuffers(n);let v=Q.acquire();v.length=n;let y=Q.acquire();y.length=n;let b=e.statesBuffer,x=e.indicesBuffer,S=Q.acquire(),C=Q.acquire(),w=Q.acquire();for(let e=0;e<f;e++)g[e]=o[e],v[e]=t[e],y[e]=c[e],b[e]=3,x[e]=e;for(let e=d-1,r=n-1;r>m;r--,e--)g[r]=o[e],v[r]=t[r],y[r]=c[e],b[r]=3,x[r]=e;for(let n=f;n<=m;n++){let o=t[n],d=r(o,n);if(g[n]=d,v[n]=o,u.set(d,n),_.has(d)){G.warn(H.LIST,W.LIST.DUPLICATE_KEY(d,n,e.containerSelector)),x[n]=-1;continue}_.add(d);let f=h.get(d);if(f===void 0){S.push(d),C.push(o),w.push(n),x[n]=-1,b[n]=1;continue}let p=s[f];y[n]=c[f];let m=a?a(p,o):Ie(p,o);!i&&p!==o&&!m?(S.push(d),C.push(o),w.push(n),b[n]=2):b[n]=0,x[n]=l.has(d)?-1:f}return rn.release(h),{newKeys:g,newKeySet:_,newItems:v,newNodes:y,newStates:b,newIndices:x,trKeys:S,trItems:C,trIdxs:w,startIndex:f,oldEndIndex:p,newEndIndex:m}}function un(e,t,n){let{trKeys:r,trItems:i,trIdxs:a,newNodes:o,newStates:s}=e,l=r.length,u=t.render,d=Array(l),f=[],p=0;for(let e=0;e<l;e++){let t=u(i[e],a[e]);d[e]=t,typeof t==`string`&&(f.push(t),p++)}let m=null,h=f.length;if(h>0)if(h===1)m=[Ft(f[0])];else{let e=`<template data-atom-sep="${(nn++).toString(36)}"></template>`;m=Ft(f.join(e)).split(e)}if(n&&m&&p===l&&!t.bind&&!t.onAdd&&!t.onRemove&&!t.events)return m;let g=0;for(let e=0;e<l;e++){let t=d[e],n=typeof t==`string`?(0,c.default)(m[g++]):(0,c.default)(t),i=a[e],l=s[i],u=r[e],f=String(u);for(let e=0,t=n.length;e<t;e++){let t=n[e];t instanceof Element&&t.setAttribute(`data-atom-key`,f)}if(l===2){let e=o[i];if(e){let t=$(e);for(let e=0,n=t.length;e<n;e++){let n=t[e];n&&q.cleanupTree(n)}t.replaceWith(n)}}o[i]=n.length===1?n[0]:n}return null}function dn(e,t){let{startIndex:n,oldEndIndex:r,newKeySet:i}=t,{oldKeys:a,oldNodes:o}=e;for(let t=n;t<=r;t++){let n=a[t];if(i.has(n))continue;let r=o[t];r&&e.removeItem(n,$(r))}}function fn(e,t,n,r,i,a){let{bind:o,update:s,onAdd:l}=i,{newKeys:u,newItems:d,newNodes:f,newStates:p,newIndices:m}=t,h=u.length,g=e.oldKeys.length===0;if(a!==null){n.innerHTML=a.join(``);let t=n.firstElementChild;for(let n=0;n<h&&t;n++){let r=u[n];t.setAttribute(`data-atom-key`,String(r)),f[n]=t,p[n]=0,e.removingKeys.delete(r),G.enabled&&G.domUpdated(H.LIST,(0,c.default)(t),`list.add`,d[n]),t=t.nextElementSibling}return}if(g){let e=document.createDocumentFragment();for(let t=0;t<h;t++){let n=f[t];if(n instanceof Element)e.appendChild(n);else for(let t=0;t<n.length;t++)e.appendChild(n[t])}n.appendChild(e)}else{let e=null,t=2147483647;for(let n=h-1;n>=0;n--){let i=m[n],a=f[n];i!==-1&&i<t?t=i:on($(a),e,r),e=a instanceof Element?a:a[0]??null}}for(let t=0;t<h;t++){let n=f[t],r=p[t];if(r!==3){let i=$(n),a=d[t];if(r===0?s?.(i,a,t):o?.(i,a,t),r===1){l?.(i);let n=u[t];e.removingKeys.delete(n),G.enabled&&G.domUpdated(H.LIST,i,`list.add`,d[t])}}}}c.default.fn.atomList=function(e,t){let{key:n,bind:r,update:i,onAdd:a,onRemove:o,empty:s,events:l,isEqual:u}=t,d=typeof n==`function`?n:(e,t)=>e[n],f={bind:r,update:i,onAdd:a,onRemove:o,events:l};for(let n=0,r=this.length;n<r;n++){let r=this[n],a=(0,c.default)(r);a.off(`.atomList`);let p=tn.get(r);p&&(p.fx.dispose(),p.ctx.dispose());let m=B(r),h=new sn(a,m,o),g=z(()=>{let n=e.value,o=n.length;k(()=>{if(cn(h,o,a,s),o===0)return;G.log(H.LIST,`${m} updating with ${o} items`);let e=ln(h,n,o,d,i,u),c=un(e,t,h.oldKeys.length===0);if(dn(h,e),fn(h,e,r,a,f,c),l){let{startIndex:t,oldEndIndex:n,newKeySet:r}=e;for(let e=t;e<=n;e++){let t=h.oldKeys[e];r.has(t)||h.keyToIndex.delete(t)}}Q.release(h.oldKeys),Q.release(h.oldItems),Q.release(h.oldNodes),h.oldKeys=e.newKeys,h.oldItems=e.newItems,h.oldNodes=e.newNodes,an.release(e.newKeySet),Q.release(e.trKeys),Q.release(e.trItems),Q.release(e.trIdxs)})});if(h.fx=g,l)for(let e in l){if(!V.call(l,e))continue;let t=l[e],n=e.indexOf(` `),r=n===-1?e:e.slice(0,n),i=(n===-1?null:e.slice(n+1).trim())||`> *`;a.on(`${r}.atomList`,i,function(e){let n=e.target.closest?.(`[data-atom-key]`);if(!n)return;let r=n.getAttribute(`data-atom-key`);if(r===null)return;let i=r;if(!h.keyToIndex.has(r)){let e=Number(r);!Number.isNaN(e)&&h.keyToIndex.has(e)&&(i=e)}let a=h.keyToIndex.get(i);a!==void 0&&t.call(n,h.oldItems[a],a,e)})}q.trackEffect(r,g),tn.set(r,{fx:g,ctx:h}),q.trackCleanup(r,()=>{h.dispose(),tn.delete(r)})}return this};var pn=Object.freeze({});c.default.fn.atomMount=function(e,t){let n=t??pn;for(let t=0,r=this.length;t<r;t++){let r=this[t];if(!r)continue;q.cleanupTree(r);let i=(0,c.default)(r),a;try{a=k(()=>e(i,n))}catch(t){G.error(H.MOUNT,W.MOUNT.ERROR(e.name),t);continue}typeof a==`function`&&q.setComponentCleanup(r,a)}return this},c.default.fn.atomUnmount=function(){for(let e=0,t=this.length;e<t;e++){let t=this[e];t&&en(t)}return this};function mn(e,t){try{return history.pushState(e,``,t),!0}catch(e){return G.warn(H.ROUTE,`PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.`,e),!1}}var hn=class{constructor(e){this.isDestroyed=!1,this.previousRoute=``,this.cleanups=[],this.templateCache=new Map,this.routeCleanups=[],this.lastRawQuery=``,this.cachedParams={},this.config={...e,mode:e.mode??U.mode,basePath:e.basePath??U.basePath,autoBindLinks:e.autoBindLinks??U.autoBindLinks,activeClass:e.activeClass??U.activeClass},this.isHistoryMode=this.config.mode===`history`,this.$target=(0,c.default)(this.config.target),this.normalizedBasePath=this.config.basePath?.replace(/\/$/,``)||``,this.activeClass=this.config.activeClass??U.activeClass,this.previousUrl=this.isHistoryMode?window.location.pathname+window.location.search:window.location.hash,this.currentRouteAtom=Te(this.getRouteName()),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=Te(this.getQueryParams()),this.queryParams=R(()=>this.queryParamsAtom.value),this.handleUrlChange=this.handleUrlChange.bind(this),this.destroy=this.destroy.bind(this),this.init()}init(){let e=this.isHistoryMode?`popstate`:`hashchange`;window.addEventListener(e,this.handleUrlChange),this.cleanups.push(()=>window.removeEventListener(e,this.handleUrlChange));let t=z(()=>{let e=this.currentRouteAtom.value;k(()=>{let e=this.routeCleanups;for(let t=0,n=e.length;t<n;t++)try{e[t]()}catch(e){G.warn(H.ROUTE,`Cleanup error during route transition:`,e)}e.length=0}),this.renderRoute(e)});this.cleanups.push(()=>t.dispose()),this.setupAutoBindLinks(),this.$target[0]&&q.trackCleanup(this.$target[0],this.destroy)}getRouteName(){let e=this.config.default;if(this.isHistoryMode){let t=window.location.pathname,n=0,r=this.normalizedBasePath;return r&&t.startsWith(r)&&(n=r.length),t.charCodeAt(n)===47&&n++,(n===0?t:t.substring(n))||e}let t=window.location.hash;if(t.length<=1)return e;let n=t.indexOf(`?`);return(n===-1?t.substring(1):t.substring(1,n))||e}getQueryParams(){let e=``;if(this.isHistoryMode)e=window.location.search.substring(1);else{let t=window.location.hash,n=t.indexOf(`?`);n!==-1&&(e=t.substring(n+1))}if(e===this.lastRawQuery)return this.cachedParams;let t={};e&&new URLSearchParams(e).forEach((e,n)=>{t[n]=e});let n=!1,r=this.cachedParams,i=Object.keys(r),a=Object.keys(t);if(i.length!==a.length)n=!0;else for(let e=0,i=a.length;e<i;e++){let i=a[e];if(r[i]!==t[i]){n=!0;break}}return n&&(this.cachedParams=t),this.lastRawQuery=e,e.includes(`%`),this.cachedParams}setUrl(e){if(this.isHistoryMode){let t=`${this.normalizedBasePath}/${e}`;mn(null,t),this.previousUrl=t}else{let t=`#${e}`;window.location.hash=t,this.previousUrl=t}}restoreUrl(){this.isHistoryMode?mn(null,this.previousUrl):window.location.hash=this.previousUrl}getCurrentUrl(){return this.isHistoryMode?window.location.pathname+window.location.search:window.location.hash}getRouteConfig(e){let{routes:t,notFound:n}=this.config,r=t[e];return!r&&n&&(r=t[n]),r||(G.warn(H.ROUTE,W.ROUTE.NOT_FOUND(e)),null)}renderTemplate(e){let t=this.templateCache.get(e);if(!t){let n=document.querySelector(e);if(!n||!(n instanceof HTMLTemplateElement))return G.warn(H.ROUTE,W.ROUTE.TEMPLATE_NOT_FOUND(e)),!1;t=n,this.templateCache.set(e,t)}let n=t.content.cloneNode(!0);return this.$target.append(n),!0}renderRoute(e){if(this.isDestroyed)return;let t=this.$target[0];if(!t){G.warn(H.ROUTE,W.ROUTE.TARGET_NOT_FOUND(this.config.target));return}let n=this.getRouteConfig(e);if(!n)return;let r=this.getQueryParams(),i=this.previousRoute,{beforeTransition:a,afterTransition:o}=this.config;a&&k(()=>a(i,e)),this.$target.empty();let s=r,{onEnter:c}=n;if(c){let e=k(()=>c(r,this));e!==void 0&&(s={...r,...e})}let l=e=>{this.routeCleanups.push(e)};n.render?n.render(t,e,s,l,this):n.template&&this.renderTemplate(n.template)&&n.onMount&&n.onMount(this.$target.children(),l,this),o&&k(()=>o(i,e)),this.previousRoute=e}handleUrlChange(){if(this.isDestroyed)return;let e=this.getCurrentUrl();if(e===this.previousUrl)return;let t=this.getRouteName(),n=this.currentRouteAtom.peek(),r=this.getQueryParams();if(n!==t){let e=this.config.routes[n];if(e?.onLeave&&k(()=>e.onLeave(this))===!1){this.restoreUrl();return}this.currentRouteAtom.value=t,this.queryParamsAtom.value=r}else this.queryParamsAtom.value=r;this.previousUrl=e}setupAutoBindLinks(){if(!this.config.autoBindLinks)return;let e=e=>{e.preventDefault();let t=e.currentTarget.dataset.route;t!=null&&this.navigate(t)};(0,c.default)(document).on(`click`,`[data-route]`,e),this.cleanups.push(()=>{(0,c.default)(document).off(`click`,`[data-route]`,e)});let t=this.activeClass,n=[],r=z(()=>{let e=this.currentRouteAtom.value;k(()=>{for(let e=0,r=n.length;e<r;e++){let r=n[e];r.classList.remove(t),r.removeAttribute(`aria-current`)}try{let r=e.replace(/"/g,`\\"`),i=document.querySelectorAll(`[data-route="${r}"]`),a=i.length,o=Array(a);for(let e=0;e<a;e++){let n=i[e];n.classList.add(t),n.setAttribute(`aria-current`,`page`),o[e]=n}n=o}catch{n=[]}})});this.cleanups.push(()=>r.dispose())}navigate(e){if(this.isDestroyed)return;let t=this.currentRouteAtom.peek(),n=this.config.routes[t];if(n?.onLeave&&n.onLeave(this)===!1)return;let r=e||this.config.default;if(!r){G.warn(H.ROUTE,`navigate() called with empty routeName and no default configured.`);return}this.setUrl(r),this.queryParamsAtom.value={},this.currentRouteAtom.value=r}destroy(){if(this.isDestroyed)return;this.isDestroyed=!0;let e=this.cleanups;this.cleanups=[];for(let t=0,n=e.length;t<n;t++)try{e[t]()}catch(e){G.warn(H.ROUTE,`Cleanup error during destroy:`,e)}this.templateCache.clear()}};function gn(e){return new hn(e)}c.default.extend({route:gn});var _n=class{constructor(e,t){this.abortController=null,this.isStaticUrl=typeof e==`string`,this.isStaticUrl?this.staticUrl=e:this.getUrl=e,typeof t.ajaxOptions==`function`?(this.ajaxOptionsFn=t.ajaxOptions,this.staticOptions={}):this.staticOptions={...t.ajaxOptions},t.method!==void 0&&(this.staticOptions.method=t.method),t.headers!==void 0&&(this.staticOptions.headers={...this.staticOptions.headers,...t.headers}),this.transformFn=t.transform,this.onErrorFn=t.onError,this.execute=this.execute.bind(this)}abort(){this.abortController?.abort()}async execute(){this.abortController?.abort(),this.abortController=new AbortController;let e=this.abortController.signal,t=this.ajaxOptionsFn?this.ajaxOptionsFn():{},n=c.default.extend(!0,{},this.staticOptions,t);n.success=void 0,n.error=void 0,n.complete=void 0,n.url=this.isStaticUrl?this.staticUrl:this.getUrl();let r=c.default.ajax(n);e.onabort=()=>r.abort(),e.aborted&&r.abort();let i;try{i=await r}catch(t){if(e.aborted){let e=Error(`AbortError`);throw e.name=`AbortError`,e}let n;if(t&&t.readyState!==void 0){let e=t;n=Error(`Network Error: ${e.statusText||`Unknown`} (${e.status})`),n.jqXHR=e}else n=t instanceof Error?t:Error(String(t??`Unknown network error`));let r=this.onErrorFn;if(r)try{r(n)}catch{}throw n}finally{e.onabort=null,this.abortController?.signal===e&&(this.abortController=null)}let a=this.transformFn;if(a)try{return a(i)}catch(e){let t=this.onErrorFn;if(t)try{t(e)}catch{}throw e}return i}};c.default.extend({atomFetch(e,t){let n=new _n(e,t),r=!(t.eager??!0),i=R(n.execute,{defaultValue:t.defaultValue,lazy:r});return Object.assign(i,{abort:()=>n.abort()})}}),(0,c.default)(()=>{mt(),st(document.body)});var vn=c.default;exports.atom=Te,exports.batch=Pe,exports.computed=R,exports.default=vn,exports.disableAutoCleanup=ct,exports.disablejQueryOverrides=ht,exports.effect=z,exports.enableAutoCleanup=st,exports.enablejQueryOverrides=mt,exports.isAtom=A,exports.isComputed=De,exports.isReactive=Fe,exports.nextTick=$e,exports.registry=q,exports.untracked=k;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|