@but212/atom-effect-jquery 0.22.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/atom-effect-jquery.min.js +3 -3
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -152
- package/dist/index.mjs +2337 -2038
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("jquery"),ft={IDLE:"idle",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"},k={DISPOSED:1,EXECUTING:8},de={DISPOSED:1,IS_COMPUTED:2,DIRTY:8,IDLE:16,PENDING:32,RESOLVED:64,REJECTED:128,RECOMPUTING:256,HAS_ERROR:512},F={DISPOSED:1,SYNC:8,NOTIFICATION_SCHEDULED:16},X={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},Me={WARN_INFINITE_LOOP:!0},ee={MAX_ASYNC_RETRIES:3,MAX_PROMISE_ID:Number.MAX_SAFE_INTEGER-1},bt=1073741823,Fe=typeof process<"u"&&process.env&&!1||!1,Be=Object.freeze([]);class et extends Error{constructor(t,e=null,n=!0){super(t),this.cause=e,this.recoverable=n,this.name="AtomError"}}class V extends et{constructor(t,e=null){super(t,e,!0),this.name="ComputedError"}}class Z extends et{constructor(t,e=null){super(t,e,!1),this.name="EffectError"}}class wt extends et{constructor(t,e=null){super(t,e,!1),this.name="SchedulerError"}}const He=Symbol("AtomEffect.DebugName"),Ge=Symbol("AtomEffect.Type"),kt=Symbol("AtomEffect.NoDefaultValue"),St={enabled:Fe,warnInfiniteLoop:Me.WARN_INFINITE_LOOP,warn(s,t){},checkCircular(s,t){if(s===t)throw new V("Direct circular dependency detected")},attachDebugInfo(s,t,e){},getDebugName:s=>s?.[He],getDebugType:s=>s?.[Ge]};let je=1;const ze=()=>je++;function _e(s,t,e){if(typeof t=="function"){const i=t;if(e.some(o=>o&&o.fn===i))return;e.push(new Bt(i,void 0));return}if("addDependency"in t){t.addDependency(s);return}const n=t;e.some(i=>i&&i.sub===n)||e.push(new Bt(void 0,n))}function se(s,t,e){const n=new Map;t.forEach(i=>{i?.unsub&&n.set(i.node,i.unsub)}),s.forEach(i=>{if(!i)return;const o=i.node,r=n.get(o);r!==void 0?(i.unsub=r,n.delete(o)):(St.checkCircular(o,e),i.unsub=o.subscribe(e))}),n.forEach(i=>i())}class Ft{constructor(t,e,n=void 0){this.node=t,this.version=e,this.unsub=n}}class Bt{constructor(t,e){this.fn=t,this.sub=e}}const S={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:(s,t)=>`Maximum flush iterations (${s}) 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."};function tt(s,t,e){if(s instanceof et)return s;const n=s instanceof Error,i=n?s.message:String(s),o=n?s:void 0,r=`${n?s.constructor.name:"Unexpected error"} (${e}): ${i}`;return new t(r,o)}class Ee{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=-1,this.id=ze()&bt}}class pe extends Ee{subscribe(t){const e=typeof t=="function";if(!e&&(!t||typeof t.execute!="function"))throw tt(new TypeError("Invalid subscriber"),et,S.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);if(this._subscribers.some(i=>i?e?i.fn===t:i.sub===t:!1))return()=>{};const n=new Bt(e?t:void 0,e?void 0:t);return this._subscribers.push(n),()=>this._unsubscribe(n)}_unsubscribe(t){const e=this._subscribers,n=e.indexOf(t);if(n===-1)return;const i=e.pop();n<e.length&&i&&(e[n]=i)}subscriberCount(){return this._subscribers.length}_notifySubscribers(t,e){this._subscribers.length!==0&&this._subscribers.slice(0).forEach(n=>{if(n)try{n.fn?n.fn(t,e):n.sub&&n.sub.execute()}catch(i){this._handleNotifyError(i)}})}_handleNotifyError(t){console.error(tt(t,et,S.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}}let Pt=0;const zt=()=>(Pt=Pt+1&bt||1,Pt),Ht=s=>s+1&bt;let Vt=0,mt=!1,ge=0;const me=()=>ge;function ne(){return mt?!1:(mt=!0,ge=zt(),Vt=0,!0)}const ie=()=>{mt=!1},Ve=()=>mt?++Vt:0;class qe{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=X.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get phase(){return this._isProcessing||this._isFlushingSync?2:this._isBatching?1:0}get queueSize(){return this._size}get isBatching(){return this._isBatching}schedule(t){if(t._nextEpoch!==this._epoch){if(t._nextEpoch=this._epoch,this._isBatching||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=t;return}this._queueBuffer[this._bufferIndex][this._size++]=t,this._isProcessing||this._flush()}}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0)return;const t=ne();this._drainQueue(),t&&ie()}finally{this._isProcessing=!1,this._size>0&&!this._isBatching&&this._flush()}}_flushSync(){this._isFlushingSync=!0;const t=ne();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=!1,t&&ie()}}_mergeBatchQueue(){if(this._batchQueueSize===0)return;const t=++this._epoch,e=this._batchQueue,n=this._queueBuffer[this._bufferIndex];let i=this._size;e.slice(0,this._batchQueueSize).forEach(o=>{o._nextEpoch!==t&&(o._nextEpoch=t,n[i++]=o)}),this._size=i,this._batchQueueSize=0,e.length>X.BATCH_QUEUE_SHRINK_THRESHOLD&&(e.length=0)}_drainQueue(){let t=0;for(;this._size>0;){if(++t>this._maxFlushIterations){this._handleFlushOverflow();return}this._processQueue(),this._mergeBatchQueue()}}_processQueue(){const t=this._bufferIndex,e=this._queueBuffer[t],n=this._size;this._bufferIndex=t^1,this._size=0,this._epoch++;for(let i=0;i<n;i++)try{e[i]()}catch(o){console.error(new wt("Error occurred during scheduler execution",o))}e.length=0}_handleFlushOverflow(){const t=this._size+this._batchQueueSize;if(console.error(new wt(S.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,t))),this._size=0,this._queueBuffer[this._bufferIndex].length=0,this._batchQueueSize=0,this.onOverflow)try{this.onOverflow(t)}catch{}}startBatch(){this._batchDepth++,this._isBatching=!0}endBatch(){this._batchDepth!==0&&--this._batchDepth===0&&(this._flushSync(),this._isBatching=!1)}setMaxFlushIterations(t){if(t<X.MIN_FLUSH_ITERATIONS)throw new wt(`Max flush iterations must be at least ${X.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=t}}const ot=new qe,qt=Symbol.for("atom-effect/atom"),Ie=Symbol.for("atom-effect/computed"),Xe=Symbol.for("atom-effect/effect"),x={current:null,run(s,t){const e=this.current;this.current=s;try{return t()}finally{this.current=e}}};function $(s){const t=x.current;if(t===null)return s();x.current=null;try{return s()}finally{x.current=t}}var oe;class Qe extends pe{constructor(t,e){super(),this._pendingOldValue=void 0,this._notifyTask=()=>this._flushNotifications(),this._subscribers=[],this[oe]=!0,this._value=t,e&&(this.flags|=F.SYNC),St.attachDebugInfo(this,"atom",this.id)}get value(){const t=x.current;return t&&_e(this,t,this._subscribers),this._value}set value(t){const e=this._value;if(Object.is(e,t))return;this._value=t,this.version=Ht(this.version);const n=this.flags;if(!(this._subscribers.length===0||n&F.NOTIFICATION_SCHEDULED)){if(this._pendingOldValue=e,this.flags=n|F.NOTIFICATION_SCHEDULED,n&F.SYNC&&!ot.isBatching){this._flushNotifications();return}ot.schedule(this._notifyTask)}}_flushNotifications(){const t=this.flags;if(!(t&F.NOTIFICATION_SCHEDULED)||t&F.DISPOSED)return;const e=this._pendingOldValue;this._pendingOldValue=void 0,this.flags&=-17,this._notifySubscribers(this._value,e)}peek(){return this._value}dispose(){this.flags&F.DISPOSED||(this._subscribers.length=0,this.flags|=F.DISPOSED,this._value=void 0,this._pendingOldValue=void 0)}[(oe=qt,Symbol.dispose)](){this.dispose()}}function It(s,t={}){return new Qe(s,t.sync??!1)}class Ye{constructor(t=50,e=256,n=!1){this.limit=t,this.capacity=e,this.pool=[],this.stats=null,this.stats=n?{acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}}:null}acquire(){return this.stats&&this.stats.acquired++,this.pool.pop()??[]}release(t,e){if(!(e&&t===e)){if(t.length>this.capacity){this.stats&&this.stats.rejected.tooLarge++;return}if(this.pool.length>=this.limit){this.stats&&this.stats.rejected.poolFull++;return}if(Object.isFrozen(t)){this.stats&&this.stats.rejected.frozen++;return}t.length=0,this.pool.push(t),this.stats&&this.stats.released++}}getStats(){if(!this.stats)return null;const{acquired:t,released:e,rejected:n}=this.stats,i=t-e-(n.frozen+n.tooLarge+n.poolFull);return{acquired:t,released:e,rejected:{...n},leaked:i,poolSize:this.pool.length}}reset(){this.pool.length=0,this.stats&&(this.stats={acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}})}}const A=Object.freeze([]),H=new Ye;function Tt(s){return s!==null&&typeof s=="object"&&qt in s}function ye(s){return s!==null&&typeof s=="object"&&Ie in s}function Ce(s){return s!==null&&typeof s=="object"&&typeof s.then=="function"}var re,ce;const{IDLE:dt,DIRTY:K,PENDING:pt,RESOLVED:q,REJECTED:nt,HAS_ERROR:_t,RECOMPUTING:st,DISPOSED:xt,IS_COMPUTED:Ke}=de;function We(s){return s&q?ft.RESOLVED:s&pt?ft.PENDING:s&nt?ft.REJECTED:ft.IDLE}class Je extends pe{constructor(t,e={}){if(typeof t!="function")throw new V(S.COMPUTED_MUST_BE_FUNCTION);super(),this[ce]=!0,this[re]=!0,this._error=null,this._promiseId=0,this._subscribers=[],this._links=A,this._asyncStartAggregateVersion=0,this._asyncRetryCount=0,this._lastDriftEpoch=-1,this._trackEpoch=-1,this._trackLinks=A,this._trackCount=0,this._value=void 0,this.flags=Ke|K|dt,this._equal=e.equal??Object.is,this._fn=t,this._defaultValue="defaultValue"in e?e.defaultValue:kt,this._onError=e.onError??null;const n=e.maxAsyncRetries;if(this._maxAsyncRetries=(n??ee.MAX_ASYNC_RETRIES)&bt,St.attachDebugInfo(this,"computed",this.id),e.lazy===!1)try{this._recompute()}catch{}}_track(){const t=x.current;t&&_e(this,t,this._subscribers)}get value(){this._track();const t=this.flags;if((t&(q|K|dt))===q)return this._value;if(t&xt)throw new V(S.COMPUTED_DISPOSED);if(t&st){if(this._defaultValue!==kt)return this._defaultValue;throw new V(S.COMPUTED_CIRCULAR_DEPENDENCY)}if(t&(K|dt)&&(this._recompute(),this.flags&q))return this._value;const e=this._defaultValue,n=e!==kt;if(this.flags&pt){if(n)return e;throw new V(S.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if(this.flags&nt){if(n)return e;throw this._error}return this._value}peek(){return this._value}get state(){return this._track(),We(this.flags)}get hasError(){return this._track(),this.flags&(nt|_t)?!0:this._links.some(t=>t?.node?.flags&_t)}get isValid(){return!this.hasError}get errors(){if(this._track(),!this.hasError)return Be;const t=[];return this._error&&t.push(this._error),this._links.forEach(e=>{const n=e.node;n.flags&_t&&n.errors.forEach(i=>{i&&!t.includes(i)&&t.push(i)})}),Object.freeze(t)}get lastError(){return this._track(),this._error}get isPending(){return this._track(),(this.flags&pt)!==0}get isResolved(){return this._track(),(this.flags&q)!==0}invalidate(){this._markDirty()}dispose(){if(this.flags&xt)return;const t=this._links;t!==A&&(t.forEach(e=>e.unsub?.()),H.release(t),this._links=A),this._subscribers.length=0,this.flags=xt|K|dt,this._error=null,this._value=void 0}[(ce=qt,re=Ie,Symbol.dispose)](){this.dispose()}addDependency(t){if(t._lastSeenEpoch!==this._trackEpoch){if(t._lastSeenEpoch=this._trackEpoch,this._trackCount<this._trackLinks.length){const e=this._trackLinks[this._trackCount];e.node=t,e.version=t.version}else this._trackLinks.push(new Ft(t,t.version));this._trackCount++}}_recompute(){if(this.flags&st)return;this.flags|=st;const t=this._links;this._trackEpoch=zt(),this._trackLinks=H.acquire(),this._trackCount=0;let e=!1;try{const n=x.run(this,this._fn);this._trackLinks.length=this._trackCount,se(this._trackLinks,t,this),this._links=this._trackLinks,e=!0,Ce(n)?this._handleAsyncComputation(n):this._finalizeResolution(n)}catch(n){if(!e)try{this._trackLinks.length=this._trackCount,se(this._trackLinks,t,this),this._links=this._trackLinks,e=!0}catch{}this._handleError(n,S.COMPUTED_COMPUTATION_FAILED,!0)}finally{e&&t!==A?H.release(t):e||H.release(this._trackLinks),this._trackEpoch=-1,this._trackLinks=A,this._trackCount=0,this.flags&=~st}}_handleAsyncComputation(t){this.flags=(this.flags|pt)&-217,this._notifySubscribers(void 0,void 0),this._asyncStartAggregateVersion=this._captureVersionSnapshot(),this._asyncRetryCount=0,this._promiseId=(this._promiseId+1)%ee.MAX_PROMISE_ID;const e=this._promiseId;t.then(n=>{if(e===this._promiseId){if(this._captureVersionSnapshot()!==this._asyncStartAggregateVersion){const i=me();return this._lastDriftEpoch!==i&&(this._lastDriftEpoch=i,this._asyncRetryCount=0),this._asyncRetryCount++<this._maxAsyncRetries?this._markDirty():this._handleError(new V(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),S.COMPUTED_ASYNC_COMPUTATION_FAILED)}this._finalizeResolution(n),this._notifySubscribers(n,void 0)}},n=>e===this._promiseId&&this._handleError(n,S.COMPUTED_ASYNC_COMPUTATION_FAILED))}_captureVersionSnapshot(){let t=0;const e=this._links;for(let n=0,i=e.length;n<i;n++)t=(t<<5)-t+e[n].node.version|0;return t}_handleError(t,e,n=!1){const i=tt(t,V,e);if(!n&&!(this.flags&nt)&&(this.version=Ht(this.version)),this._error=i,this.flags=this.flags&-121|nt|_t,this._onError)try{this._onError(i)}catch(o){console.error(S.CALLBACK_ERROR_IN_ERROR_HANDLER,o)}if(n)throw i;this._notifySubscribers(void 0,void 0)}_finalizeResolution(t){(!(this.flags&q)||!this._equal(this._value,t))&&(this.version=Ht(this.version)),this._value=t,this._error=null,this.flags=(this.flags|q)&-697}execute(){this._markDirty()}_markDirty(){this.flags&(st|K)||(this.flags|=K,this._notifySubscribers(void 0,void 0))}}function rt(s,t={}){return new Je(s,t)}var ae;class Ze extends Ee{constructor(t,e={}){super(),this[ae]=!0,this._cleanup=null,this._links=A,this._nextLinks=null,this._prevLinks=A,this._currentEpoch=-1,this._lastFlushEpoch=-1,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._fn=t,this._onError=e.onError??null,this._sync=e.sync??!1,this._maxExecutions=e.maxExecutionsPerSecond??X.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=e.maxExecutionsPerFlush??X.MAX_EXECUTIONS_PER_EFFECT,this._sync?(this._executeTask=void 0,this._notifyCallback=()=>this.execute()):(this._executeTask=()=>this.execute(),this._notifyCallback=()=>ot.schedule(this._executeTask)),St.attachDebugInfo(this,"effect",this.id)}run(){if(this.flags&k.DISPOSED)throw new Z(S.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.flags&k.DISPOSED||(this.flags|=k.DISPOSED,this._execCleanup(),this._unsubLinks(this._links),this._links!==A&&H.release(this._links),this._links=A,this._prevLinks=A)}[(ae=Xe,Symbol.dispose)](){this.dispose()}addDependency(t){if(!(this.flags&k.EXECUTING))return;const e=this._currentEpoch;if(t._lastSeenEpoch===e)return;t._lastSeenEpoch=e;const n=this._nextLinks,i=this._prevLinks,o=i.findIndex(r=>r&&r.node===t&&r.unsub);if(o!==-1){const r=i[o];r.version=t.version,n.push(r),i[o]=null;return}try{const r=t.subscribe(this._notifyCallback);n.push(new Ft(t,t.version,r))}catch(r){const c=tt(r,Z,S.EFFECT_EXECUTION_FAILED);if(console.error(c),this._onError)try{this._onError(c)}catch{}n.push(new Ft(t,t.version,void 0))}}execute(t=!1){if(this.flags&(k.DISPOSED|k.EXECUTING)||!t&&this._links.length>0&&!this._isDirty())return;this._checkInfiniteLoops(),this.flags|=k.EXECUTING,this._execCleanup(),this._prevLinks=this._links;const e=H.acquire();this._nextLinks=e,this._currentEpoch=zt();let n=!1;try{const i=x.run(this,this._fn);this._links=e,n=!0,Ce(i)?this._handleAsyncResult(i):this._cleanup=typeof i=="function"?i:null}catch(i){this._links=e,n=!0,this._handleExecutionError(i),this._cleanup=null}finally{this._finalizeDependencies(n,this._prevLinks,e),this.flags&=-9}}_handleAsyncResult(t){const e=++this._execId;t.then(n=>{if(e!==this._execId||this.flags&k.DISPOSED){if(typeof n=="function")try{n()}catch(i){this._handleExecutionError(i,S.EFFECT_CLEANUP_FAILED)}return}typeof n=="function"&&(this._cleanup=n)},n=>e===this._execId&&this._handleExecutionError(n))}_finalizeDependencies(t,e,n){this._nextLinks=null,this._prevLinks=A,t?(e.forEach(i=>i?.unsub?.()),e!==A&&H.release(e)):(this._unsubLinks(n),H.release(n))}_unsubLinks(t){t.forEach(e=>e?.unsub?.())}_isDirty(){const t=this._links,e=x.current;x.current=null;try{return t.some(n=>{const i=n.node;if(i.flags&de.IS_COMPUTED)try{i.value}catch{return!0}return i.version!==n.version})}finally{x.current=e}}_execCleanup(){if(this._cleanup){try{this._cleanup()}catch(t){this._handleExecutionError(t,S.EFFECT_CLEANUP_FAILED)}this._cleanup=null}}_checkInfiniteLoops(){const t=me();this._lastFlushEpoch!==t&&(this._lastFlushEpoch=t,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError("per-effect"),Ve()>X.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError("global"),this._executionCount++}get isDisposed(){return(this.flags&k.DISPOSED)!==0}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&k.EXECUTING)!==0}_throwInfiniteLoopError(t){const e=new Z(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Vt}`);throw this.dispose(),console.error(e),e}_handleExecutionError(t,e=S.EFFECT_EXECUTION_FAILED){const n=tt(t,Z,e);if(console.error(n),this._onError)try{this._onError(n)}catch(i){console.error(tt(i,Z,S.CALLBACK_ERROR_IN_ERROR_HANDLER))}}}function G(s,t={}){if(typeof s!="function")throw new Z(S.EFFECT_MUST_BE_FUNCTION);const e=new Ze(s,t);return e.execute(),e}function Xt(s){if(typeof s!="function")throw new TypeError("Batch callback must be a function");ot.startBatch();try{return s()}finally{ot.endBatch()}}const g={ROUTE:"[atom-route]",BINDING:"[atom-binding]",LIST:"[atom-list]",MOUNT:"[atom-mount]"},Et=Object.freeze({mode:"hash",basePath:"",autoBindLinks:!1,activeClass:"active"}),ts={EVENT:"input"},es=new Set(["input","select","textarea"]),ss=new Set(["innerHTML","outerHTML","srcdoc","__proto__","constructor","prototype"]),T={ROUTE_NOT_FOUND:s=>`Route "${s}" not found and no notFound route configured`,TEMPLATE_NOT_FOUND:s=>`Template "${s}" not found`,TARGET_NOT_FOUND:s=>`Target element "${s}" not found`,MALFORMED_URI:s=>`Malformed URI component: ${s}`,UNSAFE_CONTENT:()=>"Unsafe content neutralized during sanitization.",BLOCKED_DANGEROUS_CSS_VALUE:s=>`Blocked dangerous value in CSS style property "${s}".`,BLOCKED_EVENT_HANDLER:s=>`Blocked setting dangerous event handler attribute "${s}".`,BLOCKED_PROTOCOL:s=>`Blocked dangerous protocol in "${s}" attribute.`,BLOCKED_DANGEROUS_PROP:s=>`Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`,INVALID_INPUT_ELEMENT:s=>`Val binding used on non-input element <${s}>.`,MISSING_SOURCE:s=>`[${s}] source is required when prop/name is a string.`,MISSING_CONDITION:s=>`[${s}] condition is required when className is a string.`,DUPLICATE_KEY:(s,t)=>`Duplicate key "${s}" at index ${t}.`,UPDATER_ERROR:s=>`Updater threw in binding "${s}"`,EFFECT_DISPOSE_ERROR:()=>"Effect dispose error",BINDING_CLEANUP_ERROR:()=>"Binding cleanup error",PARSE_ERROR:()=>"parse() threw during DOM→Atom sync",MOUNT_ERROR:()=>"Mount error",MOUNT_CLEANUP_ERROR:()=>"Cleanup error"};function Qt(s){return Tt(s)}function Yt(s){const t=s.tagName.toLowerCase();if(s.id)return`${t}#${s.id}`;const e=s.classList,n=e.length;if(n===0)return t;let i=t;for(let o=0;o<n;o++)i+=`.${e[o]}`;return i}const ns=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset","background","cite","longdesc","profile","usemap","classid","codebase"]),ct=Object.prototype.hasOwnProperty,is=/^\s*(?:javascript|vbscript)\s*:/i,os=/(?: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,rs=/url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i,cs=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,as=/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,ls={colon:":",Tab:" ",NewLine:`
|
|
2
|
-
`},hs=/&(colon|Tab|NewLine);/g,us=/<\?[\s\S]*?\?>/g,fs=/(<(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,ds=/(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,_s=/data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi,Es=/\bon\w+\s*=/gim,ps=new RegExp(os.source,"gim");function Gt(s){let t=String(s??"");t=t.replace(cs,""),t=t.replace(as,(n,i,o)=>String.fromCodePoint(i?parseInt(i,16):parseInt(o,10))),t=t.replace(hs,(n,i)=>ls[i]??""),t=t.replace(us,"");let e;do e=t,t=t.replace(fs,"");while(t!==e);return t=t.replace(ds,"data-unsafe-protocol:"),t=t.replace(_s,"data-unsafe-protocol:"),t=t.replace(Es,"data-unsafe-attr="),t=t.replace(ps,"data-unsafe-css:"),t}function gs(s,t){return ns.has(s.toLowerCase())?is.test(t):!1}function ms(s){return s.toLowerCase().includes("url(")?rs.test(s):!1}function Is(s,t){if(s===t)return!0;if(s===null||t===null||typeof s!="object"||typeof t!="object")return!1;const e=Object.keys(s),n=Object.keys(t);if(e.length!==n.length)return!1;const i=s,o=t;for(let r=0;r<e.length;r++){const c=e[r];if(!ct.call(o,c)||i[c]!==o[c])return!1}return!0}function ys(s){const t=s.length;if(t===0)return new Int32Array(0);const e=new Int32Array(t).fill(-1),n=new Int32Array(t);let i=0;for(let r=0;r<t;r++){const c=s[r];if(c===void 0||c===-1)continue;const E=i>0?n[i-1]:void 0;if(i===0||E!==void 0&&(s[E]??-1)<c){e[r]=E??-1,n[i++]=r;continue}let d=0,m=i-1;for(;d<m;){const p=d+m>>>1,O=n[p];O!==void 0&&(s[O]??-1)<c?d=p+1:m=p}const N=n[d];N!==void 0&&c<(s[N]??Number.MAX_SAFE_INTEGER)&&(d>0&&(e[r]=n[d-1]??-1),n[d]=r)}const o=new Int32Array(i);if(i>0){let r=n[i-1];for(let c=i-1;c>=0&&r!==void 0&&r!==-1;c--)o[c]=r,r=e[r]}return o}const Cs={},be=600,bs=`${be/1e3}s`;function Ss(){if(typeof window<"u"){const s=window.__ATOM_DEBUG__;if(typeof s=="boolean")return s}return Cs?.VITE_ATOM_DEBUG==="true"}let W=Ss();const f={get enabled(){return W},set enabled(s){W=s},log(s,...t){W&&console.log(`${g.MOUNT} ${s}:`,...t)},atomChanged(s,t,e){W&&console.log(`${g.MOUNT} Atom "${s??"anonymous"}" changed:`,t,"→",e)},domUpdated(s,t,e){if(!W)return;const n=s instanceof Element?s:s[0];n instanceof HTMLElement&&(console.log(`${g.MOUNT} DOM updated: ${Yt(n)}.${t} =`,e),Ns(n))},cleanup(s){W&&console.log(`${g.MOUNT} Cleanup: ${s}`)},warn(s,t,...e){console.warn(`${s} ${t}`,...e)},error(s,t,e){console.error(`${s} ${t}`,e)}},jt="atom-debug-highlight",Ts="data-atom-debug";let le;function Rs(){if(le?.deref()?.isConnected)return;const s=document.createElement("style");s.setAttribute(Ts,""),s.textContent=`.${jt}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline ${bs} ease-out}`,document.head.appendChild(s),le=new WeakRef(s)}const $t=new WeakMap,Mt=new WeakMap;function Ns(s){if(!s.isConnected)return;Rs();const t=Mt.get(s);t!==void 0&&cancelAnimationFrame(t);const e=$t.get(s);e!==void 0&&clearTimeout(e);const n=requestAnimationFrame(()=>{Mt.delete(s),s.classList.add(jt),$t.set(s,setTimeout(()=>{s.classList.remove(jt),$t.delete(s)},be))});Mt.set(s,n)}function Se(s,t){return It(s,t)}Object.defineProperty(Se,"debug",{enumerable:!0,configurable:!0,get(){return f.enabled},set(s){f.enabled=s}});function Te(){return new Promise(s=>setTimeout(s,0))}const Os={atom:Se,computed:rt,effect:G,batch:Xt,untracked:$,isAtom:Tt,isComputed:ye,isReactive:Qt,nextTick:Te};l.extend(Os);const J="_aes-bound";class vs{constructor(){this.records=new WeakMap,this.preservedNodes=new WeakSet,this.ignoredNodes=new WeakSet}keep(t){this.preservedNodes.add(t)}isKept(t){return this.preservedNodes.has(t)}markIgnored(t){this.ignoredNodes.add(t)}isIgnored(t){return this.ignoredNodes.has(t)}getOrCreateRecord(t){let e=this.records.get(t);return e||(e={},this.records.set(t,e),t.classList.add(J)),e}trackEffect(t,e){const n=this.getOrCreateRecord(t);n.effects??=[],n.effects.push(e)}trackCleanup(t,e){const n=this.getOrCreateRecord(t);n.cleanups??=[],n.cleanups.push(e)}setComponentCleanup(t,e){const n=this.getOrCreateRecord(t);n.componentCleanup=e}hasBind(t){return this.records.has(t)}cleanup(t){const e=this.records.get(t);if(!e){t.isConnected&&t.classList.remove(J),this.preservedNodes.delete(t),this.ignoredNodes.delete(t);return}if(this.records.delete(t),this.preservedNodes.delete(t),this.ignoredNodes.delete(t),t.isConnected&&t.classList.remove(J),f.enabled&&f.cleanup(Yt(t)),e.componentCleanup)try{e.componentCleanup()}catch(n){f.error(g.MOUNT,T.MOUNT_CLEANUP_ERROR(),n)}if(e.effects){const n=e.effects;for(let i=0,o=n.length;i<o;i++)try{n[i].dispose()}catch(r){f.error(g.BINDING,T.EFFECT_DISPOSE_ERROR(),r)}}if(e.cleanups){const n=e.cleanups;for(let i=0,o=n.length;i<o;i++)try{n[i]()}catch(r){f.error(g.BINDING,T.BINDING_CLEANUP_ERROR(),r)}}}cleanupDescendants(t){const e=t.getElementsByClassName(J);for(let n=e.length-1;n>=0;n--){const i=e[n];i&&(this.records.has(i)?this.cleanup(i):(i.classList.remove(J),f.enabled&&f.warn(g.BINDING,`${J} class found on unregistered element:`,i)))}}cleanupTree(t){this.cleanupDescendants(t),this.cleanup(t)}}const y=new vs;let it=null,gt=null;function Re(s){if(it!==null){gt!==s&&f.warn(g.BINDING,"enableAutoCleanup() called with a different root while already active. Observation was NOT switched — call disableAutoCleanup() first.",{current:gt,requested:s});return}gt=s,it=new MutationObserver(t=>{for(let e=0,n=t.length;e<n;e++){const i=t[e].removedNodes;for(let o=0,r=i.length;o<r;o++){const c=i[o];c.nodeType===1&&(c.isConnected||y.isKept(c)||y.isIgnored(c)||y.cleanupTree(c))}}}),it.observe(s,{childList:!0,subtree:!0})}function Ds(){it?.disconnect(),it=null,gt=null}function Q(s,t,e,n){if(Qt(t)){const i=t;y.trackEffect(s,G(()=>{const o=i.value;$(()=>{try{e(o)}catch(r){f.error(g.BINDING,`${T.UPDATER_ERROR(n)}:`,r);return}f.enabled&&f.domUpdated(s,n,o)})}))}else{try{e(t)}catch(i){f.error(g.BINDING,`${T.UPDATER_ERROR(n)} (static):`,i);return}f.enabled&&f.domUpdated(s,n,t)}}const B=Symbol("atom-effect-internal"),yt=new WeakMap;let P=null;const Ne=s=>{if(s[B])return s;let t=yt.get(s);return t||(t=function(...e){return Xt(()=>s.apply(this,e))},t[B]=!0,yt.set(s,t)),t};function As(s){const t={};return Object.keys(s).forEach(e=>{const n=s[e];n&&(t[e]=Ne(n))}),t}function Ls(s){const t={};return Object.keys(s).forEach(e=>{const n=s[e];t[e]=n?yt.get(n)??n:void 0}),t}function Oe(){if(P!==null)return;P={on:l.fn.on,off:l.fn.off,remove:l.fn.remove,empty:l.fn.empty,detach:l.fn.detach};const s=P;l.fn.remove=function(t){const e=t?this.filter(t):this;for(let n=0,i=e.length;n<i;n++){const o=e[n];o&&(y.markIgnored(o),y.cleanupTree(o))}return s.remove.call(this,t)},l.fn.empty=function(){for(let t=0,e=this.length;t<e;t++){const n=this[t];n&&y.cleanupDescendants(n)}return s.empty.call(this)},l.fn.detach=function(t){const e=t?this.filter(t):this;for(let n=0,i=e.length;n<i;n++){const o=e[n];o&&y.keep(o)}return s.detach.call(this,t)},l.fn.on=function(...t){const e=t[0];if(e&&typeof e=="object")t[0]=As(e);else for(let n=t.length-1;n>=0;n--)if(typeof t[n]=="function"){t[n]=Ne(t[n]);break}return s.on.apply(this,t)},l.fn.off=function(...t){const e=t[0];if(e&&typeof e=="object")t[0]=Ls(e);else for(let n=t.length-1;n>=0;n--)if(typeof t[n]=="function"){const i=t[n];t[n]=yt.get(i)??i;break}return s.off.apply(this,t)}}function Us(){P!==null&&(l.fn.on=P.on,l.fn.off=P.off,l.fn.remove=P.remove,l.fn.empty=P.empty,l.fn.detach=P.detach,P=null)}var D=(s=>(s[s.None=0]="None",s[s.Focused=1]="Focused",s[s.Composing=2]="Composing",s[s.SyncingToAtom=4]="SyncingToAtom",s[s.SyncingToDom=8]="SyncingToDom",s[s.Busy=14]="Busy",s))(D||{});let ws=0;class ks{constructor(t,e,n){this.flags=0,this.timeoutId=void 0,this.handleCompositionStart=()=>{this.flags|=D.Composing},this.handleCompositionEnd=()=>{this.flags&=~D.Composing,this.handleInput()},this.handleFocus=()=>{this.flags|=D.Focused},this.handleBlur=()=>{this.flags&=~D.Focused,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0,this.syncAtomFromDom());const r=this.format(this.atom.peek());this.el.value!==r&&(this.el.value=r)},this.syncDomFromAtom=()=>{const r=this.atom.value;$(()=>{const c=this.format(r),E=this.el.value;if(E===c)return;const d=!!(this.flags&D.Focused);if(d)try{if(this.equal(this.parse(E),r))return}catch{}this.flags|=D.SyncingToDom;try{if(d&&(this.el instanceof HTMLInputElement||this.el instanceof HTMLTextAreaElement)){const m=this.el.selectionStart,N=this.el.selectionEnd;this.el.value=c;const p=c.length;m!==null&&N!==null&&this.el.setSelectionRange(m<p?m:p,N<p?N:p)}else this.el.value=c;f.domUpdated(this.$el,"val",c)}finally{this.flags&=~D.SyncingToDom}})},this.cleanup=()=>{this.$el.off(this.ns),clearTimeout(this.timeoutId),this.timeoutId=void 0},this.$el=t,this.el=t[0],this.atom=e,this.ns=`.atomBind-${++ws}`;const i=n.debounce??0,o=n.event??ts.EVENT;this.parse=n.parse??(r=>r),this.format=n.format??(r=>String(r??"")),this.equal=n.equal??Object.is,i>0?this.handleInput=()=>{this.flags&D.Composing||(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>this.syncAtomFromDom(),i))}:this.handleInput=()=>{this.flags&D.Composing||this.syncAtomFromDom()},this.handleFocus[B]=!0,this.handleBlur[B]=!0,this.handleCompositionStart[B]=!0,this.handleCompositionEnd[B]=!0,this.handleInput[B]=!0,this.bindEvents(o)}syncAtomFromDom(){if(!(this.flags&D.Busy)){this.flags|=D.SyncingToAtom;try{const t=this.parse(this.el.value);this.equal(this.atom.peek(),t)||(this.atom.value=t)}catch(t){f.warn(g.BINDING,`${T.PARSE_ERROR()}:`,t)}finally{this.flags&=~D.SyncingToAtom}}}bindEvents(t){const e=this.ns;this.$el.on(`focus${e}`,this.handleFocus).on(`blur${e}`,this.handleBlur).on(`compositionstart${e}`,this.handleCompositionStart).on(`compositionend${e}`,this.handleCompositionEnd).on(`${t}${e}`,this.handleInput)}}function Ps(s,t,e){const n=new ks(s,t,e);return{fx:G(n.syncDomFromAtom),cleanup:n.cleanup}}const he=new Map;function xs(s){let t=he.get(s);return t!==void 0||(t=s.includes("-")?s.replace(/-./g,e=>e[1].toUpperCase()):s,he.set(s,t)),t}const ue=new WeakMap;function $s(s){let t=ue.get(s);return t||(t=rt(()=>Gt(s.value)),ue.set(s,t)),t}function U(s){return{$el:l(s),el:s,trackCleanup:t=>y.trackCleanup(s,t)}}function ve(s,t,e){const n=s.el;Q(n,t,i=>{const o=e?e(i):typeof i=="string"?i:String(i??"");n.textContent!==o&&(n.textContent=o)},"text")}function De(s,t){const e=s.el,n=Tt(t)?$s(t):t;Q(e,n,i=>{e.innerHTML!==i&&(y.cleanupDescendants(e),e.innerHTML=i)},"html")}function Ae(s,t){for(const e in t)if(ct.call(t,e)){const n=t[e];Q(s.el,n,i=>{s.el.classList.toggle(e,!!i)},`class.${e}`)}}function Le(s,t){const e=s.el,n=e.style;for(const i in t)if(ct.call(t,i)){const o=t[i],r=xs(i),[c,E]=Array.isArray(o)?o:[o,""];Q(e,c,d=>{const m=E?`${d}${E}`:String(d);ms(m)||(n[r]=m)},`css.${i}`)}}function Ue(s,t){const e=s.el;for(const n in t)if(ct.call(t,n)){if(n.toLowerCase().startsWith("on"))continue;Q(e,t[n],i=>{if(i==null||i===!1){e.removeAttribute(n);return}const o=i===!0?n:String(i);gs(n,o)||e.getAttribute(n)!==o&&e.setAttribute(n,o)},`attr.${n}`)}}function we(s,t){const e=s.el;for(const n in t)if(ct.call(t,n)){if(ss.has(n))continue;Q(s.el,t[n],i=>{e[n]!==i&&(e[n]=i)},`prop.${n}`)}}function Ct(s,t,e){const n=s.el;Q(n,t,o=>{const r=e!==!!o;n.style.display=r?"":"none"},e?"hide":"show")}function ke(s,t,e={}){const n=s.el.tagName.toLowerCase();if(!es.has(n)){console.warn(`${g.BINDING} ${T.INVALID_INPUT_ELEMENT(n)}`);return}const{fx:i,cleanup:o}=Ps(s.$el,t,e);y.trackEffect(s.el,i),s.trackCleanup(o)}function Pe(s,t){const e=s.el,n=s.$el,i=()=>{const r=e.checked;t.value!==r&&(t.value=r)};i[B]=!0,n.on("change",i),s.trackCleanup(()=>n.off("change",i));const o=G(()=>{const r=!!t.value;$(()=>{e.checked!==r&&(e.checked=r,f.domUpdated(n,"checked",r))})});y.trackEffect(e,o)}function Ms(s,t){const e=s.$el;e.on(t),s.trackCleanup(()=>e.off(t))}function Fs(s,t,e){const n=s.$el;n.on(t,e),s.trackCleanup(()=>n.off(t,e))}function xe(s){y.cleanupTree(s)}l.fn.atomText=function(s,t){for(let e=0,n=this.length;e<n;e++)ve(U(this[e]),s,t);return this};l.fn.atomHtml=function(s){for(let t=0,e=this.length;t<e;t++)De(U(this[t]),s);return this};l.fn.atomClass=function(s,t){if(typeof s=="string"&&t===void 0)return console.warn(`${g.BINDING} ${T.MISSING_CONDITION("atomClass")}`),this;const e=typeof s=="string"?{[s]:t}:s;for(let n=0,i=this.length;n<i;n++)Ae(U(this[n]),e);return this};l.fn.atomCss=function(s,t,e){if(typeof s=="string"&&t===void 0)return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomCss")}`),this;const n=typeof s=="string"?{[s]:e?[t,e]:t}:s;for(let i=0,o=this.length;i<o;i++)Le(U(this[i]),n);return this};l.fn.atomAttr=function(s,t){if(typeof s=="string"&&t===void 0)return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomAttr")}`),this;const e=typeof s=="string"?{[s]:t}:s;for(let n=0,i=this.length;n<i;n++)Ue(U(this[n]),e);return this};l.fn.atomProp=function(s,t){if(typeof s=="string"&&t===void 0)return console.warn(`${g.BINDING} ${T.MISSING_SOURCE("atomProp")}`),this;const e=typeof s=="string"?{[s]:t}:s;for(let n=0,i=this.length;n<i;n++)we(U(this[n]),e);return this};l.fn.atomShow=function(s){for(let t=0,e=this.length;t<e;t++)Ct(U(this[t]),s,!1);return this};l.fn.atomHide=function(s){for(let t=0,e=this.length;t<e;t++)Ct(U(this[t]),s,!0);return this};l.fn.atomVal=function(s,t={}){for(let e=0,n=this.length;e<n;e++)ke(U(this[e]),s,t);return this};l.fn.atomChecked=function(s){for(let t=0,e=this.length;t<e;t++)Pe(U(this[t]),s);return this};l.fn.atomOn=function(s,t){for(let e=0,n=this.length;e<n;e++)Fs(U(this[e]),s,t);return this};l.fn.atomBind=function(s){const{text:t,html:e,class:n,css:i,attr:o,prop:r,show:c,hide:E,val:d,checked:m,on:N}=s;let p,O;d!==void 0&&(Array.isArray(d)?(p=d[0],O=d[1]):p=d);for(let j=0,C=this.length;j<C;j++){const I=U(this[j]);t!==void 0&&ve(I,t),e!==void 0&&De(I,e),n!==void 0&&Ae(I,n),i!==void 0&&Le(I,i),o!==void 0&&Ue(I,o),r!==void 0&&we(I,r),c!==void 0&&Ct(I,c,!1),E!==void 0&&Ct(I,E,!0),d!==void 0&&ke(I,p,O),m!==void 0&&Pe(I,m),N!==void 0&&Ms(I,N)}return this};l.fn.atomUnbind=function(){for(let s=0,t=this.length;s<t;s++)xe(this[s]);return this};function Bs(s,t,e){t?.isConnected?s.insertBefore(t):s.appendTo(e)}l.fn.atomList=function(s,t){const{key:e,render:n,bind:i,update:o,onAdd:r,onRemove:c,empty:E}=t,d=typeof e=="function"?e:(m,N)=>m[e];for(let m=0,N=this.length;m<N;m++){const p=this[m],O=l(p),j=Yt(p),C=new Map,I=new Set;let R=[],Y=null;const $e=(L,v)=>{const z=()=>{Rt?.isDisposed||(v.$el.remove(),I.delete(L),f.log("list",`${j} removed item:`,L))};if(!c){z();return}const M=c(v.$el);M instanceof Promise?M.then(z,z):z()},Kt=(L,v)=>{C.delete(L),I.add(L),$e(L,v)};let Rt;Rt=G(()=>{const L=s.value,v=L.length;$(()=>{if(Y&&v>0&&(Y.remove(),Y=null),v===0){if(E&&!Y){const a=typeof E=="string"?Gt(E):E;Y=l(a).appendTo(O)}for(let a=0;a<R.length;a++){const h=R[a],_=C.get(h);_&&Kt(h,_)}R.length=0;return}f.log("list",`${j} updating with ${v} items`);const z=new Map;for(let a=0;a<R.length;a++)z.set(R[a],a);const M=new Array(v),Nt=new Set,at=new Int32Array(v),lt=[],Ot=[],vt=[];for(let a=0;a<v;a++){const h=L[a],_=d(h,a);if(M[a]=_,Nt.has(_)){f.warn(g.LIST,T.DUPLICATE_KEY(_,a)),at[a]=-1;continue}Nt.add(_);const b=C.get(_);if(b){const u=b.item;!o&&u!==h&&!Is(u,h)&&(lt.push(_),Ot.push(h),vt.push(a)),at[a]=I.has(_)?-1:z.get(_)??-1}else lt.push(_),Ot.push(h),vt.push(a),at[a]=-1}const ht=lt.length,Wt=new Array(ht),Dt=[];for(let a=0;a<ht;a++){const h=n(Ot[a],vt[a]);Wt[a]=h,typeof h=="string"&&Dt.push(h)}let ut=null;if(Dt.length>0){const a=`<!--sep-${Math.random().toString(36).substring(2)}-${Date.now().toString(36)}-->`;ut=Gt(Dt.join(a)).split(a)}let Jt=0;for(let a=0;a<ht;a++){const h=Wt[a],_=l(typeof h=="string"?ut[Jt++]:h),b=lt[a],u=C.get(b);if(u){const w=u.$el[0];w&&y.cleanupTree(w),u.$el.replaceWith(_),u.$el=_,u.state="replaced"}else C.set(b,{$el:_,item:null,state:"new"})}for(let a=0;a<R.length;a++){const h=R[a];if(!Nt.has(h)){const _=C.get(h);_&&Kt(h,_)}}const Zt=ys(at);let At=Zt.length-1,te=null;const Lt=R.length===0;if(Lt&&ut!==null&&Jt===ht&&!i&&!r&&!c&&I.size===0){p.innerHTML=ut.join("");let a=0;for(let h=0;h<v;h++){const _=M[h],b=L[h],u=C.get(_);if(!u)continue;const w=p.children[a++];w&&(u.$el=l(w),u.item=b,u.state=void 0,I.delete(_),f.domUpdated(u.$el,"list.add",b))}}else{const a=Lt?document.createDocumentFragment():null;if(Lt&&a){for(let h=v-1;h>=0;h--){const _=M[h],b=L[h],u=C.get(_);if(!u)continue;const w=u.state;u.item=b,u.state=void 0,u.$el[0]&&(w===void 0?o&&o(u.$el,b,h):i&&i(u.$el,b,h));for(let Ut=u.$el.length-1;Ut>=0;Ut--)a.insertBefore(u.$el[Ut],a.firstChild);w==="new"&&(r&&r(u.$el),I.delete(_),f.domUpdated(u.$el,"list.add",b))}p.appendChild(a)}else for(let h=v-1;h>=0;h--){const _=M[h],b=L[h],u=C.get(_);if(!u)continue;const w=u.state;u.item=b,u.state=void 0,u.$el[0]&&(w===void 0?o&&o(u.$el,b,h):i&&i(u.$el,b,h)),At>=0&&Zt[At]===h?At--:Bs(u.$el,te,O),te=u.$el[0]??null,w==="new"&&(r&&r(u.$el),I.delete(_),f.domUpdated(u.$el,"list.add",b))}}R=M})}),y.trackEffect(p,Rt),y.trackCleanup(p,()=>{C.clear(),I.clear(),R.length=0,Y?.remove()})}return this};const Hs=Object.freeze({});l.fn.atomMount=function(s,t){const e=t??Hs;for(let n=0,i=this.length;n<i;n++){const o=this[n];if(!o)continue;y.cleanupTree(o);const r=l(o);let c;try{c=$(()=>s(r,e))}catch(E){f.error(g.MOUNT,T.MOUNT_ERROR(),E);continue}typeof c=="function"&&y.setComponentCleanup(o,c)}return this};l.fn.atomUnmount=function(){for(let s=0,t=this.length;s<t;s++){const e=this[s];e&&xe(e)}return this};function fe(s,t){try{return history.pushState(s,"",t),!0}catch(e){return f.warn(g.ROUTE,"PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.",e),!1}}class Gs{constructor(t){this.isDestroyed=!1,this.previousRoute="",this.cleanups=[],this.templateCache=new Map,this.config={...t,mode:t.mode??Et.mode,basePath:t.basePath??Et.basePath,autoBindLinks:t.autoBindLinks??Et.autoBindLinks,activeClass:t.activeClass??Et.activeClass},this.isHistoryMode=this.config.mode==="history",this.$target=l(this.config.target),this.normalizedBasePath=this.config.basePath?.replace(/\/$/,"")||"",this.previousUrl=this.isHistoryMode?window.location.pathname+window.location.search:window.location.hash,this.currentRouteAtom=It(this.getRouteName()),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=It(this.getQueryParams()),this.queryParams=rt(()=>this.queryParamsAtom.value),this.handleUrlChange=this.handleUrlChange.bind(this),this.destroy=this.destroy.bind(this),this.init()}init(){const t=this.isHistoryMode?"popstate":"hashchange";window.addEventListener(t,this.handleUrlChange),this.cleanups.push(()=>window.removeEventListener(t,this.handleUrlChange));const e=G(()=>{const n=this.currentRouteAtom.value;$(()=>this.renderRoute(n))});this.cleanups.push(()=>e.dispose()),this.setupAutoBindLinks(),this.$target[0]&&y.trackCleanup(this.$target[0],this.destroy)}getRouteName(){const{default:t}=this.config;if(this.isHistoryMode){let o=window.location.pathname;return this.normalizedBasePath&&o.startsWith(this.normalizedBasePath)&&(o=o.substring(this.normalizedBasePath.length)),o.charCodeAt(0)===47&&(o=o.slice(1)),o||t}const e=window.location.hash,n=e.indexOf("?");return(n===-1?e.substring(1):e.substring(1,n))||t}getQueryParams(){let t;if(this.isHistoryMode){if(t=window.location.search.substring(1),!t)return{}}else{const i=window.location.hash,o=i.indexOf("?");if(o===-1)return{};t=i.substring(o+1)}const e=new URLSearchParams(t),n=Object.fromEntries(e);if(t.includes("%"))try{decodeURIComponent(t)}catch{f.warn(g.ROUTE,T.MALFORMED_URI(t))}return n}setUrl(t){if(this.isHistoryMode){const e=`${this.normalizedBasePath}/${t}`;fe(null,e),this.previousUrl=e}else{const e=`#${t}`;window.location.hash=e,this.previousUrl=e}}restoreUrl(){this.isHistoryMode?fe(null,this.previousUrl):window.location.hash=this.previousUrl}getCurrentUrl(){return this.isHistoryMode?window.location.pathname+window.location.search:window.location.hash}getRouteConfig(t){const{routes:e,notFound:n}=this.config;let i=e[t];return!i&&n&&(i=e[n]),i||(f.warn(g.ROUTE,T.ROUTE_NOT_FOUND(t)),null)}renderTemplate(t){let e=this.templateCache.get(t);if(!e){const i=document.querySelector(t);if(!i||!(i instanceof HTMLTemplateElement))return f.warn(g.ROUTE,T.TEMPLATE_NOT_FOUND(t)),!1;e=i,this.templateCache.set(t,e)}const n=e.content.cloneNode(!0);return this.$target.append(n),!0}renderRoute(t){if(this.isDestroyed)return;const e=this.$target[0];if(!e){f.warn(g.ROUTE,T.TARGET_NOT_FOUND(this.config.target));return}const n=this.getRouteConfig(t);if(!n)return;const i=this.getQueryParams(),o=this.previousRoute;this.config.beforeTransition&&this.config.beforeTransition(o,t),this.$target.empty();let r=i;if(n.onEnter){const c=n.onEnter(i);c!==void 0&&(r={...i,...c})}n.render?n.render(e,t,r):n.template&&this.renderTemplate(n.template)&&n.onMount&&n.onMount(this.$target.children()),this.config.afterTransition&&this.config.afterTransition(o,t),this.previousRoute=t}handleUrlChange(){if(this.isDestroyed)return;const t=this.getCurrentUrl();if(t===this.previousUrl)return;const e=this.getRouteName(),n=this.currentRouteAtom.peek(),i=this.getQueryParams();if(n!==e){const o=this.config.routes[n];if(o?.onLeave&&o.onLeave()===!1){this.restoreUrl();return}this.currentRouteAtom.value=e,this.queryParamsAtom.value=i}else{this.queryParamsAtom.value=i;const o=this.config.routes[n];o?.onParamsChange?o.onParamsChange(i):this.renderRoute(e)}this.previousUrl=t}setupAutoBindLinks(){if(!this.config.autoBindLinks)return;const t=i=>{i.preventDefault();const o=i.currentTarget.dataset.route;o!=null&&this.navigate(o)};l(document).on("click","[data-route]",t),this.cleanups.push(()=>{l(document).off("click","[data-route]",t)});const{activeClass:e}=this.config,n=G(()=>{const i=this.currentRouteAtom.value;$(()=>{const o=document.querySelectorAll("[data-route]");for(let r=0,c=o.length;r<c;r++){const E=o[r],d=E.dataset.route,m=i===d;E.classList.toggle(e,m),m?E.setAttribute("aria-current","page"):E.removeAttribute("aria-current")}})});this.cleanups.push(()=>n.dispose())}navigate(t){if(this.isDestroyed)return;const e=this.currentRouteAtom.peek(),n=this.config.routes[e];if(n?.onLeave&&n.onLeave()===!1)return;const i=t||this.config.default;if(!i){f.warn(g.ROUTE,"navigate() called with empty routeName and no default configured.");return}this.setUrl(i),this.queryParamsAtom.value={},this.currentRouteAtom.value=i}destroy(){if(this.isDestroyed)return;this.isDestroyed=!0;const t=this.cleanups;for(let e=0,n=t.length;e<n;e++)try{t[e]()}catch(i){f.warn(g.ROUTE,"Cleanup error during destroy:",i)}this.cleanups.length=0,this.templateCache.clear()}}function js(s){return new Gs(s)}l.extend({route:js});const zs=new Promise(()=>{});l.extend({atomFetch(s,t){const{defaultValue:e,transform:n,method:i,headers:o,ajaxOptions:r,onError:c,eager:E}=t,d=typeof s=="string",m=d?s:void 0,N=d?null:s,p=Object.assign({},r);i!==void 0&&(p.method=i),o!==void 0&&(p.headers=o),d&&(p.url=m);let O=null;return rt(async()=>{O?.abort(),O=new AbortController;const C=O.signal;d||(p.url=N());const I=l.ajax(p);C.onabort=()=>I.abort(),C.aborted&&I.abort();try{const R=await I;return n?n(R):R}catch(R){if(C.aborted)return zs;try{c?.(R)}catch{}throw R}finally{C.onabort=null,O.signal===C&&(O=null)}},{defaultValue:e,lazy:!(E??!0)})}});l(()=>{Oe(),Re(document.body)});exports.default=l;exports.atom=It;exports.batch=Xt;exports.computed=rt;exports.disableAutoCleanup=Ds;exports.disablejQueryOverrides=Us;exports.effect=G;exports.enableAutoCleanup=Re;exports.enablejQueryOverrides=Oe;exports.isAtom=Tt;exports.isComputed=ye;exports.isReactive=Qt;exports.nextTick=Te;exports.registry=y;exports.untracked=$;
|
|
3
|
-
//# sourceMappingURL=index.cjs.map
|
|
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:`
|
|
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
|
+
//# sourceMappingURL=index.cjs.map
|