UNPKG

khulnasoft.com

Version:

Development tools for Khulnasoft CMS integration

22 lines (20 loc) 204 kB
"use strict";var ci=Object.create;var Rt=Object.defineProperty;var mi=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,gi=Object.prototype.hasOwnProperty;var Ie=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Di=(e,t)=>{for(var r in t)Rt(e,r,{get:t[r],enumerable:!0})},Jn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fi(t))!gi.call(e,o)&&o!==r&&Rt(e,o,{get:()=>t[o],enumerable:!(n=mi(t,o))||n.enumerable});return e};var Qn=(e,t,r)=>(r=e!=null?ci(di(e)):{},Jn(t||!e||!e.__esModule?Rt(r,"default",{value:e,enumerable:!0}):r,e)),Ci=e=>Jn(Rt({},"__esModule",{value:!0}),e);var Gn=Ie((Mu,Yn)=>{"use strict";Yn.exports=function(){if(process.env.npm_config_user_agent)return hi(process.env.npm_config_user_agent)};function hi(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var vn=Ie(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});function Io(e){return Object.prototype.toString.call(e)}Qt.getType=Io;function ou(e){throw new TypeError("unsupported data type: "+Io(e))}Qt.throwUnknownDataType=ou});var On=Ie(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var ke="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);ke+=t}var lt=ke.length,Rn={};for(let e=0;e<lt;e++){let t=ke[e];Rn[t]=e}function Nn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=Rn[o];i*=r,t+=i,r*=lt}return t}Le.s_to_int=Nn;function Ro(e){let t=BigInt(0),r=BigInt(1),n=BigInt(lt);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(Rn[i]);a*=r,t+=a,r*=n}return t}Le.s_to_big_int=Ro;function Bn(e){if(e===0)return ke[0];let t=[];for(;e!==0;){let r=e%lt,n=ke[r];t.push(n),e-=r,e/=lt}return t.reverse().join("")}Le.int_to_s=Bn;function No(e){let t=BigInt(0),r=BigInt(lt);if(e===t)return ke[0];let n=[];for(;e!==t;){let o=e%r,i=ke[Number(o)];n.push(i),e-=o,e/=r}return n.reverse().join("")}Le.big_int_to_s=No;function Yt(e){return e.split("").reverse().join("")}function Bo(e){if(e<0)return"-"+Bo(-e);let[t,r]=e.toString().split(".");if(!r)return Bn(e);let n;r&&([r,n]=r.split("e")),t=Wt(t),r=Yt(r),r=Wt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Yt(n),n=Wt(n),o+=n}return o}Le.num_to_s=Bo;function Wt(e){let t=+e;return t.toString()===e?Bn(t):":"+No(BigInt(e))}Le.int_str_to_s=Wt;function In(e){return e[0]===":"?Ro(e.substring(1)).toString():Nn(e).toString()}function Oo(e){if(e[0]==="-")return-Oo(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Nn(t);t=In(t),r=In(r),r=Yt(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=In(n),n=Yt(n),o+=i?-n:+n}return+o}Le.s_to_num=Oo});var Ln=Ie(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});var kn=On();function iu(e){return"n|"+kn.num_to_s(e)}_e.encodeNum=iu;function au(e){return e=e.replace("n|",""),kn.s_to_num(e)}_e.decodeNum=au;function su(e){return typeof e=="number"?e:kn.s_to_int(e)}_e.decodeKey=su;function uu(e){return e?"b|T":"b|F"}_e.encodeBool=uu;function pu(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}_e.decodeBool=pu;function lu(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}_e.encodeStr=lu;function cu(e){return e[0]+e[1]==="s|"?e.substr(2):e}_e.decodeStr=cu});var ko=Ie(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.config={sort_key:!1}});var Vn=Ie(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});var mu=ko(),fu=vn(),jn=Ln(),du=On();function gu(e){return e.store.toArray()}Xe.memToValues=gu;function Lo(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}Xe.makeInMemoryStore=Lo;function _o(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}Xe.makeInMemoryCache=_o;function Du(){return{store:Lo(),cache:_o(),keyCount:0}}Xe.makeInMemoryMemory=Du;function He(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=du.num_to_s(r);return e.store.add(t),e.cache.setValue(t,n),n}function Cu(e,t){mu.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=Tt(e,t,void 0);return e.cache.setSchema(r,n),n}function Tt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return Tt(e,null,r);break;case"object":if(t===null)return He(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":Tt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),He(e,n)}else{let n=Object.keys(t);if(n.length===0)return He(e,"o|");let o="o",i=Cu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=Tt(e,s,t);o+="|"+u}return He(e,o)}case"boolean":return He(e,jn.encodeBool(t));case"number":return He(e,jn.encodeNum(t));case"string":return He(e,jn.encodeStr(t))}return fu.throwUnknownDataType(t)}Xe.addValue=Tt});var Kn=Ie(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});var xu=vn(),Gt=Ln(),$n=Vn();function hu(e){let t=$n.makeInMemoryMemory(),r=$n.addValue(t,e,void 0);return[$n.memToValues(t),r]}vt.compress=hu;function Eu(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=bt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=bt(e,p),r[u]=p}return r}function Su(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=bt(e,a),o[i]=a}return o}function bt(e,t){if(t===""||t==="_")return null;let r=Gt.decodeKey(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return Gt.decodeBool(n);case"o|":return Eu(e,n);case"n|":return Gt.decodeNum(n);case"a|":return Su(e,n);default:return Gt.decodeStr(n)}}return xu.throwUnknownDataType(n)}vt.decode=bt;function Au(e){let[t,r]=e;return bt(t,r)}vt.decompress=Au});var Vo=Ie(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});function Fu(e){for(let t in e)e[t]===void 0&&delete e[t]}Ht.trimUndefined=Fu;function Pu(e){jo(e,new Set)}Ht.trimUndefinedRecursively=Pu;function jo(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&jo(n,t)}}});var Mo=Ie(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});var $o=Kn();ze.compress=$o.compress;ze.decompress=$o.decompress;var yu=Kn();ze.decode=yu.decode;var wu=Vn();ze.addValue=wu.addValue;var Ko=Vo();ze.trimUndefined=Ko.trimUndefined;ze.trimUndefinedRecursively=Ko.trimUndefinedRecursively});var Vu={};Di(Vu,{createDevTools:()=>Jo,createDevToolsSys:()=>Wo,detectFrameworks:()=>je,detectFrameworksFromPackageJson:()=>en,ensureConfigPlugin:()=>ui,findBuildToolConfig:()=>qn,getClientScript:()=>li,parseDotEnvContent:()=>tn,version:()=>It});module.exports=Ci(Vu);function re(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var xi=["node_modules","dist","build","public"];async function ae(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(xi.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("khulnasoft-registry."))return u;if(p.isDirectory()){let m=await r(u,i+1);if(m)return m}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`khulnasoft-registry.${await re(e)?"ts":"js"}`;return e.join(t,i)}return n}async function ct(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function Wn(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function mt(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await mt(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var Xn=Qn(Gn(),1);function ge(e){return e.endsWith(".mapper.tsx")||e.endsWith(".mapper.jsx")}function B(e,t,r){t=ce(t),r=ce(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=ce(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function ce(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function Je(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return Hn(o==="index"?e.basename(e.dirname(t)):o)}function Hn(e){return K(e).replace(/ /g,"")}function se(e,t){let r=e.extname(t),n=ce(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function V(e,t){let r=ce(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function te(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function $(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function ft(e){return typeof e=="number"}function Ze(e){return typeof e=="boolean"}function Z(e){return typeof e=="string"}function et(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function oe(e){return JSON.parse(JSON.stringify(e))}function Nt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function Zn(){try{let e=(0,Xn.default)();if(e?.name)return e.name}catch{}return"npm"}async function je(e){let t=[],r=await ct(e,e.getRepoRootDir());if(r){let n=await en(r,e);t.push(...n)}return t}async function tr(e){let t=await ct(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function en(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Ei)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};er.has(o)&&(i.version=await er.get(o)(t)),r.push(i)}}return r}function Zt(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var er=new Map([["next",async e=>{if(!e.spawnSync)return;let t=Zn(),r=t==="npm"?"npx":t,{stdout:n}=e.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:Zt(a),minor:Zt(s),patch:Zt(u)}}]]),Ei=["@shopify/remix-oxygen","@shopify/hydrogen","@khulnasoft.com/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@khulnasoft.com/qwik","@angular/core","react","solid-js","svelte","vue"];async function De(e){let t=nr(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function Ce(e,t){t=typeof t=="object"&&t!=null?t:{};let r=nr(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function nr(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".khulnasoft","khulnasoft-cache.json")}async function Ve(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Si(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function Si(e,t){let r=await e.readFile(t);return typeof r=="string"?tn(r):null}function tn(e){let t={},r=e.replace(/\r\n?/gm,` `),n;for(;(n=Ai.exec(r))!=null;){let o=n[1],i=n[2]||"";i=i.trim();let a=i[0];i=i.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),a==='"'&&(i=i.replace(/\\n/g,` `),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var Ai=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;async function $e(e,t,r,n){let o="# https://www.khulnasoft.com/c/docs/using-your-api-key",i=await e.readFile(t);if(i)if(i.includes(r))if(i.includes(n))e.debug(`"${r}" with "${n}" already set in ${t}`);else return e.debug(`Replace "${r}" in ${t}`),i=i.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await e.writeFile(t,i),"update";else return e.debug(`Append "${r}" to ${t}`),i+=` ${o} ${r}=${n} `,await e.writeFile(t,i),"update";else return e.debug(`Creating new .env file with "${r}" at ${t}`),i=[o,`${r}=${n}`,""].join(` `),await e.writeFile(t,i),"create";return null}async function dt(e){return await Ve(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],xe)}async function rr(e,t){let r=await dt(e),n=await $e(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var xe="NEXT_PUBLIC_KHULNASOFT_API_KEY";var w={gen1:"Gen 1",gen2:"Gen 2"};function I(e,t=""){return e.ts.createSourceFile("module.tsx",typeof t=="string"?t:"",e.ts.ScriptTarget.Latest,void 0)}function Bt(e,t=""){let r=I(e,t?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${t}`);return r.statements[0]}function _(e,t,r){if(t){let n=e.ts.createPrinter({newLine:e.ts.NewLineKind.LineFeed,removeComments:r});return e.ts.isSourceFile(t)?n.printFile(t).trim()+` `:n.printNode(e.ts.EmitHint.Unspecified,t,e.ts.createSourceFile("module.tsx","",e.ts.ScriptTarget.Latest)).trim()+` `}return""}function tt(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=Fi(e,t,r);return a>-1?n==null&&o?e.ts.factory.updateObjectLiteralExpression(t,i.filter((s,u)=>u!==a)):(i[a]=e.ts.factory.updatePropertyAssignment(i[a],i[a].name,gt(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,gt(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function Fi(e,t,r){return t.properties.findIndex(n=>N(e,n)===r)}function Dt(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return yi(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return Pi(e,t);case e.ts.SyntaxKind.StringLiteral:return t.text;case e.ts.SyntaxKind.NumericLiteral:return Number(t.text);case e.ts.SyntaxKind.NoSubstitutionTemplateLiteral:return t.text;case e.ts.SyntaxKind.TrueKeyword:return!0;case e.ts.SyntaxKind.FalseKeyword:return!1;case e.ts.SyntaxKind.Identifier:switch(t.escapedText){case"undefined":return;case"null":return null;case"String":return String;case"Number":return Number;case"Boolean":return Boolean;case"NaN":return NaN}}}function Pi(e,t){let r={};if(t&&e.ts.isObjectLiteralExpression(t)){for(let n of t.properties)if(e.ts.isPropertyAssignment(n)){let o=N(e,n);o&&(r[o]=Dt(e,n.initializer))}}return r}function yi(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>Dt(e,r)):[]}function N(e,t){if(t&&e.ts.isPropertyAssignment(t)){let r=t.name;switch(r.kind){case e.ts.SyntaxKind.Identifier:return r.text;case e.ts.SyntaxKind.StringLiteral:case e.ts.SyntaxKind.NumericLiteral:return r.text;case e.ts.SyntaxKind.ComputedPropertyName:let n=r.expression;if(e.ts.isStringLiteral(n)||e.ts.isNumericLiteral(n))return r.expression.text}}}function gt(e,t){return nn(e,t,new WeakSet)}function nn(e,t,r){return t===void 0?e.ts.factory.createIdentifier("undefined"):t===null?e.ts.factory.createIdentifier("null"):typeof t=="string"?e.ts.factory.createStringLiteral(t):typeof t=="number"?isNaN(t)?e.ts.factory.createIdentifier("NaN"):e.ts.factory.createNumericLiteral(t):t===!0?e.ts.factory.createTrue():t===!1?e.ts.factory.createFalse():t===String?e.ts.factory.createIdentifier("String"):t===Number?e.ts.factory.createIdentifier("Number"):t===Boolean?e.ts.factory.createIdentifier("Boolean"):Array.isArray(t)?wi(e,t,r):typeof t=="object"?Ti(e,t,r):e.ts.factory.createIdentifier(t)}function wi(e,t,r){let n=t.map(o=>nn(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Ti(e,t,r){if(r.has(t))return e.ts.factory.createIdentifier("undefined");r.add(t);let n=Object.keys(t).map(o=>e.ts.factory.createPropertyAssignment(o,nn(e,t[o],r)));return e.ts.factory.createObjectLiteralExpression(n,!0)}function Qe(e,t,r){let n=[];if(!r)return n;let o=null;if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r)){let i=r.parameters;if(i.length>0){let a=i[0],s=t.getTypeAtLocation(a);s.aliasTypeArguments&&s.aliasTypeArguments.length>0?o=s.aliasTypeArguments[0].getProperties():o=s.getProperties()}}else if(e.ts.isIdentifier(r)){let i=t.getTypeAtLocation(r),a=i.symbol?.valueDeclaration;if(a&&e.ts.isClassDeclaration(a)){let u=a.heritageClauses?.find(p=>p.token===e.ts.SyntaxKind.ExtendsKeyword)?.types;if(u){for(let p of u)if(t.getSymbolAtLocation(p.expression)?.name==="Component"){if(e.ts.isExpressionWithTypeArguments(p)){let f=p.typeArguments;if(f){let c=f[0];o=t.getTypeFromTypeNode(c).getProperties()}}break}}}if(!o){let s=i.getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}else if(e.ts.isExportSpecifier(r)){let i=t.getSymbolAtLocation(r.name);if(i){let s=t.getTypeOfSymbolAtLocation(i,r).getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}if(o)for(let i of o){let a=bi(e,t,i);a&&n.push(a)}return n=n.filter(ir),n.length>0?n:vi(e,r)}function bi(e,t,r){let n=r.valueDeclaration,o=r.getName();if(n||(n=r.getDeclarations()?.[0]),n&&e.ts.isPropertySignature(n)){if(o!=="children"&&n.getSourceFile().fileName.includes("node_modules/@types/"))return null;let i="string",a;if(n?.type){let u=t.getTypeFromTypeNode(n.type),p=t.typeToString(u),m=rn(p);m.knownType?i=m.khulnasoftType:Ri(p)||u.flags&e.ts.TypeFlags.StringLike?i="string":u.flags&e.ts.TypeFlags.NumberLike?i="number":u.flags&e.ts.TypeFlags.IndexedAccess?i="list":u.flags&e.ts.TypeFlags.Object||u.isUnion()&&u.types.every(f=>f.flags&e.ts.TypeFlags.Object)||u.isIntersection()&&u.types.some(f=>f.flags&e.ts.TypeFlags.Object)?i="object":i="string",p!==i&&(a=p)}let s={name:o,type:i,isRegistered:!1};if(a&&n.type){let u=ki(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(Bi)?s.enum=u.map(Oi):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function vi(e,t){let r=[],n=e.ts.getJSDocCommentsAndTags(t);for(let o of n)if(!(!e.ts.isJSDoc(o)||!o.tags))for(let i of o.tags){if(!e.ts.isJSDocParameterTag(i)||i.tagName.text!=="param")continue;let s=i.typeExpression?.type;if(!s||!e.ts.isJSDocTypeLiteral(s))continue;let u=s.jsDocPropertyTags;if(u)for(let p of u){if(!e.ts.isJSDocPropertyLikeTag(p))continue;let m=p.name;if(!e.ts.isQualifiedName(m))continue;let f=p.typeExpression;if(!f)continue;let c="";switch(f.type.kind){case e.ts.SyntaxKind.StringKeyword:{c="string";break}case e.ts.SyntaxKind.NumberKeyword:{c="number";break}case e.ts.SyntaxKind.BooleanKeyword:{c="boolean";break}default:continue}let C={name:m.right.text,type:c,isRegistered:!1};r.push(C)}}return r.filter(ir)}var Ii=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function Ri(e){return typeof e!="string"?!1:!!Ii.some(t=>e.includes(t))}function rn(e){return typeof e=="string"&&(e=e.trim(),Ni.some(t=>t.value===e))?{khulnasoftType:e,knownType:!0}:{khulnasoftType:"string",knownType:!1}}var Ni=[{value:"boolean",text:"boolean"},{value:"color",text:"color (provides a color in hex or rgb)"},{value:"date",text:"date (same format as the Date constructor)"},{value:"email",text:"email"},{value:"file",text:"file (uploads a file and provides a url)"},{value:"list",text:"list (collection of items)"},{value:"longText",text:"longText (multiline text editor)"},{value:"number",text:"number"},{value:"object",text:"object (set of specific names and values)"},{value:"richText",text:"richText (provides value as html)"},{value:"string",text:"string"}];function Bi(e){return/^['"].*['"]$/.test(e)}function Oi(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var ki=(e,t,r)=>{let n=new Set;or(e,t,r,n);let o=n.delete("true"),i=n.delete("false");(o||i)&&n.add("boolean");let a=Array.from(n.keys()).sort();if(a.length>1&&(a=a.map(s=>s.indexOf("=>")>=0?`(${s})`:s)),!(a.length>20))return a},Li=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},or=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{or(e,t,o,n)});else if(r.isLiteral()){let o=Li(e,t,r);n.add(o)}};function ir(e){let t=e?.name;if(typeof t!="string"||t===""||t.startsWith("aria")||t.startsWith("data-"))return!1;if(t.startsWith("on")&&t.length>2){let r=t.charAt(2);if(r.toUpperCase()===r)return!1}return!_i.has(t.toLowerCase())}var _i=new Set(["about","accessKey","accessKeyLabel","asChild","autoCapitalize","autoCorrect","autoFocus","autoSave","blur","contentEditable","contextMenu","dangerouslySetInnerHTML","datatype","defaultChecked","defaultValue","dir","draggable","enterKeyHint","focus","form","formAction","formEncType","formMethod","formNoValidate","formTarget","inlist","innerText","inputMode","is","isContentEditable","itemID","itemProp","itemRef","itemScope","itemType","lang","nonce","offsetHeight","offsetLeft","offsetTop","offsetWidth","outerText","prefix","property","radioGroup","rel","resource","results","rev","role","security","slot","spellCheck","suppressContentEditableWarning","suppressHydrationWarning","tabIndex","translate","typeof","unselectable","vocab"].map(e=>e.toLowerCase()));function ne(e,t,r){for(let n of r.properties){if(!e.ts.isPropertyAssignment(n))continue;let o=N(e,n);if(o==="name"&&e.ts.isStringLiteral(n.initializer)){t.name=n.initializer.text;continue}if(o==="description"&&e.ts.isStringLiteral(n.initializer)){t.description=n.initializer.text;continue}if(o==="image"&&e.ts.isStringLiteral(n.initializer)){t.image=n.initializer.text;continue}if(o==="inputs"&&e.ts.isArrayLiteralExpression(n.initializer)){let i=ji(e,n.initializer);ie(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=Dt(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function ji(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(Vi(e,n));return r}function Vi(e,t){let r=Dt(e,t),n=Ji(r);return n.isRegistered=!0,n}function Q(e,t,r){let n=Ki(r);return t=tt(e,t,"name",n.name,!1),t=tt(e,t,"description",n.description),t=tt(e,t,"image",n.image),t=tt(e,t,"meta",n.meta),t=$i(e,t,n),Qi(e,t)}function $i(e,t,r){let n=null,o=t.properties.filter(s=>e.ts.isPropertyAssignment(s)&&e.ts.isIdentifier(s.name)),i=o.findIndex(s=>e.ts.isIdentifier(s.name)&&s.name.text==="inputs"),a=[...r.inputs??[]];if(i>-1){if(a.length===0)return tt(e,t,"inputs",null);let s=o[i];e.ts.isPropertyAssignment(s)&&e.ts.isArrayLiteralExpression(s.initializer)&&(n=s.initializer)}return a.length===0?t:(n=Ui(e,n||e.ts.factory.createArrayLiteralExpression(),a),i>-1?o[i]=e.ts.factory.updatePropertyAssignment(o[i],o[i].name,n):o.push(e.ts.factory.createPropertyAssignment("inputs",n)),e.ts.factory.updateObjectLiteralExpression(t,o))}function Ki(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(Mi),...e.meta?{meta:{...e.meta}}:{}}}function Mi(e){let t={name:e.name,type:e.type};return(Z(e.defaultValue)||ft(e.defaultValue)||Ze(e.defaultValue))&&(t.defaultValue=e.defaultValue),Z(e.friendlyName)&&(t.friendlyName=e.friendlyName),Z(e.helperText)&&(t.helperText=e.helperText),e.required===!0&&(t.required=!0),Array.isArray(e.enum)&&(t.enum=e.enum),e.hideFromUI===!0&&(t.hideFromUI=!0),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(t.meta=e.meta),t}function Ui(e,t,r){let n=t.elements.filter(o=>{if(!e.ts.isObjectLiteralExpression(o))return!1;let i=o.properties.find(s=>N(e,s)==="name");if(!i)return!1;let a=i.initializer;return e.ts.isStringLiteral(a)?r.some(s=>s.name===a.text):!1});for(let o of r)n=zi(e,n,o);return n.sort((o,i)=>{let a=o.properties.find(c=>N(e,c)==="name"),s=i.properties.find(c=>N(e,c)==="name"),u=a?.initializer,p=s?.initializer,m=u&&e.ts.isStringLiteral(u)?u.text:"zz",f=p&&e.ts.isStringLiteral(p)?p.text:"zz";return m.toLowerCase().localeCompare(f.toLowerCase())}),e.ts.factory.updateArrayLiteralExpression(t,n)}function zi(e,t,r){let n=t.findIndex(o=>o.properties.some(i=>{let a=N(e,i);return e.ts.isPropertyAssignment(i)&&a==="name"&&e.ts.isStringLiteral(i.initializer)&&i.initializer.text===r.name}));if(n>-1)t[n]=ar(e,t[n],r);else{let o=ar(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function ar(e,t,r){let n=t.properties.filter(i=>e.ts.isPropertyAssignment(i)),o=Object.keys(r).filter(i=>i!=="isRegistered");for(let i of o)n=qi(e,n,r,i);return n=Wi(e,n.filter(i=>{let a=N(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function qi(e,t,r,n){let o=t.findIndex(i=>e.ts.isIdentifier(i.name)&&i.name.text===n);return o>-1?t[o]=e.ts.factory.updatePropertyAssignment(t[o],t[o].name,gt(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,gt(e,r[n]))),t}function ie(e,t){for(let r of t){let n=e.inputs.findIndex(o=>o.name===r.name);n>-1?(r.isRegistered||!e.inputs[n].isRegistered)&&(e.inputs[n]=r):e.inputs.push(r)}e.acceptsChildren=on(e)}function Ji(e){let t=rn(e.type),r={name:e.name.trim(),type:t.khulnasoftType};return Z(e.friendlyName)&&e.friendlyName.trim()!==e.name.trim()&&(r.friendlyName=e.friendlyName),(Z(e.defaultValue)||ft(e.defaultValue)||Ze(e.defaultValue))&&(r.defaultValue=e.defaultValue),Z(e.helperText)&&(r.helperText=e.helperText),Ze(e.required)&&(r.required=e.required),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(r.meta=e.meta),Array.isArray(e.enum)&&e.enum.length>0&&(r.enum=e.enum),e.hideFromUI===!0&&(r.hideFromUI=!0),an(r)}function on(e){let t=e.inputs.some(n=>n.name==="children"),r=e.inputs.some(n=>n.meta?.ts==="ReactNode");return!!(t||r||e.acceptsChildren===!0)}function an(e){if(e.name==="children"&&(e.hideFromUI=!0,delete e.required),e.type==="object"&&e.defaultValue==null&&(e.hideFromUI=!0),e.type==="list"&&e.defaultValue==null&&(e.hideFromUI=!0),e.meta){let t=e.meta.ts;typeof t=="string"&&(t=t.trim(),t.endsWith("ReactNode")&&(t="ReactNode"),e.meta.ts=t,t==="ReactNode"&&(e.hideFromUI=!0))}return e}function Qi(e,t){let r=[...t.properties].sort((n,o)=>{let i=N(e,n)||"zz",a=N(e,o)||"zz";if(i==="inputs")return 1;let s=sr.indexOf(i),u=sr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)});return e.ts.factory.updateObjectLiteralExpression(t,r)}var sr=["component","name","description"];function Wi(e,t){return[...t].sort((n,o)=>{let i=N(e,n)||"zz",a=N(e,o)||"zz",s=ur.indexOf(i),u=ur.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var ur=["name","type"];function nt(e,t){for(let r of t.properties){if(!e.ts.isPropertyAssignment(r)||!e.ts.isIdentifier(r.name))continue;if(N(e,r)==="canHaveChildren"){let{initializer:o}=r;return o.kind===e.ts.SyntaxKind.TrueKeyword}}return!1}function pr(e,t){let r=`Khulnasoft.registerComponent( `;if(e.appDir)t.acceptsChildren?r+=` withChildren(${t.importName}), `:r+=` ${t.importName}, `;else{let o=t.externalImportPath?t.externalImportPath:B(e,e.registryPath,t.filePath);t.exportName==="default"?t.acceptsChildren?r+=` withChildren(dynamic(() => import(${JSON.stringify(o)}))), `:r+=` dynamic(() => import(${JSON.stringify(o)})), `:t.acceptsChildren?r+=` withChildren(dynamic(async () => (await import(${JSON.stringify(o)})).${t.exportName})), `:r+=` dynamic(async () => (await import(${JSON.stringify(o)})).${t.exportName}), `}r+=` { name: "${t.name}", } `,r+=");";let n=Bt(e,r);return sn(e,n,t)}function sn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=Q(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function G(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let n=await Wn(e,t[0]),o=e.join(n,"typescript","lib"),i=new Map,a={fileExists:s=>{if(s=e.normalize(s),s.includes("node_modules")){let u=Ct.get(s);if(!u){try{e.statSync(s).isFile()?u={exists:!0,content:e.readFileSync(s)}:u={exists:!1}}catch{u={exists:!1}}Ct.set(s,u)}return u.exists}return i.has(s)||i.set(s,e.existsSync(s)),i.get(s)},getCanonicalFileName:s=>e.normalize(s),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(o,"lib.d.ts"),getDefaultLibLocation:()=>o,getNewLine:()=>` `,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=Ct.get(s);if(p)return I(e,p.content)}let u=e.readFileSync(s);if(u==null){let p=e.basename(s),m=e.extname(p).toLowerCase();if(s.startsWith(o)&&m===".ts"&&(u=cr.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new kt(p)}return s.includes("node_modules")&&(u?Ct.set(s,{exists:!0,content:u}):Ct.set(s,{exists:!1})),I(e,u)},readFile:s=>{let u=e.readFileSync(s);return typeof u=="string"?u:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return Yi(e,a,t,r)}catch(s){if(s instanceof kt){await Gi(e,s.libName);continue}throw console.error("createTsProgram",s),new Error(`createTsProgram() Could not create program for: ${t[0]}`)}}function Yi(e,t,r,n){let o={rootNames:[...r],options:{},host:t},i=e.ts.findConfigFile(e.dirname(r[0]),a=>e.existsSync(a));if(i){let a=lr.get(i);if(!a){let s=e.ts.readConfigFile(i,u=>{let p=e.readFileSync(u);return typeof p=="string"?p:void 0});s.error?console.error("error reading tsconfig for createTsProgram"):(a=e.ts.parseJsonConfigFileContent(s.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(p,m)=>e.readdirSync(p),fileExists:p=>e.existsSync(p),readFile:p=>e.readFileSync(p)||void 0},e.dirname(i),void 0,i).options,lr.set(i,a))}a&&(o.options=oe(a))}return o.options.noEmit=!0,o.options.isolatedModules=!1,o.options.strict=!1,o.options.jsx=e.ts.JsxEmit.Preserve,o.options.allowJs=!0,Object.assign(o.options,n),e.ts.createProgram(o)}async function rt(e,t,r){r||(r=await G(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var kt=class{constructor(t){this.libName=t}};async function Gi(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;Ot.has(t)||Ot.set(t,fetch(r).then(n=>n.text()).then(n=>{cr.set(t,n)})),await Ot.get(t),Ot.delete(t)}var cr=new Map,Ot=new Map,Ct=new Map,lr=new Map;function v(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=Hi(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=Xi(e,t,r.defaultImport,r.importPath,n)),t}function Hi(e,t,r,n,o,i){return i==="cjs"?fr(e,t,null,r,n):mr(e,t,null,r,n,o)}function Xi(e,t,r,n,o){return o==="cjs"?fr(e,t,r,null,n):mr(e,t,r,null,n,!1)}function mr(e,t,r,n,o,i){let a=[...t.statements],s=0,u=!1,p=!1;for(let d=0;d<a.length;d++){let C=a[d];if(!e.ts.isImportDeclaration(C)||(s=d,!C.moduleSpecifier||!e.ts.isStringLiteral(C.moduleSpecifier))||C.moduleSpecifier.text!==o||!!C.importClause?.isTypeOnly!==i)continue;let l=[],D=C.importClause?.namedBindings;if(D&&e.ts.isNamedImports(D)&&D.elements&&l.push(...D.elements),typeof n=="string"){if(l.some(x=>x.name.text===n))return t;l.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),l.sort((x,S)=>x.name.text.localeCompare(S.name.text)),u=!0}let g=C.importClause?C.importClause.name:void 0;if(typeof r=="string"){if(g&&g.text===r)return t;g=e.ts.factory.createIdentifier(r),p=!0}if(u||p)return a[d]=e.ts.factory.updateImportDeclaration(C,void 0,e.ts.factory.createImportClause(i,g,e.ts.factory.createNamedImports(l)),C.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let m,f;typeof r=="string"&&(m=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(f=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let c=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,m,f),e.ts.factory.createStringLiteral(o));return a.splice(s,0,c),e.ts.factory.updateSourceFile(t,a)}function fr(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let u=i[s];if(e.ts.isVariableStatement(u))for(let p=0;p<u.declarationList.declarations.length;p++){let m=[...u.declarationList.declarations],f=m[p],c=f.initializer;if(!c||!e.ts.isCallExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="require"||c.arguments.length!==1)continue;let C=c.arguments[0];if(e.ts.isStringLiteral(C)&&(a=s,C.text===o)){if(e.ts.isIdentifier(f.name)&&typeof r=="string")return f.name.text===r?t:(m[p]=e.ts.factory.updateVariableDeclaration(f,e.ts.factory.createIdentifier(r),f.exclamationToken,f.type,f.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,m)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(f.name)&&typeof n=="string"){let l=[...f.name.elements];return l.some(g=>!e.ts.isBindingElement(g)||!e.ts.isIdentifier(g.name)?!1:g.name.text===n)?t:(l.push(e.ts.factory.createBindingElement(void 0,void 0,n)),l.sort((g,x)=>!e.ts.isBindingElement(g)||!e.ts.isIdentifier(g.name)||!e.ts.isBindingElement(x)||!e.ts.isIdentifier(x.name)?0:g.name.text.localeCompare(x.name.text)),m[p]=e.ts.factory.updateVariableDeclaration(f,e.ts.factory.createObjectBindingPattern(l),f.exclamationToken,f.type,f.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,m)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function ue(e,t,r="esm"){return r==="cjs"?ea(e,t):Zi(e,t)}function Zi(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}else!n.exportClause&&n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:n});continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function ea(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function ta(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function he(e,t,r,n){let o=ta(e,r,n);if(o){let i=await xt(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getAppRootDir(),i);return{displayFilePath:k(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function ot(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function J(e,t,r){let n=ot(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function Lt(e,t){if(t){if(na(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Lt(e,n)&&(r=!0)}),r)return!0}return!1}function na(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function xt(e,t){let r=e.extname(t).toLowerCase();if(r===""||!un.includes(r)){for(let n of un){let o=t+n;if(await e.exists(o))return o}for(let n of un){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var un=[".tsx",".jsx",".ts",".js"];function it(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=ra(e,i);return a?[{name:a}]:void 0}function ra(e,t){if(typeof t=="string"){t=e.normalize(ce(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function Ee(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}function dr(e,t,r="esm"){return r==="cjs"?aa(e,t):ia(e,t)}var oa=/^(@\w|\w)/;function ia(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!oa.test(n.moduleSpecifier.text)||n.importClause?.isTypeOnly)continue;if(n.importClause&&n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings))for(let o of n.importClause.namedBindings.elements)o.isTypeOnly||r.push({isDefaultExport:!1,statement:n,node:o.name});n.importClause&&n.importClause.name&&r.push({isDefaultExport:!0,statement:n,node:n.importClause.name})}return r}function aa(e,t){return[]}async function at(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await G(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let p=(await Ke(e,o,a.filePath,s,!1)).find(m=>m.cmpInfo.id===a.id);p&&(a.inputs=Qe(e,o,p.node.fnNode))}return a}))}async function st(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await rt(e,t.cmpInfo.filePath,r),s=(await Ke(e,i,t.cmpInfo.filePath,o,n)).find(u=>u.cmpInfo.id===t.cmpInfo.id);if(!s)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Qe(e,i,s.node.fnNode)}return[]}async function Dr(e,t,r){let n=e.extname(t).toLowerCase();if(n===".tsx"||n===".jsx"||n===".ts"||n===".js"){let o=await e.readFile(t);if(o)return sa(e,t,o,r)}return null}function sa(e,t,r,n=!1){let o=I(e,r);return Ke(e,null,t,o,n)}async function Ke(e,t,r,n,o){let i=[];for(let s of n.statements)if(e.ts.isExpressionStatement(s)&&e.ts.isStringLiteral(s.expression)&&s.expression.text==="use server")return i;let a=ue(e,n);return o&&a.push(...dr(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await ua(e,t,r,s);i.push(...u)})),i}async function ua(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=V(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!et(s.name.text))continue;let u=Re(e,t,s.initializer);if(u){let p=u.name||s.name.text,m=n.isDefaultExport?"default":p,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await $(e,r,m),displayFilePath:k(e,r),name:K(p),inputs:[],exportName:m,exportType:f,importName:p,filePath:r,relFilePath:i,importPath:a,dependencies:u.deps},node:u})}}return o}if(e.ts.isArrowFunction(n.node)){let s=Re(e,t,n.node);if(s){let u=se(e,r),p=n.isDefaultExport?"default":u,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await $(e,r,p),displayFilePath:k(e,r),name:u,inputs:[],exportName:p,exportType:m,importName:Je(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!et(s))return o;let u=Re(e,t,n.node);if(u){let p=u.name||se(e,r),m=n.isDefaultExport||!u.name?"default":u.name,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await $(e,r,m),displayFilePath:k(e,r),name:p,inputs:[],exportName:m,exportType:f,importName:u.name||Je(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:u.deps},node:u})}return o}if((e.ts.isExportSpecifier(n.node)||e.ts.isIdentifier(n.node))&&et(n.node.getText())){let s,u=Re(e,t,n.node);if(u){let p=u.name||se(e,r),m=n.isDefaultExport||!u.name?"default":u.name,f=n.isDefaultExport?"default":"named",c=pa(e,n.node)?.moduleSpecifier??la(e,n.node)?.moduleSpecifier;if(c&&e.ts.isStringLiteral(c)){let d=t?.getSymbolAtLocation(c);if(d&&d.declarations&&d.declarations.length>0){let C=d.declarations[0];(!e.ts.isSourceFile(C)||e.ts.isSourceFile(C)&&C.fileName.includes("node_modules"))&&(s=c.text)}}o.push({cmpInfo:{id:await $(e,r,m,s),displayFilePath:k(e,r),name:p,inputs:[],exportName:m,exportType:f,importName:u.name||Je(e,r),filePath:r,relFilePath:i,importPath:s||a,externalImportPath:s,dependencies:u.deps},node:u})}return o}if(e.ts.isExportDeclaration(n.node)&&n.node.exportClause===void 0){let s=n.node.moduleSpecifier;if(s&&e.ts.isStringLiteral(s)){let u=await ma(e,t,r,s);o.push(...u)}return o}return o}function pa(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function la(e,t){for(;t;){if(e.ts.isImportDeclaration(t))return t;t=t.parent}return null}function Re(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return Lt(e,r.body)?{name:"",fnNode:r,deps:it(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Lt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:it(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(e.ts.isPropertyAccessExpression(n)){let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:Re(e,t,o[0])}else if(e.ts.isIdentifier(n)&&n.text==="observer"){let o=r.arguments;return o.length===0?null:Re(e,t,o[0])}return null}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!et(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:it(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:it(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:it(e,t,r)};if(e.ts.isExpressionStatement(r)){let n=r.expression;if(e.ts.isAsExpression(n)&&e.ts.isIdentifier(n.type)&&n.type.text==="default")return Re(e,t,n.expression)}if(e.ts.isVariableStatement(r)){for(let n of r.declarationList.declarations)if(n.initializer&&e.ts.isAsExpression(n.initializer)){let o=n.initializer;if(e.ts.isIdentifier(o.type)&&o.type.text==="default"){let i=Re(e,t,o.expression);if(i&&e.ts.isIdentifier(n.name))return{name:n.name.text,fnNode:i.fnNode,deps:i.deps}}}}return null}async function Cr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(Nt(e,ca,i.fileName)||a===e.reactConfigPath||a===e.khulnasoftComponentPath)return;let s=await Ke(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var ca=new Set(["node_modules","dist"]);async function ma(e,t,r,n){let o=[],i=n.text;if(!t)return o;try{let a=t.getSymbolAtLocation(n);if(!a)return o;let s=t.getExportsOfModule(a);for(let u of s){let p=u.valueDeclaration||u.declarations?.[0];if(!p)continue;let m=u.name;if(!et(m)&&m!=="default"||!xr(e,t,p))continue;let f=Re(e,t,p);if(f){let c=u.name,d=c==="default"?"default":"named",C=K(c),l=c==="default"?Je(e,r):c;o.push({cmpInfo:{id:await $(e,r,c,i),displayFilePath:k(e,r),name:C,inputs:[],exportName:c,exportType:d,importName:l,filePath:r,relFilePath:e.relative(e.getAppRootDir(),r),importPath:i,externalImportPath:i,dependencies:f.deps},node:f})}}}catch(a){console.error(`Error processing module ${i}:`,a)}return o}function xr(e,t,r){if(e.ts.isInterfaceDeclaration(r)||e.ts.isTypeAliasDeclaration(r))return!1;if(e.ts.isExportSpecifier(r)){let n=t.getSymbolAtLocation(r.name);if(n){let i=t.getAliasedSymbol(n).declarations?.[0];if(i)return xr(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)){let n=t.getSignatureFromDeclaration(r);if(n){let o=t.getReturnTypeOfSignature(n);return gr(o,t)}}return e.ts.isClassDeclaration(r)?r.heritageClauses?.some(o=>o.types.some(i=>i.expression.getText()==="React.Component"||i.expression.getText()==="Component"))??!1:e.ts.isVariableDeclaration(r)?t.getTypeAtLocation(r).getCallSignatures().some(i=>gr(t.getReturnTypeOfSignature(i),t)):!1}function gr(e,t){let r=t.typeToString(e);return r==="JSX.Element"||r==="Element"||r.includes("ReactElement")||r.includes("React.ReactElement")||r.includes("ReactNode")}async function hr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&fa.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.khulnasoftComponentPath)return;let u=await Ke(e,o,s,i,s===e.registryPath||ge(s));r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var fa=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function Se(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let u=a.moduleSpecifier.text;if(!u.startsWith(".")&&!u.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...pn(e,r),...p