UNPKG

@lifeart/gxt

Version:

<img align="right" width="95" height="95" alt="Philosopher’s stone, logo of PostCSS" src="./public/logo.png">

2 lines (1 loc) • 30.4 kB
function e(t,n=/* @__PURE__ */new Set){return Object.keys(t.scope.bindings).forEach(e=>{n.add(e)}),t.parentPath&&e(t.parentPath,n),n}function t(){return{trackedDecoratorNames:/* @__PURE__ */new Set(["tracked"]),trackedDecoratorNamespaces:/* @__PURE__ */new Set,reactiveFactoryNames:/* @__PURE__ */new Set(["cell","formula"]),reactiveFactoryNamespaces:/* @__PURE__ */new Set,reactiveCellTypeNames:/* @__PURE__ */new Set(["Cell","MergedCell"]),reactiveCellTypeNamespaces:/* @__PURE__ */new Set}}function n(e){return e.importHintState||(e.importHintState=t()),e.importHintState}function r(e){return e.classHintStack||(e.classHintStack=[]),e.classHintStack}function o(e){const t=e.classHintStack;if(t&&0!==t.length)return t[t.length-1].typeHints}function i(e){return e.typeRegistry||(e.typeRegistry=/* @__PURE__ */new Map),e.typeRegistry}function s(e){return"Identifier"===e.type?e.name:`${s(e.left)}.${e.right.name}`}function a(e){return"Identifier"===e.type?e.name:a(e.left)}function l(e){return"Identifier"===e.type?e.name:"StringLiteral"===e.type?e.value:"NumericLiteral"===e.type?e.value+"":"TemplateLiteral"===e.type&&0===e.expressions.length?e.quasis[0]?.value.cooked??e.quasis[0]?.value.raw:void 0}function c(e){return"ExportNamedDeclaration"===e.type||"ExportDefaultDeclaration"===e.type?e.declaration:e}function p(e,t){return!(!e||0===e.length)&&e.some(e=>d(e.expression,t))}function d(e,t){if("Identifier"===e.type)return t.trackedDecoratorNames.has(e.name);if("CallExpression"===e.type){const n=e.callee;return"Super"!==n.type&&"V8IntrinsicIdentifier"!==n.type&&d(n,t)}return"MemberExpression"===e.type&&!e.computed&&"Identifier"===e.object.type&&"Identifier"===e.property.type&&t.trackedDecoratorNamespaces.has(e.object.name)&&"tracked"===e.property.name}function u(e){let t=e;for(;"TSParenthesizedType"===t.type;)t=t.typeAnnotation;return t}function f(e,t){return{kind:e,...void 0!==t?{literalValue:t}:{}}}function m(e,t,n){return{kind:e.kind,...t?{isTracked:!0}:{},...n?{isReadonly:!0}:{},...void 0!==e.literalValue?{literalValue:e.literalValue}:{}}}function y(e,t){return t.get(s(e))||t.get(a(e))}function g(e,t,n,r=/* @__PURE__ */new Set){const o=u(e);if("TSStringKeyword"===o.type||"TSNumberKeyword"===o.type||"TSBooleanKeyword"===o.type||"TSNullKeyword"===o.type||"TSUndefinedKeyword"===o.type||"TSVoidKeyword"===o.type)return f("primitive");if("TSLiteralType"===o.type)return"StringLiteral"===o.literal.type||"NumericLiteral"===o.literal.type||"BooleanLiteral"===o.literal.type?f("primitive",o.literal.value):f("primitive");if("TSFunctionType"===o.type||"TSConstructorType"===o.type)return f("function");if("TSArrayType"===o.type||"TSTupleType"===o.type||"TSTypeLiteral"===o.type||"TSObjectKeyword"===o.type||"TSMappedType"===o.type)return f("object");if("TSUnionType"===o.type)return function(e,t,n,r){const o=e.map(e=>g(e,t,n,r)),i=new Set(o.map(e=>e.kind));if(1===i.size){const e=o[0].kind;if("primitive"!==e)return f(e);const t=o.map(e=>e.literalValue).filter(e=>void 0!==e);return 1===t.length?f("primitive",t[0]):f("primitive")}return[...i].every(e=>"primitive"===e)?f("primitive"):f("unknown")}(o.types,t,n,r);if("TSIntersectionType"===o.type)return f("unknown");if("TSTypeOperator"===o.type)return"readonly"===o.operator?g(o.typeAnnotation,t,n,r):f("unknown");if("TSTypeReference"===o.type){const e=function(e){return"Identifier"===e.type?e.name:e.right.name}(o.typeName);if("Identifier"===o.typeName.type&&t.reactiveCellTypeNames.has(o.typeName.name)||"TSQualifiedName"===o.typeName.type&&t.reactiveCellTypeNamespaces.has(a(o.typeName))&&("Cell"===e||"MergedCell"===e)||"Cell"===e||"MergedCell"===e)return f("cell");const i=y(o.typeName,n);if(i){const e="TSTypeAliasDeclaration"===i.type?"alias:"+i.id.name:"interface:"+i.id.name;if(r.has(e))return f("unknown");r.add(e);const o="TSTypeAliasDeclaration"===i.type?g(i.typeAnnotation,t,n,r):function(e){return f(e.body.body.some(e=>"TSCallSignatureDeclaration"===e.type||"TSConstructSignatureDeclaration"===e.type)?"function":"object")}(i);return r.delete(e),o}if("Array"===e||"ReadonlyArray"===e||"Record"===e||"Map"===e||"Set"===e||"Promise"===e||"Date"===e||"RegExp"===e||e.endsWith("Element")||e.endsWith("Node")||e.endsWith("Event"))return f("object");if("Function"===e)return f("function");if("String"===e||"Number"===e||"Boolean"===e)return f("primitive")}return f("unknown")}function T(e){for(const t of e)if("TSPropertySignature"===t.type&&"Args"===l(t.key)&&"TSTypeAnnotation"===t.typeAnnotation?.type)return t.typeAnnotation.typeAnnotation}function h(e,t,n=/* @__PURE__ */new Set){const r=u(e);if("TSTypeLiteral"===r.type)return T(r.members);if("TSIntersectionType"!==r.type){if("TSTypeReference"===r.type){const e=y(r.typeName,t);if(!e)return;const o="TSTypeAliasDeclaration"===e.type?"alias:"+e.id.name:"interface:"+e.id.name;if(n.has(o))return;n.add(o);const i="TSTypeAliasDeclaration"===e.type?h(e.typeAnnotation,t,n):function(e,t,n){const r=T(e.body.body);if(r)return r;for(const o of e.extends??[]){if("Identifier"!==o.expression.type&&"TSQualifiedName"!==o.expression.type)continue;const e=h({type:"TSTypeReference",typeName:o.expression,typeParameters:o.typeParameters??null},t,n);if(e)return e}}(e,t,n);return n.delete(o),i}}else for(const o of r.types){const e=h(o,t,n);if(e)return e}}function S(e,t,n,r=/* @__PURE__ */new Set){const o=u(e);if("TSIntersectionType"===o.type){const e={};for(const i of o.types){const o=S(i,t,n,r);o&&Object.assign(e,o)}return Object.keys(e).length>0?e:void 0}if("TSTypeReference"===o.type){const e=y(o.typeName,n);if(!e)return;const i="TSTypeAliasDeclaration"===e.type?"alias:"+e.id.name:"interface:"+e.id.name;if(r.has(i))return;r.add(i);const s="TSTypeAliasDeclaration"===e.type?S(e.typeAnnotation,t,n,r):S({type:"TSTypeLiteral",members:e.body.body},t,n,r);return r.delete(i),s}if("TSTypeLiteral"!==o.type)return;const i={};for(const s of o.members){if("TSPropertySignature"!==s.type)continue;const e=l(s.key);if(!e)continue;if(!s.typeAnnotation||"TSTypeAnnotation"!==s.typeAnnotation.type)continue;const r=g(s.typeAnnotation.typeAnnotation,t,n);i[e]=m(r,!1,!0===s.readonly)}return Object.keys(i).length>0?i:void 0}function k(e,t,n){const r=e.superTypeParameters;if(!r||"TSTypeParameterInstantiation"!==r.type)return;const o=r.params[0];if(!o)return;const i=h(o,n);return i?S(i,t,n):void 0}function E(e,t){const r=k(e,n(t),i(t));return{typeHints:{properties:{},...r?{args:r}:{}}}}function R(s,a){return function(d){const{types:u}=d,y=e=>{const t=e.state??={};return t.templateFunctionNames||(t.templateFunctionNames=/* @__PURE__ */new Set),t.templateFunctionNames};return{name:"ast-transform",visitor:{VariableDeclarator(e,t){if("development"!==a)return;if(!t.tokensForHotReload)return;const n=t.tokensForHotReload;"Identifier"===e.node.id.type&&"existingTokensToReload"===e.node.id.name&&(e.node.init=u.arrayExpression(n.map(e=>u.stringLiteral(e))))},ExportNamedDeclaration(e,t){if("development"===a&&(t.tokensForHotReload||(t.tokensForHotReload=[]),e.node.declaration))if("VariableDeclaration"===e.node.declaration.type){const n=e.node.declaration.declarations;if(1===n.length){const e=n[0];"Identifier"===e.id.type&&t.tokensForHotReload.push(e.id.name)}}else if("ClassDeclaration"===e.node.declaration.type){const n=e.node.declaration;"Identifier"===n.id?.type&&t.tokensForHotReload.push(n.id.name)}else if("FunctionDeclaration"===e.node.declaration.type){const n=e.node.declaration;"Identifier"===n.id?.type&&t.tokensForHotReload.push(n.id.name)}},ExportDefaultDeclaration(e,t){if("development"===a&&(t.tokensForHotReload||(t.tokensForHotReload=[]),e.node.declaration))if("ClassDeclaration"===e.node.declaration.type&&e.node.declaration.id){const n=e.node.declaration;"Identifier"===n.id?.type&&t.tokensForHotReload.push(n.id.name+":default")}else if("FunctionDeclaration"===e.node.declaration.type&&e.node.declaration.id){const n=e.node.declaration;"Identifier"===n.id?.type&&t.tokensForHotReload.push(n.id.name+":default")}},ClassDeclaration:{enter(e,t){r(t).push(E(e.node,t))},exit(e,t){r(t).pop()}},ClassExpression:{enter(e,t){r(t).push(E(e.node,t))},exit(e,t){r(t).pop()}},ClassBody:{enter(e,t){t.isInsideClassBody=!0,1===e.node.body.length&&"ClassMethod"===e.node.body[0].type&&"Identifier"===e.node.body[0].key.type&&"$static"===e.node.body[0].key.name&&(t.isInsideClassBody=!1)},exit(e,t){t.isInsideClassBody=!1}},ClassProperty(e,t){if(e.node.static)return;const r=o(t),s=r?.properties;if(!r||!s)return;const a=l(e.node.key);if(a){const r=function(e,t,n){const r=p(e.decorators,t),o=!0===e.readonly,i=function(e,t,n){if(e.typeAnnotation&&"TSTypeAnnotation"===e.typeAnnotation.type)return g(e.typeAnnotation.typeAnnotation,t,n)}(e,t,n),s=e.value?function(e,t){const n=function(e){let t=e;for(;"TSAsExpression"===t.type||"TSTypeAssertion"===t.type||"TSNonNullExpression"===t.type||"ParenthesizedExpression"===t.type;)t=t.expression;return t}(e);if(function(e,t){if("CallExpression"!==e.type)return!1;const n=e.callee;return"Identifier"===n.type?t.reactiveFactoryNames.has(n.name):"MemberExpression"===n.type&&!n.computed&&"Identifier"===n.object.type&&"Identifier"===n.property.type&&t.reactiveFactoryNamespaces.has(n.object.name)&&("cell"===n.property.name||"formula"===n.property.name)}(n,t))return f("cell");if("ArrowFunctionExpression"===n.type||"FunctionExpression"===n.type)return f("function");if("ObjectExpression"===n.type||"ArrayExpression"===n.type)return f("object");if("TemplateLiteral"===n.type&&0===n.expressions.length){const e=n.quasis[0]?.value.cooked,t=n.quasis[0]?.value.raw;return f("primitive",e??t)}return function(e){return"StringLiteral"===e.type||"NumericLiteral"===e.type||"BooleanLiteral"===e.type?{kind:"primitive",literalValue:e.value}:"NullLiteral"===e.type||"Identifier"===e.type&&"undefined"===e.name?{kind:"primitive"}:"UnaryExpression"!==e.type||"NumericLiteral"!==e.argument.type||"-"!==e.operator&&"+"!==e.operator?void 0:{kind:"primitive",literalValue:"-"===e.operator?-e.argument.value:e.argument.value}}(n)}(e.value,t):void 0;return s?m(s,r,o):i?m(i,r,o):r?m(f("unknown"),!0,o):void 0}(e.node,n(t),i(t));r&&(s["this."+a]=r)}},ClassMethod(e){"Identifier"===e.node.key.type&&"$static"===e.node.key.name&&e.replaceWith(u.classProperty(u.identifier(J.$template),u.taggedTemplateExpression(u.identifier("hbs"),e.node.body.body[0].expression.arguments[0]),null,null,!0))},StaticBlock(e){const t=e.node.body;if(1===t.length&&"ExpressionStatement"===t[0].type){const n=t[0].expression;if("CallExpression"===n.type&&"Identifier"===n.callee.type&&"TemplateLiteral"===n.arguments[0]?.type){const t=y(e);("template"===n.callee.name||t.has(n.callee.name))&&e.replaceWith(u.classProperty(u.identifier(J.$template),u.taggedTemplateExpression(u.identifier("hbs"),n.arguments[0]),null,null,!0))}else"TaggedTemplateExpression"===n.type&&"Identifier"===n.tag.type&&"hbs"===n.tag.name&&e.replaceWith(u.classProperty(u.memberExpression(u.thisExpression(),u.identifier(J.$template)),n,null,null,!1,!0))}},CallExpression(e){if(e.node.callee&&"Identifier"===e.node.callee.type)if("scope"===e.node.callee.name)e.remove();else{const t=y(e);"template"===e.node.callee.name||t.has(e.node.callee.name)?e.replaceWith(u.taggedTemplateExpression(u.identifier("hbs"),e.node.arguments[0])):"formula"===e.node.callee.name?"production"===a&&2===e.node.arguments.length&&e.node.arguments.pop():"getRenderTargets"===e.node.callee.name&&"production"===a&&2===e.node.arguments.length&&e.node.arguments.pop()}},ImportDeclaration(e,t){if(function(e,t){const n=e.source.value,r=ne.has(n),o=re.has(n);if(r||o)for(const i of e.specifiers){if("ImportSpecifier"===i.type){const e="Identifier"===i.imported.type?i.imported.name:i.imported.value,n=i.local.name;r&&"tracked"===e&&t.trackedDecoratorNames.add(n),!o||"cell"!==e&&"formula"!==e||t.reactiveFactoryNames.add(n),!o||"Cell"!==e&&"MergedCell"!==e||t.reactiveCellTypeNames.add(n);continue}if("ImportNamespaceSpecifier"===i.type){const e=i.local.name;r&&t.trackedDecoratorNamespaces.add(e),o&&(t.reactiveFactoryNamespaces.add(e),t.reactiveCellTypeNamespaces.add(e))}}}(e.node,n(t)),"@ember/template-compiler"===e.node.source.value){const t=y(e);t.add("template"),e.node.source.value=Q,e.node.specifiers.forEach(e=>{"ImportSpecifier"===e.type?("template"===("Identifier"===e.imported.type?e.imported.name:void 0)&&t.add(e.local.name),e.local.name="hbs",e.imported.name="hbs"):e.local.name="hbs"})}},Program(e,n){n.importHintState=t(),n.classHintStack=[],n.typeRegistry=function(e){const t=/* @__PURE__ */new Map;for(const n of e.body){const e=c(n);e&&("TSTypeAliasDeclaration"!==e.type&&"TSInterfaceDeclaration"!==e.type||t.set(e.id.name,e))}return t}(e.node),(e.state??={}).templateFunctionNames=/* @__PURE__ */new Set;const r=/* @__PURE__ */new Set;for(const t of e.node.body)if("ImportDeclaration"===t.type)for(const e of t.specifiers)r.add(e.local.name);const o=Object.values(J).filter(e=>!r.has(e)).map(e=>u.importSpecifier(u.identifier(e),u.identifier(e)));o.length>0&&e.node.body.unshift(u.importDeclaration(o,u.stringLiteral(Q)))},ReturnStatement:{enter(e,t){t.isInsideReturnStatement=!0},exit(e,t){t.isInsideReturnStatement=!1}},TaggedTemplateExpression(t,n){if("Identifier"===t.node.tag.type&&"hbs"===t.node.tag.name){const r=t.node.quasi.quasis[0].value.raw,i=!0===n.isInsideClassBody,a=r.includes("this");let l=!0===i||a;!0===n.isInsideReturnStatement&&(l=!0);const c=t.node.quasi.quasis[0].loc,p=o(n),d=p?function(e){const t=e.properties&&Object.keys(e.properties).length>0?{...e.properties}:void 0,n=e.args&&Object.keys(e.args).length>0?{...e.args}:void 0,r=e.helperReturns&&Object.keys(e.helperReturns).length>0?{...e.helperReturns}:void 0;if(t||n||r)return{...t?{properties:t}:{},...n?{args:n}:{},...r?{helperReturns:r}:{}}}(p):void 0;s.push({template:r,flags:{hasThisAccess:l},bindings:e(t),lexicalScope:e=>t.scope.hasBinding(e),loc:c?{start:{line:c.start.line,column:c.start.column,offset:t.node.quasi.quasis[0].start??c.start.offset},end:{line:c.end.line,column:c.end.column,offset:t.node.quasi.quasis[0].end??c.end.offset}}:void 0,typeHints:d}),t.replaceWith(u.identifier("$placeholder"))}}}}}}function I(e){const{types:t}=e;return{name:"string-gxt-debug-info-transform",visitor:{BinaryExpression(e){t.isLiteral(e.node.right)&&"/tests.html"===e.node.right.value&&e.replaceWith(t.booleanLiteral(!1))},ClassMethod(e){"constructor"===e.node.kind&&2===e.node.params.length&&"debugName"===e.node.params[1].name&&e.node.params.pop()},ExpressionStatement(e){e.node.expression&&"CallExpression"===e.node.expression.type&&"MemberExpression"===e.node.expression.callee.type&&"console"===e.node.expression.callee.object.name&&e.remove()},ClassProperty(e){"_debugName"===e.node.key.name&&e.remove()},FunctionDeclaration(e){const t=e.node.id.name;"formula"!==t&&"cell"!==t||e.node.params.pop()},AssignmentPattern(e){"debugName"===e.node.left.name&&e.remove()},NewExpression(e){e.node.callee&&"Identifier"===e.node.callee.type&&("MergedCell"!==e.node.callee.name&&"Cell"!==e.node.callee.name||e.node.arguments.pop())},CallExpression(e){if(e.node.callee&&"Identifier"===e.node.callee.type){const t=e.node.callee.name;"addToTree"===t&&3===e.node.arguments.length?e.node.arguments.pop():"cell"!==t&&"formula"!==t&&"resolveRenderable"!==t||2===e.node.arguments.length&&e.node.arguments.pop()}}}}}function v(e){const t=e.replace(/\\/g,"/");return te.sys.useCaseSensitiveFileNames?t:t.toLowerCase()}function N(e,t){if(!e)return;let n=e;return 0!==(n.flags&te.SymbolFlags.Alias)&&(n=t.getAliasedSymbol(n)),n.getName()}function x(e,t){return te.isIdentifier(e)?"tracked"===e.text||"tracked"===N(t.getSymbolAtLocation(e),t):te.isCallExpression(e)?x(e.expression,t):!!te.isPropertyAccessExpression(e)&&("tracked"===e.name.text||"tracked"===N(t.getSymbolAtLocation(e.name),t))}function b(e,t){if(!te.canHaveDecorators(e))return!1;const n=te.getDecorators(e);return!(!n||0===n.length)&&n.some(e=>x(e.expression,t))}function C(e){return te.canHaveModifiers(e)&&(te.getModifiers(e)?.some(e=>e.kind===te.SyntaxKind.ReadonlyKeyword)??!1)}function A(e){return 0!==(e.flags&te.TypeFlags.StringLiteral)||0!==(e.flags&te.TypeFlags.NumberLiteral)?e.value:0!==(e.flags&te.TypeFlags.BooleanLiteral)?"true"===e.intrinsicName:void 0}function _(e,t){const n=N(e.aliasSymbol??e.getSymbol(),t);if("Cell"===n||"MergedCell"===n)return!0;if(e.isUnion())return e.types.some(e=>_(e,t));const r=t.typeToString(e);return r.includes("Cell<")||r.includes("MergedCell<")||"Cell"===r||"MergedCell"===r}function M(e,t){if(e.isUnion()){const n=e.types.map(e=>M(e,t)),r=function(e){const t=new Set(e);return 1===t.size?e[0]:[...t].every(e=>"primitive"===e)?"primitive":"unknown"}(n.map(e=>e.kind));if("primitive"!==r)return{kind:r};const o=n.map(e=>e.literalValue).filter(e=>void 0!==e);return 1===o.length?{kind:r,literalValue:o[0]}:{kind:r}}if(_(e,t))return{kind:"cell"};const n=te.TypeFlags.StringLike|te.TypeFlags.NumberLike|te.TypeFlags.BooleanLike|te.TypeFlags.Null|te.TypeFlags.Undefined|te.TypeFlags.Void|te.TypeFlags.BigIntLike;return 0!==(e.flags&n)?{kind:"primitive",literalValue:A(e)}:t.getSignaturesOfType(e,te.SignatureKind.Call).length>0?{kind:"function"}:0!==(e.flags&te.TypeFlags.Object)?{kind:"object"}:{kind:"unknown"}}function O(e,t){return{kind:e.kind,...void 0!==e.literalValue?{literalValue:e.literalValue}:{},...t.isTracked?{isTracked:!0}:{},...t.isReadonly?{isReadonly:!0}:{}}}function w(e){if(e)return te.isIdentifier(e)||te.isPrivateIdentifier(e)||te.isStringLiteralLike(e)||te.isNumericLiteral(e)?e.text:void 0}function D(e,t){return{kind:"unknown"===t.kind&&"unknown"!==e.kind?e.kind:t.kind,...!0===t.isTracked||!0===e.isTracked?{isTracked:!0}:{},...!0===t.isReadonly||!0===e.isReadonly?{isReadonly:!0}:{},...void 0!==(t.literalValue??e.literalValue)?{literalValue:t.literalValue??e.literalValue}:{}}}function L(e,t){if(!e&&!t)return;if(!e)return t;if(!t)return e;const n={...e};for(const[r,o]of Object.entries(t))n[r]=r in n?D(n[r],o):o;return n}function F(e,t){const n=L(e?.properties,t?.properties),r=L(e?.args,t?.args),o=L(e?.helperReturns,t?.helperReturns);if(n||r||o)return{...n?{properties:n}:{},...r?{args:r}:{},...o?{helperReturns:o}:{}}}function H(e){const t=[0];for(let n=0;n<e.length;n++)"\n"===e[n]&&t.push(n+1);return t}function j(e){const t=e.lastIndexOf("/");return-1!==t?e.slice(t+1):e}function $(e){return e.every(e=>{if("ElementNode"===e.type)return function(e){const t=e.tag;return!t.includes(".")&&!t.startsWith(":")&&t.toLowerCase()===t}(e)&&$(e.children);if("TextNode"===e.type)return!0;if("MustacheCommentStatement"===e.type)return!0;if("CommentStatement"===e.type)return!0;if("MustacheStatement"===e.type){if("PathExpression"!==e.path.type)return!1;if("yield"===e.path.original||"outlet"===e.path.original)return!1;if("AtHead"===e.path.head?.type)return!0}return!1})}function P(e,t,n){e.sourceRange.start+=t,e.sourceRange.end+=t,e.generatedRange.start+=n,e.generatedRange.end+=n;for(const r of e.children)P(r,t,n)}function W(e,t){e.generatedRange.start+=t,e.generatedRange.end+=t;for(const n of e.children)W(n,t)}function V(e){const t=/\bconst\s+roots\s*=\s*/.exec(e);return t?t.index+t[0].length:-1}function B(e,t,n,r,o,i,s=!1){const a=e?.code??"",l=n,c=[];t.forEach(e=>{const t=e.flags,n=e.bindings,o=X(e.template,{bindings:n,filename:r,lexicalScope:e.lexicalScope,flags:{...l,IS_GLIMMER_COMPAT_MODE:l.IS_GLIMMER_COMPAT_MODE??!0,WITH_TYPE_OPTIMIZATION:!!e.typeHints},format:!!s&&{enabled:!0,baseIndent:" "},diagnostics:{baseOffset:e.loc?.start.offset},typeHints:e.typeHints});if(o.errors.length>0){const e=o.errors[0],t=Z(e);throw Error(t)}$(q(e.template).body)||!1!==t.hasThisAccess||(t.hasThisAccess=!0),c.push({code:o.code,mapping:o.mappingTree,originalSource:e.template,originalLoc:e.loc,flags:t})}),c.forEach(e=>{const t=a?.includes("template = ")??!1,n=r.endsWith(".gts")||r.endsWith(".gjs");let i="";const s=(e.flags.hasThisAccess,"this"),l=e.code.includes("$fw"),c=e.code.includes("$slots"),p=/\$a[\.\[]/.test(e.code),d=`const $slots = ${J.$_GET_SLOTS}(this, arguments);`,u=l?`const $fw = ${J.$_GET_FW}(this, arguments);`:"",f=c?d:"",m=p?`const $a = this[${J.$args}];`:"",y=`const roots = ${e.code};`,g=`return ${J.FINALIZE_COMPONENT}(roots, ${s});`;i=n?`function () {\n ${u}\n ${J.$_GET_ARGS}(this, arguments);\n ${m}\n ${f}\n ${y}\n ${g}\n }`:t?`() => {\n ${f}\n ${u}\n ${p?`const $a = this[${J.$args}];`:""}\n ${y}\n ${g}\n }`:`(() => {\n ${J.$_GET_ARGS}(this, arguments);\n ${m}\n ${f}\n ${u}\n ${y}\n ${g}\n })()`,o.push(i)});let p=a??"";const d=[];o.forEach((e,t)=>{const n=p.indexOf("$placeholder");-1!==n&&(d.push({start:n,end:n+e.length,templateIndex:t}),p=p.replace("$placeholder",e))});const u=p.split("").join("");let f=null;if(c.length>0&&i){const e=function(e){return Array.isArray(e)?e.filter(e=>{const t=e?.contentRange;return"string"==typeof e?.contents&&"number"==typeof t?.startUtf16Codepoint}):[]}(se.parse(i,{filename:r})),t=[];if(c.forEach((n,r)=>{const s=d[r];if(!s)return;const a=e[r];if(a){const e=function(e,t,n){const r=function(e){const t=e.split("\n").map(e=>e.endsWith("\r")?e.slice(0,-1):e);let n=0;for(;n<t.length&&""===t[n].trim();)n+=1;let r=t.length-1;for(;r>=n&&""===t[r].trim();)r-=1;const o=t.slice(n,r+1);let i=1/0;for(const s of o){if(""===s.trim())continue;const e=s.match(/^[ \t]*/),t=e?e[0].length:0;t<i&&(i=t)}return Number.isFinite(i)||(i=0),{stripped:o.map(e=>e.slice(Math.min(i,e.length))).join("\n"),startLine:n,minIndent:i,rawLines:t,rawLineOffsets:H(e)}}(n.contents);if(r.stripped!==t)return null;const o=JSON.parse(JSON.stringify(e)),i=H(t),s=e=>{const{line:t,column:o}=function(e,t){let n=0,r=e.length-1;for(;n<=r;){const o=n+r>>1,i=e[o],s=e[o+1]??1/0;if(t<i)r=o-1;else{if(!(t>=s))return{line:o,column:t-i};n=o+1}}const o=e.length-1;return{line:o,column:Math.max(0,t-e[o])}}(i,e),s=r.startLine+t;if(s>=r.rawLines.length)return null;const a=r.rawLines[s];let l=o+r.minIndent;l>a.length&&(l=a.length);const c=r.rawLineOffsets[s]+l;return n.contentRange.startUtf16Codepoint+c},a=e=>{const t=s(e.sourceRange.start),n=s(e.sourceRange.end);if(null===t||null===n)return!1;e.sourceRange.start=t,e.sourceRange.end=n;for(const r of e.children)if(!a(r))return!1;return!0};return a(o)?o:null}(n.mapping,n.originalSource,a);if(e){const n=V(o[r]);if(-1!==n)return W(e,s.start+n),void t.push(e)}}let l=-1;const c=/<template[^>]*>([\s\S]*?)<\/template>/g;let p,u=0;for(;null!==(p=c.exec(i));){if(u===r){l=p.index+p[0].indexOf(">")+1;break}u++}if(-1===l){const e=/hbs\s*`([^`]*)`/g;for(u=0;null!==(p=e.exec(i));){if(u===r){l=p.index+p[0].indexOf("`")+1;break}u++}}if(-1===l&&n.originalLoc&&(l=function(e,t,n){const r=e.split("\n");let o=0;for(let i=0;i<t-1&&i<r.length;i++)o+=r[i].length+1;return o+n}(i,n.originalLoc.start.line,n.originalLoc.start.column)),-1!==l){const e=JSON.parse(JSON.stringify(n.mapping)),i=V(o[r]);-1!==i&&(P(e,l,s.start+i),t.push(e))}}),t.length>0){const e=j(r),n=e.replace(".gts",".js").replace(".gjs",".js"),o=1===t.length?t[0]:{sourceRange:{start:0,end:i.length},generatedRange:{start:0,end:u.length},children:t,sourceNode:"Template"};f=ee(o,i,u,{file:e,includeContent:!0,sourceContent:i}),f.file=n}}if(!f&&e?.map){const t=j(r);f={version:3,file:t.replace(".gts",".js").replace(".gjs",".js").replace(".ts",".js"),sources:[t],sourcesContent:i?[i]:e.map.sourcesContent,names:e.map.names,mappings:e.map.mappings}}return{code:u,map:f}}function K(e,t,n,r=!1,o={IS_GLIMMER_COMPAT_MODE:!0,RUN_EVENT_DESTRUCTORS_FOR_SCOPED_NODES:!1,TRY_CATCH_ERROR_HANDLING:!0,SUPPORT_SHADOW_DOM:!0,REACTIVE_MODIFIERS:!0,WITH_HELPER_MANAGER:!1,WITH_MODIFIER_MANAGER:!1,WITH_EMBER_INTEGRATION:!1,WITH_CONTEXT_API:!0,ASYNC_COMPILE_TRANSFORMS:!0,WITH_DYNAMIC_EVAL:!1,WITH_TYPE_CHECKER_HINTS:!1},i){const s=e,a=[],l=[],c=o.ASYNC_COMPILE_TRANSFORMS,p=[R(a,n)];r||p.push("module:decorator-transforms");const d=t.replace(".gts",".ts").replace(".gjs",".js"),u={plugins:p,filename:d,presets:[["@babel/preset-typescript",{allExtensions:!0,onlyRemoveTypeImports:!0,allowDeclareFields:!0}]],sourceMaps:!0,sourceFileName:t},f=i||s,m=se.process(s,{filename:t}).code,y=!0===o.WITH_TYPE_CHECKER_HINTS&&(t.endsWith(".gts")||t.endsWith(".gjs"))?function(e,t){const n=function(e,t){return`${e}::${t}`}(t,e),r=oe.get(n);if(r)return r;try{const r=function(e,t){const n=function(){if(ie)return ie;const e=te.findConfigFile(process.cwd(),te.sys.fileExists,"tsconfig.json");if(e){const t=te.readConfigFile(e,te.sys.readFile);if(!t.error){const e=te.parseJsonConfigFileContent(t.config,te.sys,process.cwd());return ie={...e.options,noEmit:!0},ie}}return ie={target:te.ScriptTarget.ES2020,module:te.ModuleKind.ESNext,moduleResolution:te.ModuleResolutionKind.Bundler,allowJs:!0,skipLibCheck:!0,strict:!0,noEmit:!0,experimentalDecorators:!0},ie}(),r=te.createCompilerHost(n,!0),o=v(t),i=r.getSourceFile.bind(r),s=r.readFile.bind(r),a=r.fileExists.bind(r);return r.fileExists=e=>v(e)===o||a(e),r.readFile=t=>v(t)===o?e:s(t),r.getSourceFile=(t,n,r,s)=>v(t)===o?te.createSourceFile(t,e,n,!0,te.ScriptKind.TS):i(t,n,r,s),te.createProgram({rootNames:[t],options:n,host:r})}(e,t),o=r.getSourceFile(t);if(!o){const e=[];return oe.set(n,e),e}const i=r.getTypeChecker(),s=function(e){const t=/* @__PURE__ */new Set;for(const n of e.statements){if(!te.isImportDeclaration(n))continue;if(!te.isStringLiteral(n.moduleSpecifier))continue;if("@ember/template-compiler"!==n.moduleSpecifier.text)continue;const e=n.importClause;if(e&&e.namedBindings&&te.isNamedImports(e.namedBindings))for(const n of e.namedBindings.elements)("template"===n.propertyName?.text||!n.propertyName&&"template"===n.name.text)&&t.add(n.name.text)}return t}(o);if(0===s.size){const e=[];return oe.set(n,e),e}const a=[],l=/* @__PURE__ */new Map,c=e=>{if(te.isCallExpression(e)&&function(e,t){return te.isIdentifier(e.expression)&&t.has(e.expression.text)}(e,s)){const t=function(e){let t=e.parent;for(;t;){if(te.isClassDeclaration(t)||te.isClassExpression(t))return t;t=t.parent}}(e);t?(l.has(t)||l.set(t,function(e,t){const n=function(e,t){const n={};for(const r of e.members){if(!te.isPropertyDeclaration(r))continue;if(r.modifiers?.some(e=>e.kind===te.SyntaxKind.StaticKeyword))continue;const e=w(r.name);if(!e||e.startsWith("#"))continue;const o=b(r,t),i=C(r),s=r.type?t.getTypeFromTypeNode(r.type):r.initializer?t.getTypeAtLocation(r.initializer):t.getTypeAtLocation(r);if(!s){o&&(n["this."+e]=O({kind:"unknown"},{isTracked:o,isReadonly:i}));continue}const a=M(s,t);("unknown"!==a.kind||o)&&(n["this."+e]=O(a,{isTracked:o,isReadonly:i}))}return Object.keys(n).length>0?n:void 0}(e,t),r=function(e,t){const n=e.heritageClauses?.find(e=>e.token===te.SyntaxKind.ExtendsKeyword),r=n?.types[0]?.typeArguments?.[0];if(!r)return;const o=t.getTypeFromTypeNode(r),i=t.getPropertyOfType(o,"Args");if(!i)return;const s=t.getTypeOfSymbolAtLocation(i,r),a=t.getPropertiesOfType(s);if(0===a.length)return;const l={};for(const c of a){const e=c.getName(),n=c.valueDeclaration??c.declarations?.[0],o=M(t.getTypeOfSymbolAtLocation(c,n??r),t);if("unknown"===o.kind)continue;const i=!!n&&C(n);l[e]=O(o,{isReadonly:i})}return Object.keys(l).length>0?l:void 0}(e,t);if(n||r)return{...n?{properties:n}:{},...r?{args:r}:{}}}(t,i)),a.push(l.get(t))):a.push(void 0)}te.forEachChild(e,c)};return c(o),oe.set(n,a),a}catch{const e=[];return oe.set(n,e),e}}(m,d):[];if(c)return Y(m,u).then(e=>{if(y.length>0)for(let t=0;t<a.length&&t<y.length;t++)a[t].typeHints=F(y[t],a[t].typeHints);return B(e,a,o,t,l,f,"development"===n)});{const e=z(m,u);if(y.length>0)for(let t=0;t<a.length&&t<y.length;t++)a[t].typeHints=F(y[t],a[t].typeHints);return B(e,a,o,t,l,f,"development"===n)}}function G(e,t={}){let n=!1,r={IS_GLIMMER_COMPAT_MODE:!0,RUN_EVENT_DESTRUCTORS_FOR_SCOPED_NODES:!1,TRY_CATCH_ERROR_HANDLING:!0,SUPPORT_SHADOW_DOM:!0,REACTIVE_MODIFIERS:!0,WITH_HELPER_MANAGER:!1,WITH_MODIFIER_MANAGER:!1,WITH_EMBER_INTEGRATION:!1,WITH_CONTEXT_API:!0,ASYNC_COMPILE_TRANSFORMS:!0,WITH_DYNAMIC_EVAL:!1,WITH_TYPE_CHECKER_HINTS:!1};return{enforce:"pre",name:"glimmer-next",config(e,o){!0===t.authorMode&&(n=void 0!==e.build?.lib),r={...r,...t.flags??{}};let i=r;return n?i={IS_DEV_MODE:!1}:i.IS_DEV_MODE="development"===o.mode,{define:i,resolve:{extensions:le}}},transform(o,i){if(ce.test(i)){const s=ae.process(o,{filename:i}).code;if("development"===e){const a=!t.disableHMR&&function(e,t){const n=e.endsWith(".gts")||e.endsWith(".gjs"),r=!e.includes("-test"),o=t.includes("<template>");return n&&r&&o}(i,o);return K(function(e){return e.split("export const ").join("export let ")}(s)+(a?"\nif (import.meta.hot) {\n const existingTokensToReload: string[] = [];\n const evalMap = {};\n const internalTokensToReload = existingTokensToReload.map((t) => {\n const [key, value] = t.split(':');\n evalMap[key] = value || key;\n return key;\n });\n import.meta.hot.accept((newModule) => {\n if (newModule) {\n const moduleTokens = Object.keys(newModule);\n const newTokens = moduleTokens.filter(\n (token) => !(internalTokensToReload.includes(token) || Array.from(Object.values(evalMap)).includes(token)),\n );\n if (\n newTokens.length ||\n moduleTokens.length !== internalTokensToReload.length\n ) {\n import.meta.hot?.invalidate();\n } else {\n moduleTokens.forEach((token) => {\n const oldModule = internalTokensToReload.find((t) => evalMap[t] === token);\n if (oldModule) {\n window.hotReload(eval(oldModule), newModule[token]);\n }\n });\n internalTokensToReload.length = 0;\n internalTokensToReload.push(...moduleTokens);\n }\n }\n });\n}\n":""),i,e,n,r,o)}return K(s,i,e,n,r,o)}if(/hbs\s*`/.test(o)&&pe.test(i))try{const t=K(o,i,e,!1,r,o);return t&&"function"==typeof t.then?t.then(e=>e,()=>{}):t}catch{return}}}}import{Preprocessor as U}from"content-tag";import{preprocess as q}from"@glimmer/syntax";import{transformAsync as Y,transformSync as z}from"@babel/core";import{S as J,M as Q}from"./symbols-CMiKXAxp.js";import{c as X,f as Z,g as ee}from"./compile-CP5JuT5D.js";import*as te from"typescript";const ne=/* @__PURE__ */new Set([Q,"@glimmer/tracking"]),re=/* @__PURE__ */new Set([Q]),oe=/* @__PURE__ */new Map;let ie;const se=new U,ae=new U,le=[".mjs",".js",".mts",".ts",".jsx",".tsx",".json",".gts",".gjs"],ce=/\.(gts|gjs)$/,pe=/\.(ts|js)$/;export{G as compiler,I as stripGXTDebug};