summitjs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +105 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/dist/summit.cjs +3324 -0
- package/dist/summit.cjs.map +1 -0
- package/dist/summit.d.cts +269 -0
- package/dist/summit.d.ts +269 -0
- package/dist/summit.js +3304 -0
- package/dist/summit.js.map +1 -0
- package/dist/summit.min.js +7 -0
- package/dist/summit.min.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(){'use strict';var j,W=[],pe=0,te=new Set;function O(n,e={}){let t=pn(n,e);return e.lazy||t(),t}function pn(n,e){let t=function(){if(!t.active)return n();if(!W.includes(t)){qe(t);try{return W.push(t),j=t,n()}finally{W.pop(),j=W[W.length-1];}}};return t.deps=[],t.active=true,t.scheduler=e.scheduler,t.onStop=e.onStop,t.raw=n,t}function qe(n){let{deps:e}=n;for(let t of e)t.delete(n);e.length=0;}function fe(n){n.active&&(qe(n),n.onStop?.(),n.active=false);}function C(n){j&&(n.has(j)||(n.add(j),j.deps.push(n)));}function I(n){let e=[...n];for(let t of e)if(t!==j){if(pe>0){te.add(t);continue}Ge(t);}}function Ge(n){n.scheduler?n.scheduler():n();}function de(n){pe++;try{return n()}finally{--pe===0&&fn();}}function fn(){if(te.size===0)return;let n=[...te];te.clear();for(let e of n)e.active&&Ge(e);}function me(n){let e=n,t=new Set,r=function(){return C(t),e};return r.set=i=>{let s=typeof i=="function"?i(e):i;Object.is(s,e)||(e=s,I(t));},r.peek=()=>e,r}function z(n){let e,t=true,r=new Set,i=O(n,{lazy:true,scheduler:()=>{t||(t=true,I(r));}}),s=function(){return t&&(e=i(),t=false),C(r),e};return s.peek=()=>(t&&(e=i(),t=false),e),s}var ge=Symbol("summit.raw"),he=Symbol("summit.iterate"),ye=new WeakMap,_e=new WeakMap;function dn(n,e){let t=ye.get(n);t||ye.set(n,t=new Map);let r=t.get(e);return r||t.set(e,r=new Set),r}function ve(n,e){C(dn(n,e));}function q(n,e){let t=ye.get(n);if(!t)return;let r=t.get(e);r&&I(r);}function Je(n){return n!==null&&typeof n=="object"}function mn(n){let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function Ye(n){return Je(n)&&(Array.isArray(n)||mn(n))}var hn={get(n,e,t){if(e===ge)return n;let r=Reflect.get(n,e,t);return typeof e=="symbol"?r:(ve(n,e),Ye(r)?E(r):r)},set(n,e,t,r){let i=Je(t)?xe(t):t,s=Array.isArray(n),o=s?Number(e)<n.length:Object.prototype.hasOwnProperty.call(n,e),a=n[e],c=Reflect.set(n,e,i,r);return o?Object.is(a,i)||q(n,e):(q(n,e),q(n,s?"length":he)),c},has(n,e){return ve(n,e),Reflect.has(n,e)},deleteProperty(n,e){let t=Object.prototype.hasOwnProperty.call(n,e),r=Reflect.deleteProperty(n,e);return t&&r&&(q(n,e),q(n,he)),r},ownKeys(n){return ve(n,Array.isArray(n)?"length":he),Reflect.ownKeys(n)}};function E(n){if(!Ye(n)||n[ge])return n;let e=_e.get(n);if(e)return e;let t=new Proxy(n,hn);return _e.set(n,t),t}function xe(n){let e=n&&n[ge];return e?xe(e):n}var be=new Set,we=false,Ee=null,Ze=Promise.resolve();function ke(n){be.add(n),we||(we=true,Ee=Ze.then(vn));}function vn(){let n=[...be];be.clear(),we=false,Ee=null;for(let e of n)e();}function G(n){let e=Ee??Ze;return n?e.then(()=>{n();}):e.then(()=>{})}function T(n){let e;return e=O(n,{lazy:true,scheduler:()=>ke(e)}),e(),()=>fe(e)}var Pe=new Map,Se=new Map,Xe=new Map,Ae=E({}),Qe=new Map,Te=100;function h(n,e,t=Te){Pe.set(n,{handler:e,priority:t});}function ne(n){return Pe.get(n)}function Ve(){return [...Pe.keys()]}function g(n,e){Se.set(n,e);}function re(n){return Se.get(n)}function et(){return [...Se.keys()]}function tt(n,e){Xe.set(n,e);}function De(n){return Xe.get(n)}function Re(n,e){Ae[n]=e;}function Me(n){return Ae[n]}function nt(){return Ae}function rt(n,e){Qe.set(n,e);}function it(n){return Qe.get(n)}function _(n){let e=E(n),t=Object.getOwnPropertyDescriptors(n);for(let r of Object.keys(t)){let i=t[r];if(typeof i.get=="function"){let s=i.get,o=i.set,a=z(()=>s.call(e));Object.defineProperty(n,r,{get:()=>a(),set:o?c=>o.call(e,c):void 0,enumerable:i.enumerable,configurable:true});}else typeof i.value=="function"&&(n[r]=i.value.bind(e));}return e}var yn=["...","===","!==","**=","&&=","||=","??=","==","!=","<=",">=","&&","||","??","?.","=>","++","--","+=","-=","*=","/=","%=","**","(",")","[","]","{","}",".",",",";",":","?","+","-","*","/","%","<",">","=","!"],Y=class extends Error{};function gn(n){return /[A-Za-z_$]/.test(n)}function xn(n){return /[A-Za-z0-9_$]/.test(n)}function J(n){return n>="0"&&n<="9"}function st(n){let e=[],t=0,r=n.length;for(;t<r;){let i=n[t];if(i===" "||i===" "||i===`
|
|
2
|
+
`||i==="\r"){t++;continue}if(J(i)||i==="."&&J(n[t+1]??"")){let o=t;if(i==="0"&&(n[t+1]==="x"||n[t+1]==="X"))for(t+=2;t<r&&/[0-9a-fA-F]/.test(n[t]);)t++;else {for(;t<r&&J(n[t]);)t++;if(n[t]===".")for(t++;t<r&&J(n[t]);)t++;if(n[t]==="e"||n[t]==="E")for(t++,(n[t]==="+"||n[t]==="-")&&t++;t<r&&J(n[t]);)t++;}e.push({type:"num",value:n.slice(o,t),start:o,end:t});continue}if(i==='"'||i==="'"){let o=t,a=i;t++;let c="";for(;t<r&&n[t]!==a;)n[t]==="\\"?(c+=bn(n,t),t+=2):(c+=n[t],t++);if(t>=r)throw new Y(`Unterminated string in expression: ${n}`);t++,e.push({type:"str",value:c,start:o,end:t});continue}if(i==="`"){let o=t;t++;let a="",c=0;for(;t<r;){let u=n[t];if(u==="\\"){a+=n[t]+(n[t+1]??""),t+=2;continue}if(u==="`"&&c===0)break;if(u==="$"&&n[t+1]==="{"){c++,a+="${",t+=2;continue}if(u==="}"&&c>0){c--,a+="}",t++;continue}a+=u,t++;}if(t>=r)throw new Y(`Unterminated template literal: ${n}`);t++,e.push({type:"tmpl",value:a,raw:a,start:o,end:t});continue}if(gn(i)){let o=t;for(t++;t<r&&xn(n[t]);)t++;e.push({type:"ident",value:n.slice(o,t),start:o,end:t});continue}let s=false;for(let o of yn)if(n.startsWith(o,t)){e.push({type:"punc",value:o,start:t,end:t+o.length}),t+=o.length,s=true;break}if(!s)throw new Y(`Unexpected character '${i}' in expression: ${n}`)}return e.push({type:"eof",value:"",start:r,end:r}),e}function bn(n,e){let t=n[e+1];switch(t){case "n":return `
|
|
3
|
+
`;case "t":return " ";case "r":return "\r";case "b":return "\b";case "f":return "\f";case "v":return "\v";case "0":return "\0";case "\\":return "\\";case "'":return "'";case '"':return '"';case "`":return "`";default:return t??""}}var D=class extends Error{},wn=new Set(["true","false","null","undefined","this","typeof","void","in","instanceof","if","else","return","let","const","var","for","of","while","break","continue"]),En={"??":1,"||":2,"&&":3,"==":7,"!=":7,"===":7,"!==":7,"<":8,">":8,"<=":8,">=":8,in:8,instanceof:8,"+":10,"-":10,"*":11,"/":11,"%":11,"**":12},kn=new Set(["=","+=","-=","*=","/=","%=","**=","&&=","||=","??="]),Le=class{constructor(e){this.pos=0;this.tokens=st(e);}peek(e=0){return this.tokens[this.pos+e]??this.tokens[this.tokens.length-1]}next(){return this.tokens[this.pos++]??this.tokens[this.tokens.length-1]}isPunc(e,t=0){let r=this.peek(t);return r.type==="punc"&&r.value===e}isKeyword(e,t=0){let r=this.peek(t);return r.type==="ident"&&r.value===e}eatPunc(e){if(!this.isPunc(e))throw new D(`Expected '${e}' but found '${this.peek().value||"end of input"}'`);this.pos++;}atEnd(){return this.peek().type==="eof"}parseProgram(){let e=[];for(;!this.atEnd();){if(this.isPunc(";")){this.pos++;continue}e.push(this.parseStatement());}return {type:"Program",body:e}}parseExpressionProgram(){let e=this.parseExpression();if(!this.atEnd())throw new D(`Unexpected trailing input '${this.peek().value}'`);return {type:"Program",body:[{type:"ExpressionStatement",expression:e}]}}parseStatement(){if(this.isPunc("{"))return this.parseBlock();if(this.isKeyword("if"))return this.parseIf();if(this.isKeyword("return"))return this.parseReturn();if(this.isKeyword("let")||this.isKeyword("const")||this.isKeyword("var")){let t=this.parseVarDecl();return this.consumeSemi(),t}if(this.isKeyword("for"))return this.parseFor();if(this.isKeyword("while"))return this.parseWhile();if(this.isKeyword("break"))return this.pos++,this.consumeSemi(),{type:"BreakStatement"};if(this.isKeyword("continue"))return this.pos++,this.consumeSemi(),{type:"ContinueStatement"};let e=this.parseExpression();return this.consumeSemi(),{type:"ExpressionStatement",expression:e}}consumeSemi(){this.isPunc(";")&&this.pos++;}parseBlock(){this.eatPunc("{");let e=[];for(;!this.isPunc("}")&&!this.atEnd();){if(this.isPunc(";")){this.pos++;continue}e.push(this.parseStatement());}return this.eatPunc("}"),{type:"BlockStatement",body:e}}parseIf(){this.pos++,this.eatPunc("(");let e=this.parseExpression();this.eatPunc(")");let t=this.parseStatement(),r=null;return this.isKeyword("else")&&(this.pos++,r=this.parseStatement()),{type:"IfStatement",test:e,consequent:t,alternate:r}}parseReturn(){this.pos++;let e=null;return !this.isPunc(";")&&!this.isPunc("}")&&!this.atEnd()&&(e=this.parseExpression()),this.consumeSemi(),{type:"ReturnStatement",argument:e}}parseVarDecl(){let e=this.next().value,t=[];do{let r=this.parsePattern(),i=null;this.isPunc("=")&&(this.pos++,i=this.parseAssignment()),t.push({id:r,init:i});}while(this.isPunc(",")&&(this.pos++,true));return {type:"VariableDeclaration",kind:e,declarations:t}}parseFor(){this.pos++,this.eatPunc("(");let e=null;if(this.isKeyword("let")||this.isKeyword("const")||this.isKeyword("var")){let s=this.next().value,o=this.parsePattern();if(this.isKeyword("of")){this.pos++;let u=this.parseExpression();this.eatPunc(")");let d=this.parseStatement();return {type:"ForOfStatement",left:{type:"VariableDeclaration",kind:s,declarations:[{id:o,init:null}]},right:u,body:d}}let a=null;this.isPunc("=")&&(this.pos++,a=this.parseAssignment());let c=[{id:o,init:a}];for(;this.isPunc(",");){this.pos++;let u=this.parsePattern(),d=null;this.isPunc("=")&&(this.pos++,d=this.parseAssignment()),c.push({id:u,init:d});}e={type:"VariableDeclaration",kind:s,declarations:c};}else this.isPunc(";")||(e=this.parseExpression());this.eatPunc(";");let t=this.isPunc(";")?null:this.parseExpression();this.eatPunc(";");let r=this.isPunc(")")?null:this.parseExpression();this.eatPunc(")");let i=this.parseStatement();return {type:"ForStatement",init:e,test:t,update:r,body:i}}parseWhile(){this.pos++,this.eatPunc("(");let e=this.parseExpression();this.eatPunc(")");let t=this.parseStatement();return {type:"WhileStatement",test:e,body:t}}parseExpression(){return this.parseAssignment()}parseAssignment(){if(this.isArrowAhead())return this.parseArrow();let e=this.parseConditional(),t=this.peek();if(t.type==="punc"&&kn.has(t.value)){this.pos++;let r=this.parseAssignment();return {type:"AssignmentExpression",operator:t.value,left:e,right:r}}return e}parseConditional(){let e=this.parseBinary(1);if(this.isPunc("?")){this.pos++;let t=this.parseAssignment();this.eatPunc(":");let r=this.parseAssignment();return {type:"ConditionalExpression",test:e,consequent:t,alternate:r}}return e}parseBinary(e){let t=this.parseUnary();for(;;){let r=this.peek(),i=r.type==="punc"||r.type==="ident"&&(r.value==="in"||r.value==="instanceof")?r.value:null;if(i===null)break;let s=En[i];if(s===void 0||s<e)break;this.pos++;let o=i==="**",a=this.parseBinary(o?s:s+1);i==="&&"||i==="||"||i==="??"?t={type:"LogicalExpression",operator:i,left:t,right:a}:t={type:"BinaryExpression",operator:i,left:t,right:a};}return t}parseUnary(){let e=this.peek();return e.type==="punc"&&(e.value==="!"||e.value==="-"||e.value==="+")?(this.pos++,{type:"UnaryExpression",operator:e.value,argument:this.parseUnary()}):e.type==="ident"&&(e.value==="typeof"||e.value==="void")?(this.pos++,{type:"UnaryExpression",operator:e.value,argument:this.parseUnary()}):e.type==="punc"&&(e.value==="++"||e.value==="--")?(this.pos++,{type:"UpdateExpression",operator:e.value,prefix:true,argument:this.parseUnary()}):this.parsePostfix()}parsePostfix(){let e=this.parseCallMember(),t=this.peek();return t.type==="punc"&&(t.value==="++"||t.value==="--")&&(this.pos++,e={type:"UpdateExpression",operator:t.value,prefix:false,argument:e}),e}parseCallMember(){let e=this.parsePrimary();for(;;)if(this.isPunc(".")){this.pos++;let t=this.next();e={type:"MemberExpression",object:e,property:{type:"Identifier",name:t.value},computed:false,optional:false};}else if(this.isPunc("?."))if(this.pos++,this.isPunc("("))e={type:"CallExpression",callee:e,arguments:this.parseArguments(),optional:true};else if(this.isPunc("[")){this.pos++;let t=this.parseExpression();this.eatPunc("]"),e={type:"MemberExpression",object:e,property:t,computed:true,optional:true};}else {let t=this.next();e={type:"MemberExpression",object:e,property:{type:"Identifier",name:t.value},computed:false,optional:true};}else if(this.isPunc("[")){this.pos++;let t=this.parseExpression();this.eatPunc("]"),e={type:"MemberExpression",object:e,property:t,computed:true,optional:false};}else if(this.isPunc("("))e={type:"CallExpression",callee:e,arguments:this.parseArguments(),optional:false};else break;return e}parseArguments(){this.eatPunc("(");let e=[];for(;!this.isPunc(")")&&!this.atEnd()&&(this.isPunc("...")?(this.pos++,e.push({type:"SpreadElement",argument:this.parseAssignment()})):e.push(this.parseAssignment()),this.isPunc(","));)this.pos++;return this.eatPunc(")"),e}parsePrimary(){let e=this.peek();if(e.type==="num")return this.pos++,{type:"NumberLiteral",value:e.value.startsWith("0x")||e.value.startsWith("0X")?parseInt(e.value,16):Number(e.value)};if(e.type==="str")return this.pos++,{type:"StringLiteral",value:e.value};if(e.type==="tmpl")return this.pos++,this.parseTemplate(e.raw??"");if(e.type==="ident")return e.value==="true"||e.value==="false"?(this.pos++,{type:"BooleanLiteral",value:e.value==="true"}):e.value==="null"?(this.pos++,{type:"NullLiteral"}):e.value==="undefined"?(this.pos++,{type:"UndefinedLiteral"}):e.value==="this"?(this.pos++,{type:"ThisExpression"}):(this.pos++,{type:"Identifier",name:e.value});if(this.isPunc("(")){this.pos++;let t=this.parseAssignment();if(this.isPunc(",")){let r=[t];for(;this.isPunc(",");)this.pos++,r.push(this.parseAssignment());return this.eatPunc(")"),{type:"SequenceExpression",expressions:r}}return this.eatPunc(")"),t}if(this.isPunc("["))return this.parseArray();if(this.isPunc("{"))return this.parseObject();throw new D(`Unexpected token '${e.value||"end of input"}' in expression`)}parseArray(){this.eatPunc("[");let e=[];for(;!this.isPunc("]")&&!this.atEnd();){if(this.isPunc(",")){e.push(null),this.pos++;continue}if(this.isPunc("...")?(this.pos++,e.push({type:"SpreadElement",argument:this.parseAssignment()})):e.push(this.parseAssignment()),this.isPunc(","))this.pos++;else break}return this.eatPunc("]"),{type:"ArrayExpression",elements:e}}parseObject(){this.eatPunc("{");let e=[];for(;!this.isPunc("}")&&!this.atEnd()&&(this.isPunc("...")?(this.pos++,e.push({type:"SpreadElement",argument:this.parseAssignment()})):e.push(this.parseObjectProperty()),this.isPunc(","));)this.pos++;return this.eatPunc("}"),{type:"ObjectExpression",properties:e}}parseObjectProperty(){if((this.isKeyword("get")||this.isKeyword("set"))&&!this.isPunc(":",1)&&!this.isPunc(",",1)&&!this.isPunc("(",1)&&!this.isPunc("}",1)){let i=this.next().value,{key:s,computed:o}=this.parsePropertyKey(),a=this.parseMethodTail();return {key:s,computed:o,value:a,kind:i,shorthand:false}}let{key:e,computed:t,keyName:r}=this.parsePropertyKey();if(this.isPunc("(")){let i=this.parseMethodTail();return {key:e,computed:t,value:i,kind:"method",shorthand:false}}if(this.isPunc(":")){this.pos++;let i=this.parseAssignment();return {key:e,computed:t,value:i,kind:"init",shorthand:false}}if(r!==null&&!t)return {key:e,computed:t,value:{type:"Identifier",name:r},kind:"init",shorthand:true};throw new D(`Invalid object property near '${this.peek().value}'`)}parsePropertyKey(){if(this.isPunc("[")){this.pos++;let t=this.parseAssignment();return this.eatPunc("]"),{key:t,computed:true,keyName:null}}let e=this.next();if(e.type==="str")return {key:{type:"StringLiteral",value:e.value},computed:false,keyName:e.value};if(e.type==="num")return {key:{type:"StringLiteral",value:String(Number(e.value))},computed:false,keyName:null};if(e.type==="ident")return {key:{type:"StringLiteral",value:e.value},computed:false,keyName:e.value};throw new D(`Invalid property key '${e.value}'`)}parseMethodTail(){let e=this.parseParamList(),t=this.parseBlock();return {type:"ArrowFunction",params:e,body:t,expression:false}}isArrowAhead(){let e=this.peek();if(e.type==="ident"&&!wn.has(e.value)&&this.isPunc("=>",1))return true;if(this.isPunc("(")){let t=0,r=this.pos;for(;r<this.tokens.length;r++){let s=this.tokens[r];if(s.type==="punc"&&s.value==="(")t++;else if(s.type==="punc"&&s.value===")"){if(t--,t===0)break}else if(s.type==="eof")return false}let i=this.tokens[r+1];return !!i&&i.type==="punc"&&i.value==="=>"}return false}parseArrow(){let e;if(this.peek().type==="ident"?e=[{type:"Identifier",name:this.next().value}]:e=this.parseParamList(),this.eatPunc("=>"),this.isPunc("{")){let r=this.parseBlock();return {type:"ArrowFunction",params:e,body:r,expression:false}}let t=this.parseAssignment();return {type:"ArrowFunction",params:e,body:t,expression:true}}parseParamList(){this.eatPunc("(");let e=[];for(;!this.isPunc(")")&&!this.atEnd()&&(e.push(this.parsePattern()),this.isPunc(","));)this.pos++;return this.eatPunc(")"),e}parsePattern(){let e;if(this.isPunc("..."))return this.pos++,{type:"RestElement",argument:this.parsePattern()};if(this.isPunc("{"))e=this.parseObjectPattern();else if(this.isPunc("["))e=this.parseArrayPattern();else {let t=this.next();if(t.type!=="ident")throw new D(`Invalid binding target '${t.value}'`);e={type:"Identifier",name:t.value};}if(this.isPunc("=")){this.pos++;let t=this.parseAssignment();return {type:"AssignmentPattern",left:e,right:t}}return e}parseObjectPattern(){this.eatPunc("{");let e=[],t=null;for(;!this.isPunc("}")&&!this.atEnd();){if(this.isPunc("...")){this.pos++,t={type:"Identifier",name:this.next().value};break}let{key:r,computed:i,keyName:s}=this.parsePropertyKey(),o;if(this.isPunc(":")?(this.pos++,o=this.parsePattern()):(o={type:"Identifier",name:s??""},this.isPunc("=")&&(this.pos++,o={type:"AssignmentPattern",left:o,right:this.parseAssignment()})),e.push({key:r,value:o,computed:i}),this.isPunc(","))this.pos++;else break}return this.eatPunc("}"),{type:"ObjectPattern",properties:e,rest:t}}parseArrayPattern(){this.eatPunc("[");let e=[],t=null;for(;!this.isPunc("]")&&!this.atEnd();){if(this.isPunc(",")){e.push(null),this.pos++;continue}if(this.isPunc("...")){this.pos++,t=this.parsePattern();break}if(e.push(this.parsePattern()),this.isPunc(","))this.pos++;else break}return this.eatPunc("]"),{type:"ArrayPattern",elements:e,rest:t}}parseTemplate(e){let t=[],r=[],i="",s=0;for(;s<e.length;)if(e[s]==="$"&&e[s+1]==="{"){t.push(i),i="",s+=2;let o=1,a="";for(;s<e.length&&o>0;){let u=e[s];if(u==="{")o++;else if(u==="}"&&(o--,o===0))break;a+=u,s++;}s++;let c=ie(a,"expression").body[0];r.push(c&&c.type==="ExpressionStatement"?c.expression:{type:"UndefinedLiteral"});}else i+=e[s],s++;return t.push(i),{type:"TemplateLiteral",quasis:t,expressions:r}}},ot=new Map;function ie(n,e){let t=e+"\0"+n,r=ot.get(t);if(r)return r;let i=new Le(n),s=e==="expression"?i.parseExpressionProgram():i.parseProgram();return ot.set(t,s),s}var Z=class{constructor(e){this.value=e;}},F=class{},K=class{},k=class{constructor(e){this.parent=e;this.vars=new Map;}declare(e,t,r){this.vars.set(e,{value:t,constant:r});}find(e){let t=this;for(;t;){if(t.vars.has(e))return t;t=t.parent;}return null}has(e){return this.find(e)!==null}get(e){return this.find(e)?.vars.get(e)?.value}set(e,t){let r=this.find(e);if(!r)return false;let i=r.vars.get(e);if(i.constant)throw new TypeError(`Assignment to constant '${e}'`);return i.value=t,true}},ct=new Set(["Math","JSON","Date","Object","Array","Number","String","Boolean","parseInt","parseFloat","isNaN","isFinite","RegExp","Map","Set","WeakMap","WeakSet","Promise","Intl","console","window","document","location","navigator","history","localStorage","sessionStorage","setTimeout","clearTimeout","setInterval","clearInterval","requestAnimationFrame","cancelAnimationFrame","fetch","alert","confirm","prompt","structuredClone","URL","URLSearchParams","encodeURIComponent","decodeURIComponent","NaN","Infinity"]);function je(n){for(let e of n)ct.add(e);}function at(n,e){if(n!=null)return n[e]}var X=class{constructor(e){this.root=e;}run(e,t){let r=new k(null),i;try{for(let s of e.body)s.type==="ExpressionStatement"?i=this.evalExpr(s.expression,r,t):this.execStmt(s,r,t);}catch(s){if(s instanceof Z)return s.value;throw s}return i}execBlock(e,t,r){for(let i of e)this.execStmt(i,t,r);}execStmt(e,t,r){switch(e.type){case "ExpressionStatement":this.evalExpr(e.expression,t,r);return;case "BlockStatement":this.execBlock(e.body,new k(t),r);return;case "IfStatement":this.evalExpr(e.test,t,r)?this.execStmt(e.consequent,t,r):e.alternate&&this.execStmt(e.alternate,t,r);return;case "ReturnStatement":throw new Z(e.argument?this.evalExpr(e.argument,t,r):void 0);case "VariableDeclaration":for(let i of e.declarations){let s=i.init?this.evalExpr(i.init,t,r):void 0;this.bindPattern(i.id,s,t,e.kind==="const");}return;case "WhileStatement":for(;this.evalExpr(e.test,t,r);)try{this.execStmt(e.body,new k(t),r);}catch(i){if(i instanceof F)break;if(i instanceof K)continue;throw i}return;case "ForOfStatement":{let i=this.evalExpr(e.right,t,r);for(let s of i??[]){let o=new k(t);e.left.type==="VariableDeclaration"?this.bindPattern(e.left.declarations[0].id,s,o,e.left.kind==="const"):this.assignPattern(e.left,s,o,r);try{this.execStmt(e.body,o,r);}catch(a){if(a instanceof F)break;if(a instanceof K)continue;throw a}}return}case "ForStatement":{let i=new k(t);for(e.init&&(e.init.type==="VariableDeclaration"?this.execStmt(e.init,i,r):this.evalExpr(e.init,i,r));!e.test||this.evalExpr(e.test,i,r);){try{this.execStmt(e.body,new k(i),r);}catch(s){if(s instanceof F)break;if(!(s instanceof K))throw s}e.update&&this.evalExpr(e.update,i,r);}return}case "BreakStatement":throw new F;case "ContinueStatement":throw new K}}evalExpr(e,t,r){switch(e.type){case "NumberLiteral":case "StringLiteral":case "BooleanLiteral":return e.value;case "NullLiteral":return null;case "UndefinedLiteral":return;case "ThisExpression":return r;case "Identifier":return this.resolve(e.name,t);case "TemplateLiteral":{let i=e.quasis[0]??"";for(let s=0;s<e.expressions.length;s++)i+=String(this.evalExpr(e.expressions[s],t,r)??""),i+=e.quasis[s+1]??"";return i}case "ArrayExpression":{let i=[];for(let s of e.elements)s===null?i.push(void 0):s.type==="SpreadElement"?i.push(...this.evalExpr(s.argument,t,r)):i.push(this.evalExpr(s,t,r));return i}case "ObjectExpression":return this.evalObject(e,t,r);case "UnaryExpression":{let i=this.evalExpr(e.argument,t,r);switch(e.operator){case "!":return !i;case "-":return -i;case "+":return +i;case "typeof":return typeof i;case "void":return}return}case "UpdateExpression":{let i=Number(this.evalTarget(e.argument,t,r)),s=e.operator==="++"?i+1:i-1;return this.assign(e.argument,s,t,r),e.prefix?s:i}case "BinaryExpression":return this.evalBinary(e.operator,this.evalExpr(e.left,t,r),this.evalExpr(e.right,t,r));case "LogicalExpression":{let i=this.evalExpr(e.left,t,r);return e.operator==="&&"?i&&this.evalExpr(e.right,t,r):e.operator==="||"?i||this.evalExpr(e.right,t,r):i??this.evalExpr(e.right,t,r)}case "ConditionalExpression":return this.evalExpr(e.test,t,r)?this.evalExpr(e.consequent,t,r):this.evalExpr(e.alternate,t,r);case "AssignmentExpression":return this.evalAssignment(e,t,r);case "MemberExpression":{let i=this.evalExpr(e.object,t,r);if(e.optional&&i==null)return;let s=e.computed?this.evalExpr(e.property,t,r):e.property.name;return at(i,s)}case "CallExpression":return this.evalCall(e,t,r);case "ArrowFunction":return this.makeFunction(e,t,r,false);case "SequenceExpression":{let i;for(let s of e.expressions)i=this.evalExpr(s,t,r);return i}case "SpreadElement":return this.evalExpr(e.argument,t,r)}}evalObject(e,t,r){let i={};for(let s of e.properties){if(s.type==="SpreadElement"){Object.assign(i,this.evalExpr(s.argument,t,r));continue}let o=s,a=o.computed?String(this.evalExpr(o.key,t,r)):o.key.value;if(o.kind==="get"){let c=this.makeFunction(o.value,t,r,true);Object.defineProperty(i,a,{get:c,enumerable:true,configurable:true});}else if(o.kind==="set"){let c=this.makeFunction(o.value,t,r,true);Object.defineProperty(i,a,{set:c,enumerable:true,configurable:true});}else o.kind==="method"?i[a]=this.makeFunction(o.value,t,r,true):i[a]=this.evalExpr(o.value,t,r);}return i}evalCall(e,t,r){let i,s;if(e.callee.type==="MemberExpression"){let a=e.callee,c=this.evalExpr(a.object,t,r);if(a.optional&&c==null)return;s=c;let u=a.computed?this.evalExpr(a.property,t,r):a.property.name;i=at(c,u);}else i=this.evalExpr(e.callee,t,r);if(e.optional&&i==null)return;let o=this.evalArguments(e.arguments,t,r);if(typeof i!="function"){if(i==null)return;throw new TypeError("Expression value is not a function")}return i.apply(s,o)}evalArguments(e,t,r){let i=[];for(let s of e)s.type==="SpreadElement"?i.push(...this.evalExpr(s.argument,t,r)):i.push(this.evalExpr(s,t,r));return i}evalBinary(e,t,r){switch(e){case "+":return t+r;case "-":return t-r;case "*":return t*r;case "/":return t/r;case "%":return t%r;case "**":return t**r;case "==":return t==r;case "!=":return t!=r;case "===":return t===r;case "!==":return t!==r;case "<":return t<r;case ">":return t>r;case "<=":return t<=r;case ">=":return t>=r;case "in":return t in r;case "instanceof":return t instanceof r}}evalAssignment(e,t,r){let i=e.operator;if(i==="="){let a=this.evalExpr(e.right,t,r);return this.assign(e.left,a,t,r),a}let s=this.evalTarget(e.left,t,r),o;if(i==="&&="){if(!s)return s;o=this.evalExpr(e.right,t,r);}else if(i==="||="){if(s)return s;o=this.evalExpr(e.right,t,r);}else if(i==="??="){if(s!=null)return s;o=this.evalExpr(e.right,t,r);}else {let a=this.evalExpr(e.right,t,r);o=this.evalBinary(i.slice(0,-1),s,a);}return this.assign(e.left,o,t,r),o}evalTarget(e,t,r){return this.evalExpr(e,t,r)}assign(e,t,r,i){if(e.type==="Identifier"){r.set(e.name,t)||this.root.set(e.name,t);return}if(e.type==="MemberExpression"){let s=this.evalExpr(e.object,r,i);if(s==null)throw new TypeError("Cannot assign to a property of null or undefined");let o=e.computed?this.evalExpr(e.property,r,i):e.property.name;s[o]=t;return}throw new TypeError("Invalid assignment target")}resolve(e,t){if(t.has(e))return t.get(e);if(this.root.has(e))return this.root.get(e);if(ct.has(e))return globalThis[e]}makeFunction(e,t,r,i){let s=this;return function(...o){let a=new k(t);s.bindParams(e.params,o,a);let c=i?this:r;if(e.expression)return s.evalExpr(e.body,a,c);try{s.execBlock(e.body.body,new k(a),c);}catch(u){if(u instanceof Z)return u.value;throw u}}}bindParams(e,t,r){for(let i=0;i<e.length;i++){let s=e[i];if(s.type==="RestElement"){this.bindPattern(s.argument,t.slice(i),r,false);break}this.bindPattern(s,t[i],r,false);}}bindPattern(e,t,r,i){switch(e.type){case "Identifier":r.declare(e.name,t,i);return;case "AssignmentPattern":this.bindPattern(e.left,t===void 0?this.evalExpr(e.right,r,void 0):t,r,i);return;case "RestElement":this.bindPattern(e.argument,t,r,i);return;case "ObjectPattern":{let s=t??{},o=new Set;for(let a of e.properties){let c=a.computed?String(this.evalExpr(a.key,r,void 0)):a.key.value;o.add(c),this.bindPattern(a.value,s[c],r,i);}if(e.rest){let a={};for(let c of Object.keys(s))o.has(c)||(a[c]=s[c]);r.declare(e.rest.name,a,i);}return}case "ArrayPattern":{let s=t??[];for(let o=0;o<e.elements.length;o++){let a=e.elements[o];a&&this.bindPattern(a,s[o],r,i);}e.rest&&this.bindPattern(e.rest,s.slice(e.elements.length),r,i);return}}}assignPattern(e,t,r,i){if(e.type==="Identifier"){r.set(e.name,t)||this.root.set(e.name,t);return}this.bindPattern(e,t,r,false);}};function N(n,e,t){let r=ie(n,"expression");return new X(e).run(r,t)}function Oe(n,e,t){let r=ie(n,"program");return new X(e).run(r,t)}var Pn="https://velofy.github.io/summit";function Sn(n,e){let t=n.length,r=e.length;if(!t)return r;if(!r)return t;let i=Array.from({length:r+1},(s,o)=>o);for(let s=1;s<=t;s++){let o=[s];for(let a=1;a<=r;a++){let c=n[s-1]===e[a-1]?0:1;o[a]=Math.min(i[a]+1,o[a-1]+1,i[a-1]+c);}i=o;}return i[r]}function lt(n,e){let t=null,r=1/0;for(let s of e){let o=Sn(n,s);o<r&&(r=o,t=s);}let i=n.length<=4?1:2;return t!==null&&r<=i?t:null}function An(n){let e=n.tagName.toLowerCase(),t=n.id?`#${n.id}`:"",r=n.classList.length?"."+Array.from(n.classList).slice(0,2).join("."):"";return `<${e}${t}${r}>`}function se(n,e,t){let r=[`[summit] ${n}: ${e}`];return t.hint&&r.push(` ${t.hint}`),t.expression&&r.push(` expression: ${t.expression.trim()}`),t.el&&r.push(` element: ${An(t.el)}`),r.push(` docs: ${Pn}/${t.doc?t.doc+"/":""}`),r.join(`
|
|
4
|
+
`)}function $(n,e,t={}){t.cause!==void 0?console.warn(se(n,e,t),`
|
|
5
|
+
`,t.cause):console.warn(se(n,e,t));}function w(n,e,t={}){t.cause!==void 0?console.error(se(n,e,t),`
|
|
6
|
+
`,t.cause):console.error(se(n,e,t));}var ut=new Set;function pt(n,e,t,r={}){ut.has(n)||(ut.add(n),$(e,t,r));}var B=new WeakMap;function R(n){let e=B.get(n);return e||B.set(n,e={}),e}var Tn=0;function ft(){return ++Tn}function P(n,e){let t=R(n);(t.cleanups??(t.cleanups=[])).push(e);}function dt(n){let e=B.get(n);if(e){if(e.cleanups){for(let t of e.cleanups)try{t();}catch(r){w("E601","a cleanup callback threw during teardown.",{doc:"lifecycle",cause:r});}e.cleanups=[];}if(e.destroyCallbacks){for(let t of e.destroyCallbacks)try{t();}catch(r){w("E602","a destroy() callback threw during teardown.",{doc:"lifecycle",cause:r});}e.destroyCallbacks=[];}}}function oe(n){let e=B.get(n)?.scopes;if(e)return e;let t=n.parentElement;for(;t;){let r=B.get(t)?.scopes;if(r)return r;t=t.parentElement;}return []}function Ce(n){let e=n;for(;e;){if(B.get(e)?.isRoot)return e;e=e.parentElement;}return null}function ae(n){let e=Ce(n)??n,t=R(e);return t.refs??(t.refs={})}var mt=36;function M(n,e){let t=oe(n),r=t.length?t[t.length-1]:void 0,i={el:n,scopes:t,evaluate:o=>N(o,s,r),effect:o=>{let a=T(o);P(n,a);},cleanup:o=>P(n,o)},s={has(o){if(e&&o in e)return true;for(let a=t.length-1;a>=0;a--)if(o in t[a])return true;return !!(o.charCodeAt(0)===mt&&re(o.slice(1)))},get(o){if(e&&o in e)return e[o];for(let a=t.length-1;a>=0;a--)if(o in t[a])return t[a][o];if(o.charCodeAt(0)===mt){let a=re(o.slice(1));if(a)return a(i)}},set(o,a){for(let c=t.length-1;c>=0;c--)if(o in t[c]){t[c][o]=a;return}t.length&&(t[t.length-1][o]=a);}};return {env:s,thisVal:r,evaluate:o=>N(o,s,r),evaluateAction:(o,a)=>a?Oe(o,{has:u=>u in a?true:s.has(u),get:u=>u in a?a[u]:s.get(u),set:(u,d)=>s.set(u,d)},r):Oe(o,s,r)}}function Ie(n,e,t){let r={el:e,scopes:t,evaluate:i=>N(i,M(e).env,t.length?t[t.length-1]:void 0),effect:i=>P(e,T(i)),cleanup:i=>P(e,i)};for(let i of et())Object.defineProperty(n,"$"+i,{get:()=>re(i)(r),enumerable:false,configurable:true});}function ht(n,e){let t=n;if(t[0]==="@")t="on:"+t.slice(1);else if(t[0]===":")t="bind:"+t.slice(1);else if(t.startsWith("s-"))t=t.slice(2);else return null;let r=t.split("."),i=r[0],s=r.slice(1),o=i.indexOf(":"),a,c;return o===-1?(a=i,c=null):(a=i.slice(0,o),c=i.slice(o+1)),{name:a,value:c,modifiers:s,expression:e,raw:n}}var vt="__summitPersist";function yt(n){return {[vt]:true,initial:n,key:null,as(e){return this.key=String(e),this}}}function gt(n){return !!n&&typeof n=="object"&&n[vt]===true}var Dn=new Set(["if","for","teleport"]),xt=new Set(["data","ignore"]),Et;function $e(n){Et=n;}function Rn(n){let e=[];for(let t of Array.from(n.attributes)){let r=ht(t.name,t.value);if(r)if(xt.has(r.name)||ne(r.name))e.push(r);else {let i=lt(r.name,[...Ve(),...xt]);pt(`dir:${r.name}`,"E201",`unknown directive "${t.name}".`,{el:n,doc:i?`s-${i}`:"start",hint:i?`Did you mean "s-${i}"?`:"See the directive reference."});}}return e}function bt(n){return ne(n)?.priority??Te}function Mn(n,e){let t=M(n);return {evaluate:r=>t.evaluate(r),evaluateAction:(r,i)=>t.evaluateAction(r,i),effect:r=>{let i=T(r);P(n,i);},cleanup:r=>P(n,r),initTree:L,destroyTree:H,scopes:e,makeEnv:(r,i)=>M(r,i).env,Summit:Et}}function wt(n,e,t){let r=ne(e.name);if(r)try{r.handler(n,e,Mn(n,t));}catch(i){w("E301",`s-${e.name} failed while evaluating its expression.`,{el:n,expression:e.expression,doc:`s-${e.name}`,hint:"Every name in the expression must be state from an enclosing s-data, or an allowed global.",cause:i});}}var Ln=/^([A-Za-z_$][\w$]*)\s*(\(([\s\S]*)\))?$/;function jn(n,e){let t=typeof localStorage<"u";for(let r of Object.keys(n)){let i=n[r];if(!gt(i))continue;let s=i.key??r,o=i.initial;if(t)try{let a=localStorage.getItem(s);a!=null&&(o=JSON.parse(a));}catch{}if(n[r]=o,t){let a=T(()=>{try{localStorage.setItem(s,JSON.stringify(n[r]));}catch{}});P(e,a);}}}function On(n,e,t){let r=M(n),i=e.expression.trim(),s,o=i.match(Ln);if(o&&De(o[1])){let p=De(o[1]),m=o[2]?r.evaluate("["+(o[3]??"")+"]"):[];s=p(...m);}else i===""?s={}:s=r.evaluate("("+i+")");(s===null||typeof s!="object")&&(s={});let a=_(s);jn(a,n);let c=[...t,a],u=R(n);u.scopes=c,u.isRoot=true,u.refs={},Ie(s,n,c);let d=a.init;if(typeof d=="function")try{d();}catch(p){w("E101","s-data init() threw.",{el:n,doc:"s-data",cause:p});}let l=a.destroy;return typeof l=="function"&&P(n,()=>{try{l();}catch(p){w("E102","s-data destroy() threw.",{el:n,doc:"s-data",cause:p});}}),c}function L(n,e){let t=R(n);if(t.initialized||t.ignore)return;if(n.hasAttribute("s-ignore")){t.ignore=true,t.initialized=true;return}let r=e??oe(n);t.scopes=r,t.marker=ft();let i=Rn(n),s=i.find(c=>c.name==="data");s&&(r=On(n,s,r));let o=i.find(c=>Dn.has(c.name));if(o){t.initialized=true,wt(n,o,r);return}let a=i.filter(c=>c.name!=="data").sort((c,u)=>bt(c.name)-bt(u.name));for(let c of a)wt(n,c,r);t.initialized=true;for(let c of Array.from(n.children))L(c,r);}function H(n){dt(n);for(let e of Array.from(n.children))H(e);R(n).initialized=false;}var He=null;function Fe(n){He||(He=new MutationObserver(Cn),He.observe(n,{childList:true,subtree:true}));}function Cn(n){let e=[],t=[];for(let r of n)r.type==="childList"&&(r.removedNodes.forEach(i=>{i.nodeType===1&&e.push(i);}),r.addedNodes.forEach(i=>{i.nodeType===1&&t.push(i);}));for(let r of e)r.isConnected||H(r);for(let r of t)r.isConnected&&!R(r).initialized&&L(r);}function kt(n){return n==null?"":String(n)}var Pt=(n,e,t)=>{t.effect(()=>{n.textContent=kt(t.evaluate(e.expression));});},St=(n,e,t)=>{t.effect(()=>{n.innerHTML=kt(t.evaluate(e.expression));let r=n.firstElementChild;for(;r;)t.initTree(r,t.scopes),r=r.nextElementSibling;});};var In=new Set(["disabled","checked","required","readonly","hidden","selected","open","multiple","autofocus","novalidate","autoplay","controls","loop","muted","playsinline","default","ismap","reversed","async","defer","inert"]),$n=new Set(["value","checked","selected","indeterminate","muted","volume"]);function ce(n){return n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Ke(n){return n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function At(n){return n?typeof n=="string"?n.split(/\s+/).filter(Boolean):Array.isArray(n)?n.flatMap(e=>At(e)):typeof n=="object"?Object.entries(n).filter(([,e])=>e).map(([e])=>e):[]:[]}function Tt(n,e){let t=new Set;for(let r of n.split(/\s+/))r&&t.add(r);for(let r of At(e))t.add(r);return [...t].join(" ")}function Dt(n,e){let t=[];if(n&&t.push(n.trim().replace(/;?\s*$/,"")),typeof e=="string")t.push(e.trim().replace(/;?\s*$/,""));else if(e&&typeof e=="object")for(let[r,i]of Object.entries(e))i==null||i===false||t.push(`${Ke(r)}: ${String(i)}`);return t.filter(Boolean).join("; ")}function ue(n,e,t){if(In.has(e)){t?n.setAttribute(e,""):n.removeAttribute(e),e in n&&(n[e]=!!t);return}if($n.has(e)&&e in n){n[e]=t;return}t===false||t==null?n.removeAttribute(e):n.setAttribute(e,String(t));}var Rt=(n,e,t)=>{if(e.value===null){Hn(n,e.expression,t);return}let r=e.modifiers.includes("camel")?ce(e.value):e.value;if(r==="class"){let i=n.getAttribute("class")??"";t.effect(()=>{n.setAttribute("class",Tt(i,t.evaluate(e.expression)));});return}if(r==="style"){let i=n.getAttribute("style")??"";t.effect(()=>{let s=Dt(i,t.evaluate(e.expression));s?n.setAttribute("style",s):n.removeAttribute("style");});return}t.effect(()=>{ue(n,r,t.evaluate(e.expression));});};function Hn(n,e,t){let r=t.evaluate(e);if(!(!r||typeof r!="object"))for(let[i,s]of Object.entries(r))if(i[0]==="@"){let o=i.slice(1),a=s;n.addEventListener(o,a),t.cleanup(()=>n.removeEventListener(o,a));}else if(i[0]===":"){let o=i.slice(1),a=s;t.effect(()=>ue(n,o,typeof a=="function"?a():a));}else ue(n,i,s);}var Fn=new Set(["shift","ctrl","alt","cmd","meta"]),Kn=new Set(["prevent","stop","self","outside","once","capture","passive","window","document","camel","dot","debounce","throttle"]),Nn={enter:"Enter",tab:"Tab",space:" ",esc:"Escape",escape:"Escape",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight","arrow-up":"ArrowUp","arrow-down":"ArrowDown","arrow-left":"ArrowLeft","arrow-right":"ArrowRight","page-up":"PageUp","page-down":"PageDown",home:"Home",end:"End",delete:"Delete",backspace:"Backspace"};function Lt(n){return /^\d+(ms|s)?$/.test(n)}function Bn(n){return n.endsWith("ms")?parseInt(n,10):n.endsWith("s")?parseInt(n,10)*1e3:parseInt(n,10)}function Mt(n,e){let t=n.indexOf(e);if(t===-1)return null;let r=n[t+1];return r&&Lt(r)?Bn(r):250}function Un(n,e){let t=n.key;if(!t)return false;let r=Nn[e];return r?t===r:Ke(t).toLowerCase()===e.toLowerCase()||t.toLowerCase()===e.toLowerCase()}function Wn(n,e){let t=n;return !(e.includes("shift")&&!t.shiftKey||e.includes("ctrl")&&!t.ctrlKey||e.includes("alt")&&!t.altKey||(e.includes("cmd")||e.includes("meta"))&&!t.metaKey)}function zn(n,e){let t;return r=>{clearTimeout(t),t=setTimeout(()=>n(r),e);}}function qn(n,e){let t=0,r;return i=>{let s=Date.now(),o=e-(s-t);o<=0?(t=s,n(i)):r||(r=setTimeout(()=>{t=Date.now(),r=void 0,n(i);},o));}}var jt=(n,e,t)=>{let r=e.modifiers,i=e.value??"";r.includes("camel")&&(i=ce(i)),r.includes("dot")&&(i=i.replace(/-/g,"."));let s=r.filter(p=>!Fn.has(p)&&!Kn.has(p)&&!Lt(p)),o=r.includes("window")?window:r.includes("document")||r.includes("outside")?document:n,a={};r.includes("capture")&&(a.capture=true),r.includes("passive")&&(a.passive=true),r.includes("once")&&(a.once=true);let c=p=>{if(!(r.includes("self")&&p.target!==n)){if(r.includes("outside")){let m=p.target;if(n===m||n.contains(m)||!document.documentElement.contains(m))return}if(!(s.length&&!s.some(m=>Un(p,m)))&&Wn(p,r)){r.includes("prevent")&&p.preventDefault(),r.includes("stop")&&p.stopPropagation();try{let m=t.evaluateAction(e.expression,{$event:p});typeof m=="function"&&m(p);}catch(m){w("E301",`@${i} handler failed while evaluating its expression.`,{el:n,expression:e.expression,doc:"s-on",hint:"Names must be state from an enclosing s-data, a $magic, or an allowed global.",cause:m});}}}},u=Mt(r,"debounce"),d=Mt(r,"throttle"),l=c;u!=null?l=zn(c,u):d!=null&&(l=qn(c,d)),o.addEventListener(i,l,a),t.cleanup(()=>o.removeEventListener(i,l,a));};function Ne(n,e){if(e.includes("number")){let t=parseFloat(n);return isNaN(t)?n:t}return e.includes("boolean")?n==="true"?true:n==="false"?false:!!n:n}function Gn(n,e){let t;return ()=>{clearTimeout(t),t=setTimeout(n,e);}}function _n(n,e){let t=n.indexOf(e);if(t===-1)return null;let r=n[t+1];return r&&/^\d+(ms|s)?$/.test(r)?r.endsWith("s")&&!r.endsWith("ms")?parseInt(r,10)*1e3:parseInt(r,10):250}var Ot=(n,e,t)=>{let r=n,i=n,s=e.modifiers,o=e.expression,a=r.type,c=n.tagName,u=()=>t.evaluate(o),d=f=>{t.evaluateAction(o+" = $model",{$model:f});};if(s.includes("fill")){let f=u();(f==null||f==="")&&d(Ne(r.value??r.getAttribute("value")??"",s));}let l=()=>{if(a==="checkbox"){let f=u();if(Array.isArray(f)){let y=new Set(f);return r.checked?y.add(r.value):y.delete(r.value),[...y]}return r.checked}return a==="radio"?Ne(r.value,s):c==="SELECT"&&i.multiple?Array.from(i.selectedOptions).map(f=>f.value):Ne(r.value,s)},p=f=>{if(a==="checkbox"){r.checked=Array.isArray(f)?f.map(String).includes(r.value):!!f;return}if(a==="radio"){r.checked=String(f)===r.value;return}if(c==="SELECT"&&i.multiple){let x=new Set(f?.map(String)??[]);for(let A of Array.from(i.options))A.selected=x.has(A.value);return}let y=f==null?"":String(f);r.value!==y&&(r.value=y);};t.effect(()=>p(u()));let m="input";(c==="SELECT"||a==="checkbox"||a==="radio")&&(m="change"),(s.includes("lazy")||s.includes("change"))&&(m="change"),s.includes("blur")&&(m="blur");let S=()=>d(l()),v=_n(s,"debounce");v!=null&&(S=Gn(S,v)),n.addEventListener(m,S),t.cleanup(()=>n.removeEventListener(m,S)),n._summitModel={get:u,set:d};};var Q=new WeakMap;function Jn(n){let e=Q.get(n);return e||Q.set(n,e={classMode:false}),e}function It(n){return Q.has(n)}function b(n){return n?n.split(/\s+/).filter(Boolean):[]}function Ct(n,e){let t=n.indexOf(e);if(t===-1)return;let r=n[t+1];if(r)return r.endsWith("ms")?parseInt(r,10):r.endsWith("s")?parseInt(r,10)*1e3:parseInt(r,10)}var $t=(n,e)=>{let t=Jn(n),r=e.modifiers;if(e.value){t.classMode=true;let i=e.value,s={enter:"enter","enter-start":"enterStart","enter-end":"enterEnd",leave:"leave","leave-start":"leaveStart","leave-end":"leaveEnd"};t[s[i]]=e.expression;return}if(t.duration=Ct(r,"duration")??t.duration,t.delay=Ct(r,"delay")??t.delay,r.includes("opacity")&&(t.opacity=true),r.includes("scale")){let i=r.indexOf("scale"),s=r[i+1];t.scale=s&&/^\d+$/.test(s)?parseInt(s,10)/100:.95;}!r.includes("opacity")&&t.scale===void 0&&(t.opacity=true,t.scale=.95);};function Ht(n,e,t){let r=getComputedStyle(n).transitionDuration,i=r&&r!=="0s"?parseFloat(r)*1e3:e;i<=0?requestAnimationFrame(()=>t()):setTimeout(t,i);}function Ft(n,e){let t=Q.get(n);if(!t){return}if(t.classMode){n.classList.add(...b(t.enter),...b(t.enterStart)),requestAnimationFrame(()=>{n.classList.remove(...b(t.enterStart)),n.classList.add(...b(t.enterEnd)),Ht(n,t.duration??150,()=>{n.classList.remove(...b(t.enter),...b(t.enterEnd));});});return}let r=t.duration??150;n.style.transition="none",t.opacity&&(n.style.opacity="0"),t.scale!==void 0&&(n.style.transform=`scale(${t.scale})`),requestAnimationFrame(()=>{n.style.transition=`all ${r}ms ease-out ${t.delay??0}ms`,t.opacity&&(n.style.opacity="1"),t.scale!==void 0&&(n.style.transform="scale(1)"),setTimeout(()=>{n.style.removeProperty("transition"),n.style.removeProperty("opacity"),n.style.removeProperty("transform");},r+(t.delay??0));});}function Kt(n,e){let t=Q.get(n);if(!t){e();return}if(t.classMode){n.classList.add(...b(t.leave),...b(t.leaveStart)),requestAnimationFrame(()=>{n.classList.remove(...b(t.leaveStart)),n.classList.add(...b(t.leaveEnd)),Ht(n,t.duration??150,()=>{n.classList.remove(...b(t.leave),...b(t.leaveEnd)),e();});});return}let r=t.duration??150;n.style.transition=`all ${r}ms ease-in ${t.delay??0}ms`,requestAnimationFrame(()=>{t.opacity&&(n.style.opacity="0"),t.scale!==void 0&&(n.style.transform=`scale(${t.scale})`),setTimeout(()=>{n.style.removeProperty("transition"),n.style.removeProperty("opacity"),n.style.removeProperty("transform"),e();},r+(t.delay??0));});}var Nt=(n,e,t)=>{let r=n,i=e.modifiers.includes("important"),s=r.style.display==="none"?"":r.style.display,o=()=>{s?r.style.display=s:r.style.removeProperty("display");},a=()=>{i?r.style.setProperty("display","none","important"):r.style.setProperty("display","none");},c=true;t.effect(()=>{let u=!!t.evaluate(e.expression),d=It(n)&&!c;if(c=false,!d){u?o():a();return}u?(o(),Ft(r)):Kt(r,a);});};var Bt=(n,e,t)=>{let r=n.parentNode;if(!r)return;let i=document.createComment("s-if");r.insertBefore(i,n);let s;if(n.tagName==="TEMPLATE")s=Array.from(n.content.children).map(u=>u.cloneNode(true));else {let u=n.cloneNode(true);u.removeAttribute(e.raw),s=[u];}if(n.remove(),!s.length)return;let o=t.scopes,a=[],c=()=>{for(let u of a)t.destroyTree(u),u.remove();a=[];};t.effect(()=>{let u=!!t.evaluate(e.expression);if(u&&!a.length){let d=s.map(p=>p.cloneNode(true)),l=document.createDocumentFragment();for(let p of d)l.appendChild(p);i.parentNode?.insertBefore(l,i.nextSibling);for(let p of d)t.initTree(p,o);a=d;}else !u&&a.length&&c();}),t.cleanup(c);};var Ut=/^\s*(.+?)\s+(?:in|of)\s+([\s\S]+)$/;function Yn(n){let e=n.trim();if(e.startsWith("(")){let r=e.slice(1,-1).split(",").map(i=>i.trim());return {item:r[0],index:r[1]??null}}return {item:e,index:null}}function Zn(n){return typeof n=="number"?Array.from({length:n},(e,t)=>({value:t+1,index:t})):Array.isArray(n)?n.map((e,t)=>({value:e,index:t})):n&&typeof n=="object"?Object.entries(n).map(([e,t],r)=>({value:t,index:r,objectKey:e})):[]}var Wt=(n,e,t)=>{if(n.tagName!=="TEMPLATE"){$("E401","s-for must be used on a <template> element.",{el:n,doc:"s-for",hint:`Wrap the repeated markup: <template s-for="${e.expression}"><li>...</li></template>`});return}let r=n.parentNode;if(!r)return;let i=n.content.firstElementChild;if(!i){$("E402","s-for <template> needs exactly one root element.",{el:n,doc:"s-for"});return}let{item:s,index:o}=Yn(e.expression.replace(Ut,"$1")),a=e.expression.replace(Ut,"$2"),c=n.getAttribute(":key")??n.getAttribute("s-bind:key"),u=document.createComment("s-for");r.insertBefore(u,n),n.remove();let d=t.scopes,l=new Map,p=(v,f)=>{if(!c)return v.objectKey??v.index;let y=M(n,f).env;try{return N(c,y)}catch{return v.index}},m=v=>{let f={[s]:v.value};return o&&(f[o]=v.objectKey??v.index),E(f)},S=()=>{for(let v of l.values())t.destroyTree(v.node),v.node.remove();l.clear();};t.effect(()=>{let v=Zn(t.evaluate(a)),f=new Map,y=[];for(let x of v){let A=m(x),U=p(x,A);y.push(U);let ee=l.get(U);if(ee)ee.scope[s]=x.value,o&&(ee.scope[o]=x.objectKey??x.index),f.set(U,ee),l.delete(U);else {let ze=i.cloneNode(true);t.initTree(ze,[...d,A]),f.set(U,{node:ze,scope:A});}}for(let x of l.values())t.destroyTree(x.node),x.node.remove();for(let x of y){let A=f.get(x);r.insertBefore(A.node,u);}l=f;}),t.cleanup(S);};var zt=(n,e,t)=>{if(n.tagName!=="TEMPLATE"){$("E501","s-teleport must be used on a <template> element.",{el:n,doc:"s-teleport"});return}let r=e.expression||e.value||"",i=r?document.querySelector(r):null;if(!i){$("E502",`s-teleport target not found: "${r}".`,{el:n,doc:"s-teleport",hint:"The target must be a CSS selector that already exists in the DOM, e.g. body."});return}let s=n.content,o=Array.from(s.children).map(c=>c.cloneNode(true)),a=document.createDocumentFragment();for(let c of o)a.appendChild(c);e.modifiers.includes("prepend")?i.parentNode?.insertBefore(a,i):e.modifiers.includes("append")?i.parentNode?.insertBefore(a,i.nextSibling):i.appendChild(a);for(let c of o)t.initTree(c,t.scopes);t.cleanup(()=>{for(let c of o)t.destroyTree(c),c.remove();});};var qt=0,Be=new WeakMap;function Gt(n,e){let t=Be.get(n);t||Be.set(n,t=new Map);for(let r of e)t.set(r,++qt);}function _t(n,e,t){let r=n;for(;r;){let s=Be.get(r);if(s&&s.has(e)){let o=`${e}-${s.get(e)}`;return t!=null?`${o}-${t}`:o}r=r.parentElement;}let i=`${e}-${++qt}`;return t!=null?`${i}-${t}`:i}var Jt=(n,e,t)=>{t.evaluateAction(e.expression);},Yt=(n,e,t)=>{t.effect(()=>{t.evaluateAction(e.expression);});},Zt=(n,e,t)=>{let r=t.evaluate(e.expression),i=typeof r=="string"&&r?r:e.expression.trim(),s=ae(n);s[i]=n,t.cleanup(()=>{s[i]===n&&delete s[i];});},Xt=(n,e,t)=>{let r=t.evaluate(e.expression);Array.isArray(r)&&Gt(n,r.map(String));},Qt=n=>{n.removeAttribute("s-cloak");};var Vt=(n,e,t)=>{if(typeof IntersectionObserver>"u")return;let r=e.value==="leave",i=e.modifiers.includes("full")?.99:e.modifiers.includes("half")?.5:0,s=e.modifiers.includes("once"),o=new IntersectionObserver(a=>{for(let c of a)(r?!c.isIntersecting:c.isIntersecting)&&(t.evaluateAction(e.expression),s&&o.disconnect());},{threshold:i});o.observe(n),t.cleanup(()=>o.disconnect());},en=(n,e,t)=>{if(typeof ResizeObserver>"u")return;let r=new ResizeObserver(i=>{let s=i[0]?.contentRect;t.evaluateAction(e.expression,{$width:s?.width??0,$height:s?.height??0});});r.observe(n),t.cleanup(()=>r.disconnect());};var Xn=["a[href]","button:not([disabled])","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])","[contenteditable]"].join(",");function Qn(n){let e=n.getBoundingClientRect();return e.width===0&&e.height===0?n.offsetParent!==null||typeof n.offsetParent>"u":true}function V(n){return Array.from(n.querySelectorAll(Xn)).filter(Qn)}var tn=(n,e,t)=>{let r=false,i=null,s=c=>{if(c.key!=="Tab")return;let u=V(n);if(!u.length){c.preventDefault();return}let d=u[0],l=u[u.length-1],p=document.activeElement;c.shiftKey&&(p===d||!n.contains(p))?(c.preventDefault(),l.focus()):!c.shiftKey&&p===l&&(c.preventDefault(),d.focus());},o=()=>{if(r)return;r=true,i=document.activeElement,document.addEventListener("keydown",s,true);let c=()=>{(V(n)[0]??n).focus?.();};typeof requestAnimationFrame=="function"?requestAnimationFrame(c):c();},a=()=>{r&&(r=false,document.removeEventListener("keydown",s,true),i?.focus?.());};t.effect(()=>{t.evaluate(e.expression)?o():a();}),t.cleanup(a);};var nn=(n,e,t)=>{let r=e.modifiers,i=r.includes("top")?"top":"bottom",s=r.includes("end")?"end":r.includes("center")?"center":"start",o=r.indexOf("offset"),a=o>=0&&/^\d+$/.test(r[o+1]??"")?Number(r[o+1]):8,c=n;c.style.position="fixed",c.style.zIndex||(c.style.zIndex="50"),c.style.margin="0";let u=null,d=()=>{if(!u||typeof window>"u")return;let l=u.getBoundingClientRect(),p=c.offsetWidth,m=c.offsetHeight,S=window.innerHeight,v=window.innerWidth,f=i==="top"?l.top-m-a:l.bottom+a;i==="bottom"&&f+m>S&&l.top-m-a>=0&&(f=l.top-m-a),i==="top"&&f<0&&l.bottom+a+m<=S&&(f=l.bottom+a);let y=s==="end"?l.right-p:s==="center"?l.left+l.width/2-p/2:l.left;y=Math.max(8,Math.min(y,v-p-8)),c.style.top=`${Math.round(f)}px`,c.style.left=`${Math.round(y)}px`;};if(t.effect(()=>{let l=t.evaluate(e.expression);u=l&&typeof l.getBoundingClientRect=="function"?l:null,u&&d();}),typeof window<"u"){let l=()=>d();window.addEventListener("scroll",l,true),window.addEventListener("resize",l),t.cleanup(()=>{window.removeEventListener("scroll",l,true),window.removeEventListener("resize",l);});}};var rn=(n,e,t)=>{let r=n;r.style.overflow="hidden";let i=true;t.effect(()=>{let s=!!t.evaluate(e.expression);if(i){i=false,r.style.height=s?"auto":"0px",s||r.setAttribute("hidden","until-found");return}r.removeAttribute("hidden");let o=r.getBoundingClientRect().height;r.style.height=`${o}px`;let a=s?r.scrollHeight:0,c=()=>{r.style.transition="height 250ms ease",r.style.height=`${a}px`;};typeof requestAnimationFrame=="function"?requestAnimationFrame(c):c();let u=()=>{r.style.transition="",s&&(r.style.height="auto"),r.removeEventListener("transitionend",u);};r.addEventListener("transitionend",u);});};function Vn(n,e){return n==="9"?/\d/.test(e):n==="a"?/[a-zA-Z]/.test(e):n==="*"?/[a-zA-Z0-9]/.test(e):false}function er(n,e){let t="",r=0;for(let i of e){if(r>=n.length)break;if(i==="9"||i==="a"||i==="*")for(;r<n.length;){let s=n[r++];if(Vn(i,s)){t+=s;break}}else t+=i,n[r]===i&&r++;}return t}var sn=(n,e,t)=>{let r=n,i=String(t.evaluate(e.expression)??e.expression),s=()=>{r.value=er(r.value,i);};r.addEventListener("input",s),r.value&&s(),t.cleanup(()=>r.removeEventListener("input",s));};function on(){h("ref",Zt,10),h("id",Xt,15),h("if",Bt,20),h("for",Wt,20),h("teleport",zt,20),h("bind",Rt,50),h("mask",sn,55),h("model",Ot,60),h("on",jt,70),h("text",Pt,80),h("html",St,80),h("transition",$t,85),h("anchor",nn,88),h("collapse",rn,89),h("show",Nt,90),h("trap",tn,95),h("effect",Yt,100),h("intersect",Vt,100),h("resize",en,100),h("init",Jt,200),h("cloak",Qt,1e3);}function Ue(n){let e=()=>V(n),t=r=>{let i=e();if(!i.length)return;let s=i.indexOf(document.activeElement),o=s===-1?0:(s+r+i.length)%i.length;i[o]?.focus();};return {focus(r){r?.focus?.();},first(){e()[0]?.focus();},last(){let r=e();r[r.length-1]?.focus();},next(){t(1);},previous(){t(-1);},within(r){return Ue(r)}}}function an(){g("el",n=>n.el),g("refs",n=>ae(n.el)),g("root",n=>Ce(n.el)),g("data",n=>n.scopes.length?n.scopes[n.scopes.length-1]:{}),g("store",()=>nt()),g("watch",n=>(e,t)=>{let r,i=true,s=T(()=>{let o=n.evaluate(e);if(i){r=o,i=false;return}if(Object.is(o,r))return;let a=r;r=o,t(o,a);});return n.cleanup(s),s}),g("dispatch",n=>(e,t,r={})=>{let i=new CustomEvent(e,{detail:t,bubbles:true,composed:true,cancelable:true,...r});return n.el.dispatchEvent(i)}),g("nextTick",()=>n=>G(n)),g("id",n=>(e,t)=>_t(n.el,e,t)),g("persist",()=>n=>yt(n)),g("focus",n=>Ue(n.el));}var tr="0.1.0",We=false;function cn(n){typeof document<"u"&&document.dispatchEvent(new CustomEvent(n));}function nr(n){if(We)return;We=true;let e=n??(typeof document<"u"?document.body:void 0);e&&(cn("summit:init"),L(e),Fe(e.ownerDocument?.body??e),cn("summit:initialized"));}var un={version:tr,started:()=>We,start:nr,data(n,e){return tt(n,e),this},directive(n,e,t){return h(n,e,t),this},magic(n,e){return g(n,e),this},bind(n,e){return rt(n,e),this},store(n,e){if(e===void 0)return Me(n);if(e!==null&&typeof e=="object"){let t=_(e);Re(n,t);let r=t.init;if(typeof r=="function")try{r();}catch(i){w("E103",`store "${n}" init() threw.`,{doc:"globals-store",cause:i});}return t}return Re(n,e),Me(n)},plugin(n){return n(this),this},addGlobals(n){return je(n),this},getBind:it,signal:me,computed:z,effect:O,reactive:E,batch:de,nextTick:G,initTree:L,destroyTree:H};on();an();$e(un);var le=un;window.Summit=le;function ln(){le.start();}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ln,{once:true}):ln();var ws=le;return ws;})();//# sourceMappingURL=summit.min.js.map
|
|
7
|
+
//# sourceMappingURL=summit.min.global.js.map
|