@pan-stack/cli 0.3.61 → 0.3.62

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/bin/pan.js CHANGED
@@ -1335,7 +1335,7 @@ tfoot td{font-weight:700;border-bottom:0;border-top:1px solid color-mix(in oklab
1335
1335
  `).trim()),p.push("```"),p.push("")}}return p.push("---"),p.push(""),p.push(w("STATS_REVIEW_MD_AI_H2")),p.push(""),p.push(w("STATS_REVIEW_MD_AI_INTRO")),p.push(""),p.push(w("STATS_REVIEW_MD_AI_CRITERIA")),p.push(""),p.push(w("STATS_REVIEW_MD_AI_OUTRO")),p.join(`
1336
1336
  `)}function BZ(e){try{return(0,FZ.execFileSync)("git",e,{encoding:"utf8",maxBuffer:512*1024*1024})}catch(t){let n=t instanceof Error?t.message:String(t);throw new Error(w("STATS_GIT_ERROR__MSG",{msg:n.split(`
1337
1337
  `)[0]??""}))}}function i9e(e){let t=[],n=null;for(let r of e.split(`
1338
- `)){if(r.includes("")){n&&t.push(n);let[i,a,s,l,c]=r.split("");n={hash:i??"",date:a??"",name:s??"",email:l??"",subject:c||"",additions:0,deletions:0};continue}let o=r.match(/(\d+) insertion[s]?\(\+\)|(\d+) deletion[s]?\(-\)/g);if(o&&n)for(let i of o){let a=i.match(/(\d+) insertion/),s=i.match(/(\d+) deletion/);a?.[1]&&(n.additions+=parseInt(a[1],10)),s?.[1]&&(n.deletions+=parseInt(s[1],10))}}return n&&t.push(n),t}function a9e(e){return String(e||"").replace(/\|/g,"\\|")}function GZ(e,t){return hR.default.mkdirSync(jZ.default.dirname(e),{recursive:!0}),hR.default.writeFileSync(e,t),e}var hR,jZ,FZ,zZ=ne(()=>{"use strict";hR=Q(require("fs")),jZ=Q(require("path")),FZ=require("child_process");FS();It()});var mR={};zn(mR,{runStats:()=>c9e});function s9e(e){let t={_:[],open:!0,diff:!0};for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(r==="--since"?t.since=e[++n]:r==="--from"?t.from=e[++n]:r==="--to"?t.to=e[++n]:r==="--member"||r==="-m"?t.member=e[++n]:r==="--project"||r==="-p"?t.project=e[++n]:r==="--port"?t.port=parseInt(e[++n]??"",10):r==="--out"||r==="-o"?t.out=e[++n]:r==="--no-open"?t.open=!1:r==="--no-diff"?t.diff=!1:r==="--head-only"?t.headOnly=!0:r==="--max-diff-lines"?t.maxDiffLines=parseInt(e[++n]??"",10):r.startsWith("--since=")?t.since=r.slice(8):t._.push(r))}return t}function GS(){let e=Eg.default.join(HZ.default.homedir(),".pan-code-graph");return zS.default.mkdirSync(e,{recursive:!0}),e}function vR(){let e=og();if(e)return{repos:_Z(e),source:`.project.yaml (${e.project})`};let t=rg(process.cwd());if(!t.length)throw new Error(w("STATS_NO_REPOS__CWD",{cwd:process.cwd()}));return console.log(w("STATS_FALLBACK_SCAN__CWD",{cwd:process.cwd()})),{repos:t,source:w("STATS_SOURCE_FALLBACK")}}function l9e(){console.log(w("STATS_USAGE"))}async function c9e(e){let t=s9e(e),n=t._[0],r=n!==void 0&&["report","people","review"].includes(n)?t._.shift():"report";return t._[0]==="help"||t.help?l9e():r==="review"?p9e(t):r==="people"?f9e(t):d9e(t)}function u9e(e){let{repos:t}=vR(),n=Oy(e),r=!e.headOnly,o=r?w("STATS_SCOPE_ALL_BRANCHES"):w("STATS_SCOPE_HEAD_ONLY");console.log(w("STATS_SCAN_RANGE__N_SCOPE_LABEL",{n:t.length,scope:o,label:n.label}));let{commits:i,repoStatus:a}=dR(t,n,{allBranches:r}),s=fR(Eg.default.join(GS(),"alias-map.json"));return{repos:t,range:n,commits:i,repoStatus:a,aliasMap:s}}function d9e(e){let{repos:t}=vR(),n=Oy({}),r=!e.headOnly,o=r?w("STATS_SCOPE_ALL_BRANCHES"):w("STATS_SCOPE_HEAD_ONLY");console.log(w("STATS_SCAN_FULL__N_SCOPE",{n:t.length,scope:o}));let{commits:i,repoStatus:a}=dR(t,n,{allBranches:r}),s=fR(Eg.default.join(GS(),"alias-map.json")),l=i.map(h=>({e:US(h.email,s),n:h.name||h.email,t:h.ts,r:h.repoName,a:h.additions,d:h.deletions})),c=a.filter(h=>!h.available).map(h=>({name:h.name,reason:h.reason}));Oy(e);let u={reposTotal:a.length,reposAvailable:a.filter(h=>h.available).length,unavailable:c,initialSince:e.since!=null?Number(e.since):null,initialFrom:e.from||null,initialTo:e.to||null,initialMembers:e.member?[e.member]:[]},d=OZ(l,u),f=e.out||Eg.default.join(GS(),"report.html");zS.default.writeFileSync(f,d),console.log(w("STATS_WROTE_REPORT__PATH_N",{path:f,n:l.length})),c.length&&console.log(w("STATS_UNAVAILABLE__N",{n:c.length})),PZ(d,{port:e.port||4321,open:e.open})}function f9e(e){let{commits:t,aliasMap:n}=u9e(e),{members:r}=kZ(t,n);console.log(w("STATS_PEOPLE_HEADER__N",{n:r.length}));for(let o of r)console.log(w("STATS_PEOPLE_ROW__N_NAME_EMAIL",{n:String(o.commits).padStart(5),name:o.name,email:o.email}))}function p9e(e){if(!e.member||!e.project)throw new Error(w("STATS_REVIEW_NEED_FLAGS"));let{repos:t}=vR(),n=t.find(s=>s.name===e.project);if(!n)throw new Error(w("STATS_REVIEW_NO_PROJECT__PROJECT_NAMES",{project:e.project,names:t.map(s=>s.name).join(", ")}));if(!zS.default.existsSync(n.dir))throw new Error(w("STATS_REVIEW_NOT_CLONED__PROJECT_DIR",{project:e.project,dir:n.dir}));let r=Oy(e);console.log(w("STATS_REVIEW_BUILDING__MEMBER_PROJECT_LABEL",{member:e.member,project:e.project,label:r.label}));let o=UZ(n,e.member,r,{withDiff:e.diff,maxDiffLines:e.maxDiffLines,allBranches:!e.headOnly}),i=`${e.project}_${e.member.replace(/[^a-z0-9]+/gi,"-")}`.toLowerCase(),a=e.out||Eg.default.join(GS(),`review-${i}.md`);GZ(a,o),console.log(w("STATS_REVIEW_WROTE__PATH",{path:a})),console.log(w("STATS_REVIEW_HINT"))}var zS,Eg,HZ,gR=ne(()=>{"use strict";zS=Q(require("fs")),Eg=Q(require("path")),HZ=Q(require("os"));Ps();EZ();FS();pR();TZ();RZ();MZ();zZ();It()});var bR=F((E_t,h9e)=>{h9e.exports={name:"@pan-stack/cli",version:"0.3.61",description:"PAN Stack CLI \u2014 multi-repo git and project commands from .project.yaml",license:"SEE LICENSE IN LICENSE.txt",bin:{pan:"bin/pan.js"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},files:["bin","dist/agent-plugin"],scripts:{build:"node tools/pan-stack-cli/build.mjs","build:agent-plugin":"node tools/pan-stack-cli/build-agent-plugin.ts",prepare:"node tools/pan-stack-cli/build.mjs",prepublishOnly:"node tools/pan-stack-cli/build.mjs",test:'tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && tsc -p tools/pan-ba/tsconfig.e2e.json --noEmit && node --test "tools/pan-stack-plan/test/*.test.ts" "tools/pan-stack-cli/test/*.test.ts" "tools/pan-lineage/test/*.test.ts" "tools/pan-harness/test/*.test.ts" "tools/pan-program/test/*.test.ts" "tools/pan-handover/test/*.test.ts" "tools/pan-ba-core/test/*.test.ts" "tools/pan-ba/test/*.test.ts" "agent-plugin/plugins/pan/test/*.test.mjs" && node --test "tools/pan-cicd/test/*.test.mjs"',"test:pan-cicd":'node tools/pan-stack-cli/build.mjs && node --test "tools/pan-cicd/test/*.test.mjs"',"test:pan-stack-plan":'node --test "tools/pan-stack-plan/test/*.test.ts"',"test:pan-stack-cli":'node --test "tools/pan-stack-cli/test/*.test.ts"',typecheck:"tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && tsc -p tools/pan-ba/tsconfig.e2e.json --noEmit","build:web":"node tools/pan-stack-plan/build-web.mjs",pretest:"node tools/pan-stack-plan/build-web.mjs","test:e2e":"playwright test -c tools/pan-stack-plan/playwright.config.ts","test:e2e:ba":"node tools/pan-stack-cli/build.mjs && playwright test -c tools/pan-ba/playwright.config.ts","test:pan-lineage":'node --test "tools/pan-lineage/test/*.test.ts"'},engines:{node:">=18"},keywords:["pan-stack","monorepo","git","cli"],devDependencies:{"@inquirer/core":"^11.2.1","@inquirer/prompts":"^8.5.2","@inquirer/testing":"^3.3.9","@playwright/test":"1.62.1","@radix-ui/react-dialog":"^1.1.23","@radix-ui/react-popover":"1.1.23","@radix-ui/react-separator":"^1.1.15","@radix-ui/react-slot":"^1.3.3","@radix-ui/react-switch":"^1.3.7","@radix-ui/react-tabs":"^1.1.21","@radix-ui/react-tooltip":"^1.2.16","@tailwindcss/cli":"4.3.3","@tailwindcss/typography":"0.5.20","@types/node":"22.18.8","@types/picomatch":"3.0.1","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/sanitize-html":"2.16.0","class-variance-authority":"0.7.1",clsx:"2.1.1",cmdk:"1.1.1","csv-parse":"7.0.1","csv-stringify":"6.8.1",docx:"9.15.2",esbuild:"0.28.1",marked:"15.0.12","pdf-lib":"1.17.1",picomatch:"4.0.2",react:"19.2.8","react-dom":"19.2.8","react-markdown":"10.1.0","remark-gfm":"4.0.1","sanitize-html":"2.16.0",serve:"^14.2.4","tailwind-merge":"3.6.0",tailwindcss:"4.3.3",typescript:"5.9.3",yaml:"2.6.1"},optionalDependencies:{"@pan-stack/powerpoint":"^0.1.0"}}});var KZ={};zn(KZ,{runInteractiveMenu:()=>m9e});function v9e(e){let t=e,n=String(t&&`${String(t.name)} ${String(t.message)}`||"");return/ExitPromptError|force closed|SIGINT|cancel/i.test(n)}async function wR({message:e,choices:t,hotkeys:n=[]}){try{return await j0({message:e,choices:t,hotkeys:n})}catch(r){if(String(r?.message)!=="no-core")throw r;let o=await Tc();if(!o||typeof o.select!="function")return"__exit__";let i=n.map(s=>({name:`${s.key} ${s.label}`,value:s.value})),a=i.length?[...t,new o.Separator,...i]:t;return o.select({message:e,choices:a,pageSize:20,loop:!1,theme:aa(!1)})}}async function m9e({printUsage:e,version:t}={}){let n=await tS(),r=await Tc();if(!n&&(!r||typeof r.select!="function"))return!1;let o=M6().filter(i=>ay(i).length>0).sort((i,a)=>Tu(i).localeCompare(Tu(a)));if(o.length===0)return console.log(w("NO_PAN_YAML_WITH_COMMANDS")),console.log(w("NO_PAN_YAML_BUT_GIT_STILL_WORKS")),!1;try{for(;;){let i=await wR({message:w("MENU_SELECT_PROJECT"),choices:o.map((f,h)=>({name:Tu(f),value:h,description:`${ay(f).length} ${w("COMMANDS_LABEL")} \xB7 ${f.root}`})),hotkeys:[{key:"h",label:w("HELP_LABEL"),value:"__help__"},{key:"v",label:w("VERSION_LABEL"),value:"__version__"},{key:"x",label:w("EXIT_LABEL"),value:"__exit__"}]});if(i==="__exit__")return!0;if(i==="__version__"){console.log(`@pan-stack/cli ${t||"?"}`);continue}if(i==="__help__"){typeof e=="function"&&e();continue}let a=typeof i=="number"?o[i]:void 0;if(!a)continue;let s=ay(a),l=await wR({message:`[${Tu(a)}] ${w("MENU_SELECT_COMMAND")}`,choices:s.map(f=>({name:f.name+(f.aliases&&f.aliases.length?` (${f.aliases.join(", ")})`:"")+(f.hasTargets?` [${f.targets.join("|")}]`:""),value:f.name,description:f.description||""})),hotkeys:[{key:"b",label:w("BACK_LABEL"),value:"__back__"},{key:"x",label:w("EXIT_LABEL"),value:"__exit__"}]});if(l==="__exit__")return!0;if(l==="__back__")continue;let c=a.commands[String(l)],u=[];if(c&&c.targets&&Object.keys(c.targets).length>0){let f=Object.keys(c.targets),h=await wR({message:w("SELECT_TARGET__CMD",{cmd:l}),choices:[...f.map(p=>({name:p,value:p})),{name:w("DEFAULT_LABEL"),value:"__default__"}],hotkeys:[{key:"b",label:w("BACK_LABEL"),value:"__back__"}]});if(h==="__back__")continue;h!=="__default__"&&u.push(String(h))}console.error(`
1338
+ `)){if(r.includes("")){n&&t.push(n);let[i,a,s,l,c]=r.split("");n={hash:i??"",date:a??"",name:s??"",email:l??"",subject:c||"",additions:0,deletions:0};continue}let o=r.match(/(\d+) insertion[s]?\(\+\)|(\d+) deletion[s]?\(-\)/g);if(o&&n)for(let i of o){let a=i.match(/(\d+) insertion/),s=i.match(/(\d+) deletion/);a?.[1]&&(n.additions+=parseInt(a[1],10)),s?.[1]&&(n.deletions+=parseInt(s[1],10))}}return n&&t.push(n),t}function a9e(e){return String(e||"").replace(/\|/g,"\\|")}function GZ(e,t){return hR.default.mkdirSync(jZ.default.dirname(e),{recursive:!0}),hR.default.writeFileSync(e,t),e}var hR,jZ,FZ,zZ=ne(()=>{"use strict";hR=Q(require("fs")),jZ=Q(require("path")),FZ=require("child_process");FS();It()});var mR={};zn(mR,{runStats:()=>c9e});function s9e(e){let t={_:[],open:!0,diff:!0};for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(r==="--since"?t.since=e[++n]:r==="--from"?t.from=e[++n]:r==="--to"?t.to=e[++n]:r==="--member"||r==="-m"?t.member=e[++n]:r==="--project"||r==="-p"?t.project=e[++n]:r==="--port"?t.port=parseInt(e[++n]??"",10):r==="--out"||r==="-o"?t.out=e[++n]:r==="--no-open"?t.open=!1:r==="--no-diff"?t.diff=!1:r==="--head-only"?t.headOnly=!0:r==="--max-diff-lines"?t.maxDiffLines=parseInt(e[++n]??"",10):r.startsWith("--since=")?t.since=r.slice(8):t._.push(r))}return t}function GS(){let e=Eg.default.join(HZ.default.homedir(),".pan-code-graph");return zS.default.mkdirSync(e,{recursive:!0}),e}function vR(){let e=og();if(e)return{repos:_Z(e),source:`.project.yaml (${e.project})`};let t=rg(process.cwd());if(!t.length)throw new Error(w("STATS_NO_REPOS__CWD",{cwd:process.cwd()}));return console.log(w("STATS_FALLBACK_SCAN__CWD",{cwd:process.cwd()})),{repos:t,source:w("STATS_SOURCE_FALLBACK")}}function l9e(){console.log(w("STATS_USAGE"))}async function c9e(e){let t=s9e(e),n=t._[0],r=n!==void 0&&["report","people","review"].includes(n)?t._.shift():"report";return t._[0]==="help"||t.help?l9e():r==="review"?p9e(t):r==="people"?f9e(t):d9e(t)}function u9e(e){let{repos:t}=vR(),n=Oy(e),r=!e.headOnly,o=r?w("STATS_SCOPE_ALL_BRANCHES"):w("STATS_SCOPE_HEAD_ONLY");console.log(w("STATS_SCAN_RANGE__N_SCOPE_LABEL",{n:t.length,scope:o,label:n.label}));let{commits:i,repoStatus:a}=dR(t,n,{allBranches:r}),s=fR(Eg.default.join(GS(),"alias-map.json"));return{repos:t,range:n,commits:i,repoStatus:a,aliasMap:s}}function d9e(e){let{repos:t}=vR(),n=Oy({}),r=!e.headOnly,o=r?w("STATS_SCOPE_ALL_BRANCHES"):w("STATS_SCOPE_HEAD_ONLY");console.log(w("STATS_SCAN_FULL__N_SCOPE",{n:t.length,scope:o}));let{commits:i,repoStatus:a}=dR(t,n,{allBranches:r}),s=fR(Eg.default.join(GS(),"alias-map.json")),l=i.map(h=>({e:US(h.email,s),n:h.name||h.email,t:h.ts,r:h.repoName,a:h.additions,d:h.deletions})),c=a.filter(h=>!h.available).map(h=>({name:h.name,reason:h.reason}));Oy(e);let u={reposTotal:a.length,reposAvailable:a.filter(h=>h.available).length,unavailable:c,initialSince:e.since!=null?Number(e.since):null,initialFrom:e.from||null,initialTo:e.to||null,initialMembers:e.member?[e.member]:[]},d=OZ(l,u),f=e.out||Eg.default.join(GS(),"report.html");zS.default.writeFileSync(f,d),console.log(w("STATS_WROTE_REPORT__PATH_N",{path:f,n:l.length})),c.length&&console.log(w("STATS_UNAVAILABLE__N",{n:c.length})),PZ(d,{port:e.port||4321,open:e.open})}function f9e(e){let{commits:t,aliasMap:n}=u9e(e),{members:r}=kZ(t,n);console.log(w("STATS_PEOPLE_HEADER__N",{n:r.length}));for(let o of r)console.log(w("STATS_PEOPLE_ROW__N_NAME_EMAIL",{n:String(o.commits).padStart(5),name:o.name,email:o.email}))}function p9e(e){if(!e.member||!e.project)throw new Error(w("STATS_REVIEW_NEED_FLAGS"));let{repos:t}=vR(),n=t.find(s=>s.name===e.project);if(!n)throw new Error(w("STATS_REVIEW_NO_PROJECT__PROJECT_NAMES",{project:e.project,names:t.map(s=>s.name).join(", ")}));if(!zS.default.existsSync(n.dir))throw new Error(w("STATS_REVIEW_NOT_CLONED__PROJECT_DIR",{project:e.project,dir:n.dir}));let r=Oy(e);console.log(w("STATS_REVIEW_BUILDING__MEMBER_PROJECT_LABEL",{member:e.member,project:e.project,label:r.label}));let o=UZ(n,e.member,r,{withDiff:e.diff,maxDiffLines:e.maxDiffLines,allBranches:!e.headOnly}),i=`${e.project}_${e.member.replace(/[^a-z0-9]+/gi,"-")}`.toLowerCase(),a=e.out||Eg.default.join(GS(),`review-${i}.md`);GZ(a,o),console.log(w("STATS_REVIEW_WROTE__PATH",{path:a})),console.log(w("STATS_REVIEW_HINT"))}var zS,Eg,HZ,gR=ne(()=>{"use strict";zS=Q(require("fs")),Eg=Q(require("path")),HZ=Q(require("os"));Ps();EZ();FS();pR();TZ();RZ();MZ();zZ();It()});var bR=F((E_t,h9e)=>{h9e.exports={name:"@pan-stack/cli",version:"0.3.62",description:"PAN Stack CLI \u2014 multi-repo git and project commands from .project.yaml",license:"SEE LICENSE IN LICENSE.txt",bin:{pan:"bin/pan.js"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},files:["bin","dist/agent-plugin"],scripts:{build:"node tools/pan-stack-cli/build.mjs","build:agent-plugin":"node tools/pan-stack-cli/build-agent-plugin.ts",prepare:"node tools/pan-stack-cli/build.mjs",prepublishOnly:"node tools/pan-stack-cli/build.mjs",test:'tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && tsc -p tools/pan-ba/tsconfig.e2e.json --noEmit && node --test "tools/pan-stack-plan/test/*.test.ts" "tools/pan-stack-cli/test/*.test.ts" "tools/pan-lineage/test/*.test.ts" "tools/pan-harness/test/*.test.ts" "tools/pan-program/test/*.test.ts" "tools/pan-handover/test/*.test.ts" "tools/pan-ba-core/test/*.test.ts" "tools/pan-ba/test/*.test.ts" "agent-plugin/plugins/pan/test/*.test.mjs" && node --test "tools/pan-cicd/test/*.test.mjs"',"test:pan-cicd":'node tools/pan-stack-cli/build.mjs && node --test "tools/pan-cicd/test/*.test.mjs"',"test:pan-stack-plan":'node --test "tools/pan-stack-plan/test/*.test.ts"',"test:pan-stack-cli":'node --test "tools/pan-stack-cli/test/*.test.ts"',typecheck:"tsc --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.web.json --noEmit && tsc -p tools/pan-stack-plan/tsconfig.e2e.json --noEmit && tsc -p tools/pan-ba/tsconfig.e2e.json --noEmit","build:web":"node tools/pan-stack-plan/build-web.mjs",pretest:"node tools/pan-stack-plan/build-web.mjs","test:e2e":"playwright test -c tools/pan-stack-plan/playwright.config.ts","test:e2e:ba":"node tools/pan-stack-cli/build.mjs && playwright test -c tools/pan-ba/playwright.config.ts","test:pan-lineage":'node --test "tools/pan-lineage/test/*.test.ts"'},engines:{node:">=18"},keywords:["pan-stack","monorepo","git","cli"],devDependencies:{"@inquirer/core":"^11.2.1","@inquirer/prompts":"^8.5.2","@inquirer/testing":"^3.3.9","@playwright/test":"1.62.1","@radix-ui/react-dialog":"^1.1.23","@radix-ui/react-popover":"1.1.23","@radix-ui/react-separator":"^1.1.15","@radix-ui/react-slot":"^1.3.3","@radix-ui/react-switch":"^1.3.7","@radix-ui/react-tabs":"^1.1.21","@radix-ui/react-tooltip":"^1.2.16","@tailwindcss/cli":"4.3.3","@tailwindcss/typography":"0.5.20","@types/node":"22.18.8","@types/picomatch":"3.0.1","@types/react":"^19.2.18","@types/react-dom":"^19.2.5","@types/sanitize-html":"2.16.0","class-variance-authority":"0.7.1",clsx:"2.1.1",cmdk:"1.1.1","csv-parse":"7.0.1","csv-stringify":"6.8.1",docx:"9.15.2",esbuild:"0.28.1",marked:"15.0.12","pdf-lib":"1.17.1",picomatch:"4.0.2",react:"19.2.8","react-dom":"19.2.8","react-markdown":"10.1.0","remark-gfm":"4.0.1","sanitize-html":"2.16.0",serve:"^14.2.4","tailwind-merge":"3.6.0",tailwindcss:"4.3.3",typescript:"5.9.3",yaml:"2.6.1"},optionalDependencies:{"@pan-stack/powerpoint":"^0.1.0"}}});var KZ={};zn(KZ,{runInteractiveMenu:()=>m9e});function v9e(e){let t=e,n=String(t&&`${String(t.name)} ${String(t.message)}`||"");return/ExitPromptError|force closed|SIGINT|cancel/i.test(n)}async function wR({message:e,choices:t,hotkeys:n=[]}){try{return await j0({message:e,choices:t,hotkeys:n})}catch(r){if(String(r?.message)!=="no-core")throw r;let o=await Tc();if(!o||typeof o.select!="function")return"__exit__";let i=n.map(s=>({name:`${s.key} ${s.label}`,value:s.value})),a=i.length?[...t,new o.Separator,...i]:t;return o.select({message:e,choices:a,pageSize:20,loop:!1,theme:aa(!1)})}}async function m9e({printUsage:e,version:t}={}){let n=await tS(),r=await Tc();if(!n&&(!r||typeof r.select!="function"))return!1;let o=M6().filter(i=>ay(i).length>0).sort((i,a)=>Tu(i).localeCompare(Tu(a)));if(o.length===0)return console.log(w("NO_PAN_YAML_WITH_COMMANDS")),console.log(w("NO_PAN_YAML_BUT_GIT_STILL_WORKS")),!1;try{for(;;){let i=await wR({message:w("MENU_SELECT_PROJECT"),choices:o.map((f,h)=>({name:Tu(f),value:h,description:`${ay(f).length} ${w("COMMANDS_LABEL")} \xB7 ${f.root}`})),hotkeys:[{key:"h",label:w("HELP_LABEL"),value:"__help__"},{key:"v",label:w("VERSION_LABEL"),value:"__version__"},{key:"x",label:w("EXIT_LABEL"),value:"__exit__"}]});if(i==="__exit__")return!0;if(i==="__version__"){console.log(`@pan-stack/cli ${t||"?"}`);continue}if(i==="__help__"){typeof e=="function"&&e();continue}let a=typeof i=="number"?o[i]:void 0;if(!a)continue;let s=ay(a),l=await wR({message:`[${Tu(a)}] ${w("MENU_SELECT_COMMAND")}`,choices:s.map(f=>({name:f.name+(f.aliases&&f.aliases.length?` (${f.aliases.join(", ")})`:"")+(f.hasTargets?` [${f.targets.join("|")}]`:""),value:f.name,description:f.description||""})),hotkeys:[{key:"b",label:w("BACK_LABEL"),value:"__back__"},{key:"x",label:w("EXIT_LABEL"),value:"__exit__"}]});if(l==="__exit__")return!0;if(l==="__back__")continue;let c=a.commands[String(l)],u=[];if(c&&c.targets&&Object.keys(c.targets).length>0){let f=Object.keys(c.targets),h=await wR({message:w("SELECT_TARGET__CMD",{cmd:l}),choices:[...f.map(p=>({name:p,value:p})),{name:w("DEFAULT_LABEL"),value:"__default__"}],hotkeys:[{key:"b",label:w("BACK_LABEL"),value:"__back__"}]});if(h==="__back__")continue;h!=="__default__"&&u.push(String(h))}console.error(`
1339
1339
  \u25B6 pan ${l}${u.length?" "+u.join(" "):""} (${WZ.default.basename(a.root)})
1340
1340
  `);let d=await BS(a,String(l),u);if(!(d&&d.backed))return!0}}catch(i){if(v9e(i))return console.error(`
1341
1341
  `+w("EXITED")),!0;throw i}}var WZ,qZ=ne(()=>{"use strict";WZ=Q(require("path"));Ps();vh();eR();kp();Ja();Eh();It()});function _R(e){var t="";return g9e.forEach(function(n){for(;e>=n[0];)t+=n[1],e-=n[0]}),t}function JZ(e,t){var n=new Map;function r(o,i){var a=0;o.forEach(function(s){if(s.coSo!==!1){var l=i.concat([++a]),c=l.slice(1).join(".");n.set(s.key,{heading:t==="thap-phan"?l.join(".")+".":l.length===1?_R(l[0])+".":l.join(".")+".",ref:t==="thap-phan"?l.join("."):l.length===1?_R(l[0]):l.join("."),depth:l.length}),r(s.children||[],l)}})}return r(e,[]),n}function T0(e){return String(e??"").replace(/[đĐ]/g,"d").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}function Bl(e){if(!e)return"";var t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return t?t[3]+"/"+t[2]+"/"+t[1]:String(e)}function yR(e){if(!e)return"";var t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);return t?t[3]+"/"+t[2]+"/"+t[1]+" "+t[4]+":"+t[5]:Bl(e)}function HS(e){var t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e);return t?Date.UTC(+t[1],+t[2]-1,+t[3])/864e5:NaN}function eee(e){return ZZ[e]||e}function YZ(e){return SR[e]||e}function Nh(e){return sa[e]||sa.vi}function Cp(e,t){return String(e).replace(/\{(\w+)\}/g,function(n,r){return t[r]==null?"":String(t[r])})}function pi(e,t,n={}){var r=Nh(e).lint||kR;return Cp(r[t]||kR[t]||t,n||{})}function _9e(e){return e!=null&&(Array.isArray(e)?e.length>0:typeof e=="string"?e.trim()!=="":!0)}function Np(e){return typeof e=="string"?e:e.ma}function xR(e){return typeof e=="string"?[]:e.con||[]}function $Z(e){return JSON.parse(JSON.stringify(e))}function Vd(e){var t=String(e),n=t.trim().replace(/^\[\[/,"").replace(/\]\]$/,""),r=null,o=n.indexOf("|");if(o>=0&&(r=n.slice(o+1).trim(),n=n.slice(0,o).trim()),n.charAt(0)==="?")return{raw:t,code:null,row:null,block:null,label:r,unregistered:!0,ten:n.slice(1).trim()};var i=null,a=null,s=n.indexOf("#");s>=0&&(i=n.slice(s+1).replace(/^"|"$/g,""),n=n.slice(0,s));var l=n.indexOf("/");return l>=0&&(a=n.slice(l+1),n=n.slice(0,l)),{raw:t,code:n.trim(),row:i,block:a?eee(a):null,label:r,unregistered:!1,ten:null}}function Sg(e){var t=[],n=String(e??""),r=0,o;for(QZ.lastIndex=0;o=QZ.exec(n);){o.index>r&&t.push({text:n.slice(r,o.index)});var i=Vd(o[1]),a=i.unregistered?"?"+i.ten:i.code+(i.block?"/"+i.block:"")+(i.row?"#"+i.row:"");t.push({ref:a,raw:o[0],code:i.code,row:i.row,block:i.block,label:i.label,unregistered:i.unregistered,ten:i.ten}),r=o.index+o[0].length}return r<n.length&&t.push({text:n.slice(r)}),t}function tee(e){var t=new Map,n=null;function r(){return Object.isFrozen(e)}function o(K,oe){var $=r()?t:n;if(!$||K==null)return oe();if($.has(K))return $.get(K);var se=oe();return $.set(K,se),se}function i(K){return function(){var oe=n;oe||(n=new Map);try{return K.apply(null,arguments)}finally{oe||(n=null)}}}function a(){return o("idx",function(){var K=new Map;return(e.items||[]).forEach(function(oe){K.set(oe.ma,oe)}),(e.tbd||[]).forEach(function(oe){K.set(oe.ma,oe)}),K})}function s(K){return T0(K).replace(/\s+/g,"")}function l(){return o("alias",function(){var K=new Map;return(e.items||[]).forEach(function(oe){(oe.biDanh||[]).forEach(function($){K.has(s($))||K.set(s($),oe.ma)})}),K})}function c(K){return K=K||{},{docId:K.docId||m(),variant:K.variant||"current",outlines:K.outlines||null,items:K.items||null}}function u(K){return K.outlines||K.items?null:K.docId+"|"+K.variant}function d(K,oe){return oe&&oe.items&&oe.items[K]||a().get(K)||null}function f(K){return K&&a().get(String(K).split(/[#/]/)[0])||null}function h(K){return(e.people||[]).filter(function(oe){return oe.id===K})[0]||null}function p(K){var oe=h(K);return oe?oe.ten:K||""}function v(K){return(e.docs||[]).filter(function(oe){return oe.ma===K})[0]||null}function m(){var K=(e.docs||[])[0];return K?K.ma:""}function g(){return Object.keys(e.outlines||{})[0]||""}function b(K){return(e.modules||[]).filter(function(oe){return oe.ma===K})[0]||null}function x(K,oe,$){if($&&$.outlines&&$.outlines[K])return $.outlines[K];var se=e.outlines&&e.outlines[K];return se?se[oe]||se.current||{}:{}}function y(K){var oe=[];function $(se){(se||[]).forEach(function(he){oe.push(Np(he)),$(xR(he))})}return Object.keys(K||{}).forEach(function(se){$(K[se])}),oe}function E(K,oe){if(!K)return!1;if(K.loai==="cho")return!0;if(K.daXoa)return!1;var $=e.outlines&&e.outlines[K.phanHe];return $&&$[oe]&&oe!=="current"?y($[oe]).indexOf(K.ma)>=0:!0}function _(K,oe){return!(K&&K.sauBan&&oe!=="current")}function T(K,oe,$){var se=eee(K),he=Nh($||e.lang);return oe&&he.blockShort[se]||he.blockTitle[se]||String(K)}function S(K){if(typeof K=="string"&&(K=f(K)),!K||K.loai==="cho"||K.daXoa||K.trangThai==="du-kien")return[];var oe=K.khoi||{},$=K.vanBan||{};return(w9e[K.loai]||[]).filter(function(se){return se[2]||_9e(oe[se[1]])||!!($[se[0]]&&String($[se[0]]).trim())}).map(function(se){return se[0]})}function A(K,oe,$,se,he){he=he||0;var xe=K&&K.khoi&&K.khoi[oe];if(!xe)return[];if(oe==="danhMuc")return(xe.dong||[]).slice();if(Array.isArray(xe))return xe.filter(function(Pe){return _(Pe,$)});if(xe.keThua&&he<5){var Le=d(xe.keThua.tu,se),Ne=A(Le,oe,$,se,he+1).map(function(Pe){return Object.assign({},Pe,{keThua:xe.keThua.tu})});return(xe.thayDoi||[]).forEach(function(Pe){var wt=-1;if(Ne.forEach(function(Ve,Et){wt<0&&Ve.ma===Pe.ma&&(wt=Et)}),Pe.bo)wt>=0&&Ne.splice(wt,1);else if(Pe.sua)wt>=0&&(Ne[wt]=Object.assign({},Ne[wt],Pe.sua,{thayDoi:"sua"}));else{var Me={ma:Pe.ma,ten:Pe.ten,kieu:Pe.kieu||"",batBuoc:!!Pe.batBuoc,macDinh:Pe.macDinh||"",nguon:Pe.nguon||null,mo:Pe.mo||null,moTa:Pe.moTa||"",thayDoi:"them"},ft=-1;Pe.sau&&Ne.forEach(function(Ve,Et){Ve.ma===Pe.sau&&(ft=Et)}),ft>=0?Ne.splice(ft+1,0,Me):Ne.push(Me)}}),Ne}return[]}function C(K,oe,$){var se=K&&K.khoi&&K.khoi[oe];return se?oe==="danhMuc"?(se.dong||[]).slice():Array.isArray(se)?se.filter(function(he){return!he.nhom&&_(he,$)}):(se.thayDoi||[]).filter(function(he){return!he.bo}).map(function(he){return he.sua?Object.assign({ma:he.ma},he.sua):he}):[]}function R(K,oe,$,se){for(var he=0;he<Ap.length;he++)for(var xe=A(K,Ap[he][0],$,se).filter(function(Ne){return!Ne.nhom}),Le=0;Le<xe.length;Le++)if(String(xe[Le].ma)===String(oe))return{row:xe[Le],block:Ap[he][1],index:Le+1,inherited:!!xe[Le].keThua&&xe[Le].thayDoi!=="them"};return null}function D(K,oe){var $=YZ(oe),se=K&&K.khoi&&K.khoi[$];if(!se||Array.isArray(se)||!se.keThua)return!1;var he=f(se.keThua.tu),xe=he&&he.bam&&he.bam[$];return!!xe&&xe!==se.keThua.daRaSoat}function U(K,oe){var $=[];if(!K||!K.khoi)return $;function se(he,xe){Sg(he).forEach(function(Le){Le.ref&&$.push(Object.assign({},xe,{ref:Le.ref,field:"moTa",text:he}))})}return Ap.forEach(function(he){var xe=K.khoi[he[0]];xe&&(xe.keThua&&$.push({tu:K.ma+"/"+he[1],ma:K.ma,row:null,block:he[1],ref:xe.keThua.tu+"/"+he[1],field:"keThua",text:""}),C(K,he[0],oe).forEach(function(Le){var Ne={tu:K.ma+"#"+Le.ma,ma:K.ma,row:Le.ma,block:he[1]};["mo","nguon","man"].forEach(function(Pe){Le[Pe]&&$.push(Object.assign({},Ne,{ref:Le[Pe],field:Pe,text:Le.moTa||""}))}),Le.moTa&&se(Le.moTa,Ne),Le.noiDung&&se(Le.noiDung,Ne)}))}),typeof K.khoi.mucDich=="string"&&se(K.khoi.mucDich,{tu:K.ma+"/muc-dich",ma:K.ma,row:null,block:"muc-dich"}),$}function L(K){var oe=f(K),$=0;if(!oe){var se=l().get(s(K));return se||K}for(;oe&&oe.daXoa&&oe.daXoa.gopVao&&$<5;)K=oe.daXoa.gopVao,oe=f(K),$++;return K}function I(K){var oe=v(K.docId);if(!oe)return[];var $=e.khung&&e.khung[oe.khung]||[],se=oe.phamVi||[];function he(Et){var ge=Np(Et),Qe=d(ge,K);if(!Qe||Qe.daXoa||Qe.loai==="cho")return null;var jt=S(Qe).map(function(cn){return{key:ge+"/"+cn,title:ER[cn],kind:"khoi",code:ge,block:cn,status:null,children:[]}});return xR(Et).forEach(function(cn){var it=he(cn);it&&jt.push(it)}),{key:ge,title:Qe.tieuDe,kind:Qe.loai,code:ge,block:null,status:Qe.trangThai,children:jt}}var xe=[];se.forEach(function(Et){xe=xe.concat(y(x(Et,K.variant,K)))});for(var Le=x("CHUNG",K.variant,K),Ne=y(Le),Pe={},wt=xe.slice(),Me={};wt.length;){var ft=wt.shift();if(!Me[ft]){Me[ft]=!0;var Ve=d(ft,K);Ve&&U(Ve,K.variant).forEach(function(Et){var ge=Vd(Et.ref);if(ge.code){var Qe=L(ge.code);Ne.indexOf(Qe)>=0&&!Pe[Qe]&&(Pe[Qe]=!0,wt.push(Qe))}})}}return $.map(function(Et){var ge="chuong:"+Et.id,Qe=[];if(Et.nguon&&(se.forEach(function(it){var Ct=x(it,K.variant,K),Qt=(Ct[Et.nguon]||[]).concat(Et.nguon==="chuc_nang"&&it!=="CHUNG"?Ct.muc||[]:[]);if(Qt.length){var lt=b(it);Qe.push({key:"phan-he:"+Et.id+":"+it,title:lt?lt.ten:it,kind:"phan-he",code:null,phanHe:it,block:null,status:null,children:Qt.map(he).filter(Boolean)})}}),Et.dungChung)){var jt=(Le.muc||[]).filter(function(it){return Pe[Np(it)]});if(jt.length){var cn=b("CHUNG");Qe.push({key:"phan-he:"+Et.id+":CHUNG",title:cn?cn.ten:"D\xF9ng chung",kind:"phan-he",code:null,phanHe:"CHUNG",block:null,status:null,children:jt.map(he).filter(Boolean)})}}return(Et.con||[]).forEach(function(it){var Ct={key:ge+"/"+it.id,title:it.ten,kind:"khung",code:null,block:null,status:null,children:[]};it.nguon&&(se.forEach(function(Qt){(x(Qt,K.variant,K)[it.nguon]||[]).forEach(function(lt){var mt=he(lt);mt&&Ct.children.push(mt)})}),(Le[it.nguon]||[]).forEach(function(Qt){if(Pe[Np(Qt)]){var lt=he(Qt);lt&&Ct.children.push(lt)}})),Qe.push(Ct)}),{key:ge,title:Et.ten,kind:"chuong",code:null,block:null,status:null,children:Qe}})}function B(K){var oe=u(K);return o(oe?"tree|"+oe:null,function(){return I(K)})}function M(K){var oe=u(K);return o(oe?"num|"+oe:null,function(){var $=v(K.docId);return JZ(B(K),$?$.kieuSo:"la-ma")})}function Y(K){return o("home|"+K,function(){for(var oe=e.docs||[],$=0;$<oe.length;$++)if(M(c({docId:oe[$].ma})).has(K))return oe[$].ma;return null})}function H(K){var oe=(e.baselines||[]).filter(function($){return $.taiLieu===K&&$.phatHanh});return oe.sort(function($,se){return $.ngay<se.ngay?-1:$.ngay>se.ngay?1:0}),oe[oe.length-1]||null}function j(K,oe){if(!oe)return H(K);var $=String(oe).replace(/^v/i,"");return(e.baselines||[]).filter(function(se){return se.taiLieu===K&&(se.phienBan===$||se.phienBan===$+".0")})[0]||null}function W(K,oe){var $=typeof K=="string"?Vd(K):K,se={ref:$.raw,label:$.label||null,code:$.code||null,row:$.row||null,block:$.block||null,target:null,number:null,itemNumber:null,homeDoc:null,homeNumber:null,homeVersion:null,via:null,reason:null,suspect:!1,rowInfo:null,targetState:null};if($.unregistered)return Object.assign(se,{state:"pending",targetState:"pending",reason:"chua-dang-ky",ten:$.ten});var he=$.code,xe=d(he,oe),Le=null,Ne=0;if(!xe){var Pe=l().get(s(he));Pe&&(xe=d(Pe,oe),Le={kieu:"bi-danh",tu:he},he=Pe)}for(;xe&&xe.daXoa;)if(xe.daXoa.gopVao&&Ne<5)Le=Le||{kieu:"gop",tu:he},he=xe.daXoa.gopVao,xe=d(he,oe),Ne++;else return Object.assign(se,{state:"broken",targetState:"broken",reason:Ne>=5?"vong-lap":"da-xoa",target:xe});if(!xe)return Object.assign(se,{state:"broken",targetState:"broken",reason:"khong-ton-tai"});if(xe.loai==="cho"){if(xe.trangThai==="da-giai"&&xe.giaiThanh){var wt=W(Object.assign({},$,{code:xe.giaiThanh}),oe);return wt.via={kieu:"muc-cho",tu:xe.ma},wt.ref=$.raw,wt}return xe.trangThai==="huy"?Object.assign(se,{state:"broken",targetState:"broken",reason:"muc-cho-huy",code:xe.ma,target:xe}):Object.assign(se,{state:"pending",targetState:"pending",code:xe.ma,target:xe})}var Me=null;if($.row&&(Me=R(xe,$.row,oe.variant,oe),!Me))return Object.assign(se,{state:"broken",targetState:"broken",reason:"khong-co-dong",code:he,target:xe,via:Le});if($.block&&S(xe).indexOf($.block)<0)return Object.assign(se,{state:"broken",targetState:"broken",reason:"khong-co-khoi",code:he,target:xe,via:Le});var ft=M(oe),Ve=$.block?he+"/"+$.block:he,Et,ge=null,Qe=null,jt=null,cn=null,it=null;if(ft.has(he))Qe=ft.get(he).ref,ge=(ft.get(Ve)||ft.get(he)).ref,jt=oe.docId,Et=xe.trangThai==="du-kien"?"planned":"ok";else{Et="external",jt=Y(he);var Ct=jt&&H(jt);Ct&&Ct.so&&Ct.so[he]&&(it=Ct.phienBan,cn=Ct.so[Ve]||Ct.so[he])}var Qt=$.block||Me&&Me.block||null,lt=!!(Qt&&D(xe,Qt));lt&&Et==="ok"&&(Et="suspect");var mt=Et;return Le&&(Et="alias"),Object.assign(se,{state:Et,targetState:mt,code:he,target:xe,via:Le,number:ge,itemNumber:Qe,homeDoc:jt,homeNumber:cn,homeVersion:it,suspect:lt,rowInfo:Me,planned:xe.trangThai==="du-kien"})}function X(K,oe,$){$=$||{};var se=v(oe.docId),he=Nh(se&&se.language||e.lang),xe=se&&se.mauThamChieu||he.refTpl,Le=he.q1,Ne=he.q2;if(K.state==="broken"){var Pe=K.reason==="khong-co-dong"||K.reason==="khong-co-khoi"?String(K.ref).replace(/^\[\[|\]\]$/g,""):K.code||String(K.ref);return(K.reason==="da-xoa"||K.reason==="muc-cho-huy"||K.reason==="vong-lap")&&(Pe=Vd(K.ref).code),{lead:null,full:Cp(he.notFound,{x:Pe})}}if(K.state==="pending"){if(K.reason==="chua-dang-ky")return{lead:null,full:Cp(he.tbdLoose,{ten:K.ten})};var wt=K.target;return $.mienTru?{lead:null,full:Cp(he.tbdWaived,{ten:wt.tenDuKien,ma:wt.ma})}:{lead:null,full:Cp(he.tbd,{ten:wt.tenDuKien,ma:wt.ma,nguoi:p(wt.phuTrach),han:Bl(wt.han)})}}var Me=K.target,ft=K.code,Ve=K.targetState==="external",Et=Me.trangThai==="du-kien"?he.planned:"";function ge(Ge,_e){return K.homeVersion?Cp(he.extVer,{head:Ge,ma:ft,so:_e,doc:K.homeDoc,ver:K.homeVersion}):Cp(he.extDraft,{head:Ge,ma:ft,doc:K.homeDoc||"?"})}function Qe(Ge,_e,qe){return Ve?ge(Ge+" "+Le+_e+Ne,qe||K.homeNumber):xe.replace("{loai}",Ge).replace("{ten}",_e).replace("{so}",qe).replace("{ma}",ft)}function jt(Ge,_e){return Ve?ge(Ge,K.homeNumber):xe.replace("{loai} "+Le+"{ten}"+Ne,Ge).replace("{loai} \xAB{ten}\xBB",Ge).replace("{so}",_e).replace("{ma}",ft)}var cn=he.loaiWord[Me.loai]||he.item,it=Ve?K.homeNumber:K.itemNumber;if(K.rowInfo){var Ct=K.rowInfo.row,Qt=/^(TB|PG|TS|MSG|BR|VR|F|T|P|B)\d/.exec(String(Ct.ma)),lt=Qt?Qt[1]:null;if(lt==="VR"||lt==="BR"||lt==="MSG")return{lead:null,full:Qe((lt==="MSG"?he.msg:he.rule)+Ct.ma,Ct.noiDung,it)+Et};var mt;return K.rowInfo.block==="danh-muc"?mt=he.value+" "+Le+Ct.ten+Ne+" ("+Ct.ma+")":lt==="TB"?mt=he.button+" "+Le+Ct.ten+Ne+" ("+Ct.ma+")":lt==="PG"?mt=he.func+" "+Le+Ct.ten+Ne+" ("+Ct.ma+")":lt==="B"?mt=he.step+" "+K.rowInfo.index+" "+Le+Ct.ten+Ne:lt==="TS"?mt=he.param+" "+Ct.ma+" "+Le+Ct.chuThich+Ne:mt=he.field+" "+Le+Ct.ten+Ne+" ("+Ct.ma+")",{lead:null,full:mt+he.of+Qe(cn,Me.tieuDe,it)+Et}}if(K.block){var We=Ve?K.homeNumber:K.number;return{lead:null,full:Cp(he.part,{t:he.blockTitle[K.block]})+Qe(cn,Me.tieuDe,We)+Et}}if(K.label)return{lead:null,full:jt(K.label,it)+Et};var gt=Me.hienThi==="popup"?"popup":cn,ve=Qe(gt,Me.tieuDe,it)+Et,ke=Ve||xe.indexOf("{loai} ")===0;return{lead:ke?gt:null,full:ve,rest:ke?ve.slice(gt.length+1):ve,family:Me.loai}}function q(K,oe,$){return X(W(K,oe),oe,$).full}function ee(K,oe){var $=T0(K),se=T0(oe);return $===se+" "||$.length>se.length+1&&$.slice(-(se.length+2))===" "+se+" "||$.slice(-(se.length+2))==="("+se+" "}function ie(K,oe,$){var se="";return Sg(K).forEach(function(he){if(he.text!=null&&!he.ref&&!he.unregistered){se+=he.text;return}var xe=X(W(he.raw,oe),oe,$);if(xe.lead){var Le=[xe.lead];xe.family==="man-hinh"&&(Le=Le.concat(["m\xE0n h\xECnh","popup","m\xE0n"]));for(var Ne=0;Ne<Le.length;Ne++)if(ee(se,Le[Ne])){se+=xe.rest;return}}se+=xe.full}),se}function fe(K,oe){oe=oe||"current";var $=[],se={},he=L(K);return(e.items||[]).forEach(function(xe){E(xe,oe)&&U(xe,oe).forEach(function(Le){var Ne=Vd(Le.ref);if(Ne.code){var Pe=Ne.code===K||L(Ne.code)===he;if(!Pe){var wt=a().get(Ne.code);if(!(wt&&wt.loai==="cho"&&wt.trangThai==="da-giai"&&wt.giaiThanh===K))return}var Me=Le.tu;se[Me]||(se[Me]={tu:Le.tu,ma:Le.ma,row:Le.row,block:Le.block,ref:Le.ref,fields:[],text:Le.text||"",quaBiDanh:Ne.code!==he&&Ne.code!==K},$.push(se[Me])),se[Me].fields.indexOf(Le.field)<0&&se[Me].fields.push(Le.field),!se[Me].text&&Le.text&&(se[Me].text=Le.text)}})}),$}function Fe(K,oe,$){var se=j(oe||m(),$);return se&&se.so&&se.so[K]||null}function pe(K){var oe=String(K).split("/")[0],$=Y(oe);if(!$)return null;var se=M(c({docId:$})).get(K);return se?se.ref:null}function Ze(K){var oe=String(K||"").trim(),$=[],se={},he=/^v(\d+(?:\.\d+)?)\s+([IVXivx]+(?:\.\d+)*|\d+(?:\.\d+)*)\.?$/.exec(oe),xe=/^word\s+(\d+(?:\.\d+)*)\.?$/i.exec(oe);function Le(Me,ft,Ve,Et){var ge=ft;if(!se[ge]){se[ge]=!0;var Qe=ft.split("/")[0],jt=ft.indexOf("/")>0?ft.split("/")[1]:null,cn=pe(ft),it=Et==="word"?"s\u1ED1 trong Word c\u0169 l\xE0 "+Ve+(Me&&Me.tep?" ("+Me.tep+")":"")+", nay l\xE0 "+(cn||"\u2014"):"\u1EDF b\u1EA3n "+Me.phienBan+" l\xE0 "+Ve+", nay l\xE0 "+(cn||"\u2014");$.push({key:ft,code:Qe,block:jt,docId:Me?Me.taiLieu:Y(Qe),phienBan:Me?Me.phienBan:null,so:Ve,nay:cn,sub:it,nguon:Et})}}if(he){var Ne=he[1],Pe=he[2].toUpperCase();(e.baselines||[]).forEach(function(Me){Me.nguon!=="word"&&(Me.phienBan===Ne||Me.phienBan===Ne+".0")&&Object.keys(Me.so||{}).forEach(function(ft){String(Me.so[ft]).toUpperCase()===Pe&&Le(Me,ft,Me.so[ft],"baseline")})})}if(xe){var wt=xe[1];(e.baselines||[]).forEach(function(Me){Me.nguon==="word"&&Object.keys(Me.so||{}).forEach(function(ft){Me.so[ft]===wt&&Le(Me,ft,wt,"word")})}),(e.items||[]).forEach(function(Me){Me.nguonNhap&&Me.nguonNhap.soCu===wt&&Le({taiLieu:Y(Me.ma),phienBan:"0",tep:Me.nguonNhap.tep},Me.ma,wt,"word")})}return $}function be(K){var oe=Vd(K),$=oe.code||"";if(/^TBD-/.test($))return"05-muc-cho-kiem-tra.html#"+$;var se=f($),he=oe.row?"/"+oe.row:oe.block?"/"+oe.block:"";return se&&se.loai==="man-hinh"?"03-soan-man-hinh.html#"+$+he:"02-khong-gian-phan-he.html#"+$+he}function Ye(K,oe){oe=oe||{};var $=oe.module||g(),se=oe.limit||40,he=String(K||"").trim();if(!he)return[];var xe=[];if(he.charAt(0)===">"){var Le=T0(he.slice(1)).trim();return(e.commands||[]).forEach(function(ge,Qe){var jt=T0(ge.title),cn=!Le||jt.indexOf(Le)>=0||(ge.khoa||[]).some(function(it){return it.indexOf(Le)===0||Le.indexOf(it)===0});cn&&xe.push({group:"L\u1EC7nh",title:ge.title,sub:ge.sub||"",code:null,href:ge.href,run:ge.id,score:900-Qe})}),xe.slice(0,se)}var Ne=T0(he).replace(/\s+/g," "),Pe=Ne.replace(/\s+/g,""),wt=Ne.split(" ").filter(Boolean);function Me(ge){return wt.length>1&&wt.every(function(Qe){return ge.indexOf(Qe)>=0})}Ze(he).forEach(function(ge){var Qe=f(ge.code);xe.push({group:"S\u1ED1 \u1EDF b\u1EA3n \u0111\xE3 giao",title:Qe?Qe.tieuDe:ge.code,sub:ge.sub,code:ge.key,href:be(ge.key),score:1e3})});var ft=/^([a-z]{2,3})[\s-]*(\d{1,4})$/.exec(Ne),Ve=(e.items||[]).concat(e.tbd||[]);Ve.forEach(function(ge){var Qe=T0(ge.ma),jt=T0(ge.tieuDe),cn=(ge.phanHe===$?50:0)+(ge.loai==="man-hinh"?10:0)-(ge.daXoa?300:0),it=0;if(Qe===Ne?it=950:Ne.length>=3&&Qe.indexOf(Ne)===0?it=800:/^\d+$/.test(Ne)&&Qe.slice(-(Math.max(3,Ne.length)+1))==="-"+(Ne.length<3?("00"+Ne).slice(-3):Ne)?it=700:ft&&Qe.indexOf(ft[1]+"-")===0&&parseInt(Qe.split("-").pop(),10)===parseInt(ft[2],10)?it=780:Ne.length>=3&&Qe.indexOf(Ne)>=0&&(it=600),jt===Ne?it=Math.max(it,850):Ne.length>=3&&jt.indexOf(Ne)>=0?it=Math.max(it,500):Me(jt)&&(it=Math.max(it,300)),it){var Ct=ge.loai==="cho"?null:pe(ge.ma),Qt=ge.loai==="cho"?"M\u1EE5c ch\u1EDD \xB7 "+p(ge.phuTrach)+" \xB7 h\u1EA1n "+Bl(ge.han):ge.daXoa?"\u0110\xE3 xo\xE1"+(ge.daXoa.gopVao?" \u2014 g\u1ED9p v\xE0o "+ge.daXoa.gopVao:""):(e.labels&&e.labels.loai[ge.hienThi==="popup"?"popup":ge.loai]||ge.loai)+(Ct?" \xB7 "+Ct:"")+" \xB7 "+(e.labels&&e.labels.trangThai[ge.trangThai]||ge.trangThai);xe.push({group:ge.loai==="cho"?"M\u1EE5c ch\u1EDD":"M\u1EE5c",title:ge.tieuDe,sub:Qt,code:ge.ma,href:be(ge.ma),score:it+cn})}var lt=(ge.biDanh||[]).concat(ge.nguonNhap&&ge.nguonNhap.maCu?[ge.nguonNhap.maCu]:[]);lt.forEach(function(mt){var We=s(mt);Pe.length>=3&&We.indexOf(Pe)>=0&&xe.push({group:"M\xE3 c\u0169",title:ge.tieuDe,sub:"M\xE3 c\u0169: "+mt,code:ge.ma,href:be(ge.ma),score:700+cn})}),Ap.forEach(function(mt){mt[0]!=="danhMuc"&&C(ge,mt[0],"current").forEach(function(We){var gt=We.ten||We.chuThich||We.noiDung;if(gt){var ve=T0(gt),ke=0;T0(ge.ma+"#"+We.ma)===Ne?ke=900:ve===Ne?ke=840:Ne.length>=3&&ve.indexOf(Ne)>=0?ke=450:Me(ve)&&(ke=250),ke&&xe.push({group:"Tr\u01B0\u1EDDng & n\xFAt",title:We.ma+" "+gt,sub:ge.ma+" \xB7 "+ge.tieuDe,code:ge.ma+"#"+We.ma,href:be(ge.ma+"#"+We.ma),score:ke+cn})}})})});var Et={};return xe.forEach(function(ge,Qe){ge._i=Qe;var jt=ge.group+"|"+ge.code;(!Et[jt]||Et[jt].score<ge.score)&&(Et[jt]=ge)}),Object.keys(Et).map(function(ge){return Et[ge]}).sort(function(ge,Qe){return Qe.score-ge.score||ge._i-Qe._i}).slice(0,se).map(function(ge){return delete ge._i,ge})}var dt=["E01","E02","E03","E04","E05","E06","E07","E08","W01","W02","W03","W04","W05","W06","W07","W08","W09","W10"];function Kt(K,oe,$){oe=oe==="phat-hanh"?"phat-hanh":"nhap";var se=c({docId:K,variant:$||"current"}),he=v(se.docId)||{},xe=M(se),Le=[],Ne={},Pe=oe==="phat-hanh";function wt(ge){var Qe=ge.charAt(0)==="E"?"error":"warn",jt=!1;ge.charAt(0)==="E"&&(jt=!0),ge==="W01"&&(jt=he.tbdKhiPhatHanh==="chan"),ge==="W03"&&(jt=!0),ge==="W08"&&(jt=he.duKienKhiPhatHanh==="chan"),(ge==="W05"||ge==="W09")&&!Pe&&(Qe="info");var cn=["E03","E04","E07","E08"].indexOf(ge)>=0;return{muc:Qe,chanPhatHanh:jt,chan:Pe?jt:cn}}function Me(ge,Qe){return pi(e.lang,ge,Qe)}function ft(ge,Qe,jt,cn,it){var Ct=ge+"|"+Qe+"|"+jt;Ne[Ct]||(Ne[Ct]=!0,Le.push(Object.assign({ma:ge,noi:Qe,dich:jt,cau:cn,href:be(Qe),suaNhanh:null},wt(ge),it||{})))}var Ve=[];xe.forEach(function(ge,Qe){var jt=d(Qe,se);jt&&jt.loai!=="cho"&&Qe.indexOf("/")<0&&Ve.push(Qe)});var Et={};return Ve.forEach(function(ge){var Qe=d(ge,se);if(U(Qe,se.variant).forEach(function(lt){var mt=W(lt.ref,se),We=Vd(lt.ref);if(mt.reason==="chua-dang-ky")ft("W03",lt.tu,"?"+We.ten,Me("W03",{ten:We.ten}));else if(mt.state==="broken"&&mt.reason==="khong-ton-tai")ft("E01",lt.tu,We.code,Me("E01",{code:We.code}),{suaNhanh:{kieu:"doi-ma",tu:We.code,sang:null}});else if(mt.state==="broken"&&(mt.reason==="da-xoa"||mt.reason==="vong-lap"))ft("E02",lt.tu,We.code,Me("E02_DELETED",{code:We.code,date:Bl(mt.target&&mt.target.daXoa&&mt.target.daXoa.luc).slice(0,5)}));else if(mt.state==="broken"&&mt.reason==="muc-cho-huy")ft("E02",lt.tu,We.code,Me("E02_CANCELLED",{code:We.code}));else if(mt.state==="broken")ft("E06",lt.tu,lt.ref,Me("E06",{part:We.row||We.block,code:We.code}));else if(mt.state==="pending"){var gt=mt.target;Et[gt.ma]=!0,ft("W01",lt.tu,gt.ma,Me("W01",{code:gt.ma,name:gt.tenDuKien,owner:p(gt.phuTrach),due:Bl(gt.han)})+(wt("W01").chanPhatHanh?Me("W01_BLOCK"):""))}mt.via&&(mt.via.kieu==="gop"||mt.via.kieu==="bi-danh")&&ft("W05",lt.tu,We.code,Me(mt.via.kieu==="gop"?"W05_MERGED":"W05_ALIAS",{code:We.code,to:mt.code}),{suaNhanh:{kieu:"doi-ma",tu:We.code,sang:mt.code}})}),Ap.forEach(function(lt){if(D(Qe,lt[1])){var mt=Qe.khoi[lt[0]].keThua.tu;ft("W04",ge+"/"+lt[1],mt+"/"+lt[1],Me("W04",{block:T(lt[1],!1,e.lang),code:ge,src:mt}),{suaNhanh:{kieu:"da-ra"}})}}),Qe.thietKe){var jt=(e.designs||[]).filter(function(lt){return lt.man===Qe.thietKe.man})[0];jt&&jt.bam!==Qe.thietKe.daRaSoat&&ft("W06",ge,jt.man,Me("W06",{code:ge,screen:jt.man,who:p(jt.suaBoi),at:yR(jt.suaLuc)}),{suaNhanh:{kieu:"cap-nhat-anh"}})}var cn=[];Ap.forEach(function(lt){C(Qe,lt[0],se.variant).forEach(function(mt){mt.moTa&&cn.push({tu:ge+"#"+mt.ma,text:mt.moTa}),mt.noiDung&&cn.push({tu:ge+"#"+mt.ma,text:mt.noiDung})})}),typeof(Qe.khoi||{}).mucDich=="string"&&cn.push({tu:ge+"/muc-dich",text:Qe.khoi.mucDich}),cn.forEach(function(lt){Sg(lt.text).forEach(function(mt){if(!(mt.ref||mt.unregistered))for(var We=/(^|[\s(«"])(mục\s+((?:[IVX]+\.)?\d+(?:\.\d+)+))\.?/g,gt;gt=We.exec(mt.text);){var ve=gt[3],ke=null;xe.forEach(function(Ge,_e){!ke&&_e.indexOf("/")<0&&d(_e,se)&&(Ge.heading===ve+"."||Ge.ref===ve)&&(ke={code:_e,ref:Ge.ref})}),ft("W07",lt.tu,ke?ke.code:ve,ke?Me("W07_HIT",{text:gt[2],code:ke.code,ref:ke.ref}):Me("W07_MISS",{text:gt[2]}),{suaNhanh:ke?{kieu:"doi-chu",tu:gt[2],sang:"[["+ke.code+"]]"}:null})}})}),Qe.trangThai==="du-kien"&&ft("W08",ge,ge,Me("W08",{code:ge,title:Qe.tieuDe,due:Qe.han?Me("W08_DUE",{due:Bl(Qe.han)}):""}));var it=[];if(Ap.forEach(function(lt){C(Qe,lt[0],se.variant).forEach(function(mt){for(var We=(mt.moTa||"")+" "+(mt.noiDung||""),gt=(We.match(XZ)||[]).length,ve=0;ve<gt;ve++)it.push(mt.ma)})}),typeof(Qe.khoi||{}).mucDich=="string")for(var Ct=(Qe.khoi.mucDich.match(XZ)||[]).length,Qt=0;Qt<Ct;Qt++)it.push(Nh(e.lang).purpose);it.length&&ft("W09",ge,ge,Me("W09",{code:ge,n:it.length,list:it.join(", ")}),{viTri:it})}),(e.tbd||[]).forEach(function(ge){if(ge.trangThai==="mo"){var Qe=String(ge.noiTao||"").split(/[#/]/)[0];if(!(!Et[ge.ma]&&!xe.has(Qe))){var jt=ge.han?HS(ge.han)-HS(e.today||VZ):null;!ge.phuTrach||!ge.han?ft("W02",ge.ma,ge.ma,Me(ge.phuTrach?"W02_NO_DUE":"W02_NO_OWNER",{code:ge.ma})):jt<0&&ft("W02",ge.ma,ge.ma,Me("W02_OVERDUE",{code:ge.ma,name:ge.tenDuKien,days:-jt,due:Bl(ge.han),owner:p(ge.phuTrach)}))}}}),Le.forEach(function(ge){ge.tongCung=Le.filter(function(Qe){return Qe.ma===ge.ma}).length}),Le.sort(function(ge,Qe){return dt.indexOf(ge.ma)-dt.indexOf(Qe.ma)}),Le}function ln(K,oe,$){$=$||"current";var se=Kt(K,oe,$),he=e.lint;if(!he||he.taiLieu!==K||(he.variant||"current")!==$)return se;var xe=[];return(he.dong||[]).forEach(function(Le){var Ne=se.filter(function(Pe){return Pe.ma===Le.ma&&Pe.noi===Le.noi&&(!Le.dich||Pe.dich===Le.dich)})[0];Ne&&xe.push(Object.assign({},Ne,Le.suaNhanh?{suaNhanh:Le.suaNhanh}:{}))}),xe}function Nn(K,oe){var $=typeof oe=="object"&&oe?oe:x(K,oe||"current"),se=b(K)||{ten:K,chuTri:""},he=["ma: "+K,"ten: "+se.ten,"chu_tri: "+se.chuTri,"outline:"];function xe(Ne){var Pe=f(Ne);return Pe?Pe.loai==="danh-muc"?"Danh m\u1EE5c "+Pe.tieuDe.charAt(0).toLowerCase()+Pe.tieuDe.slice(1):Pe.tieuDe:"(kh\xF4ng c\xF3 t\u1EC7p)"}function Le(Ne,Pe){Ne.forEach(function(wt){var Me=xR(wt),ft=new Array(Pe+1).join(" ")+"- "+Np(wt)+(Me.length?":":""),Ve=Math.max(25,ft.length+3);he.push(ft+new Array(Ve-ft.length+1).join(" ")+"# "+xe(Np(wt))),Me.length&&Le(Me,Pe+4)})}return["quy_trinh","chuc_nang","danh_muc","muc"].forEach(function(Ne){var Pe=$[Ne];!Pe||!Pe.length||(he.push(" "+Ne+":"),Le(Pe,4))}),he.join(`
@@ -4607,7 +4607,7 @@ tr.pb-flash > td { animation: pb-flash 1.2s ease-out 1 both; }
4607
4607
  `});var Uge=F((bNt,tlt)=>{tlt.exports=`// Pan BA UI (pan ba ui) \u2014 app ch\u1EA1y tr\xEAn d\u1EEF li\u1EC7u th\u1EADt c\u1EE7a repo BA. Khung: shell.js (window.PanBA). M\xF4 h\xECnh: model.js (ba-core).
4608
4608
  // S\u1EEDa (L2): edit.js \u2014 m\u1ECDi thay \u0111\u1ED5i ghi qua API c\u1EE5c b\u1ED9, m\xE1y \u0111\u1ECBnh d\u1EA1ng chu\u1EA9n v\xE0 ki\u1EC3m l\u1EA1i t\u1EC7p. Ch\u1EEF giao di\u1EC7n: i18n.js (T).
4609
4609
  import { createModel } from './model.js';
4610
- import { aiBanner, api, exportDialog, whoDialog, gitBar, initEdit, newItemDialog, openEditor, renderFeedback, renderMyWork, renderTbds } from './edit.js';
4610
+ import { addMenuItems, aiBanner, api, exportDialog, whoDialog, gitBar, initEdit, newItemDialog, openEditor, renderFeedback, renderMyWork, renderTbds } from './edit.js';
4611
4611
  import { askAi, commentCount, decorateWord, initAssist, loadComments, mountAi, mountComments, openComments, renderComments, renderCtx, studioDialog, importDialog } from './assist.js';
4612
4612
 
4613
4613
  const P = window.PanBA;
@@ -4777,14 +4777,16 @@ function renderTree() {
4777
4777
  const el = UI.left; el.replaceChildren();
4778
4778
  const sc = scope();
4779
4779
  if (!sc.length) { el.appendChild(h('div', { class: 'pb-empty' }, h('div', { class: 'pb-empty__title' }, T('Ph\xE2n h\u1EC7 ch\u01B0a c\xF3 m\u1EE5c trong h\u1ED3 s\u01A1 n\xE0y')))); return; }
4780
- const walk = (nodes) => h('ul', null, nodes.filter(isItem).map((n) => {
4780
+ const walk = (nodes, parent) => h('ul', null, nodes.filter(isItem).map((n) => {
4781
4781
  const it = M.item(n.code) || {};
4782
- const btn = h('button', { type: 'button', class: 'pbx-node', 'aria-current': String(ST.sel === n.code), 'data-testid': 'tree-' + n.code },
4782
+ const btn = h('button', { type: 'button', class: 'pbx-node', 'aria-current': String(ST.sel === n.code), 'data-testid': 'tree-' + n.code, title: T('Chu\u1ED9t ph\u1EA3i \u0111\u1EC3 th\xEAm m\u1EE5c t\u1EA1i \u0111\xE2y') },
4783
4783
  h('span', { class: 'pbx-node__num' }, num(n)), h('span', { class: 'pbx-node__code' }, n.code),
4784
4784
  h('span', { class: 'pbx-node__title' }, it.tieuDe || n.title || ''));
4785
4785
  btn.addEventListener('click', () => { location.hash = encodeURIComponent(n.code); });
4786
+ // chu\u1ED9t ph\u1EA3i (ho\u1EB7c ph\xEDm Menu / Shift+F10) \u21D2 th\xEAm m\u1EE5c ngay t\u1EA1i \u0111\xE2y
4787
+ btn.addEventListener('contextmenu', (e) => { e.preventDefault(); P.menu(btn, addMenuItems(n.code, parent), { placement: 'bottom-start', testid: 'tree-menu' }); });
4786
4788
  const kids = (n.children || []).filter(isItem);
4787
- return h('li', null, btn, kids.length ? walk(kids) : null);
4789
+ return h('li', null, btn, kids.length ? walk(kids, n.code) : null);
4788
4790
  }));
4789
4791
  for (const ch of sc) {
4790
4792
  el.appendChild(h('div', { class: 'pbx-tree__head' }, (ch.number ? ch.number.heading : '') + ' ' + ch.title));
@@ -4871,16 +4873,19 @@ function renderWork(el) {
4871
4873
  el.appendChild(h('h2', { class: 'pbx-ch' }, (ch.number ? ch.number.heading + ' ' : '') + ch.title));
4872
4874
  for (const g of ch.children) {
4873
4875
  if (g.kind === 'phan-he') el.appendChild(h('h3', { class: 'pbx-ph' }, num(g) + ' ' + g.title));
4874
- const walk = (nodes) => nodes.filter(isItem).forEach((n) => {
4876
+ const walk = (nodes, parent) => nodes.filter(isItem).forEach((n) => {
4875
4877
  const it = M.item(n.code) || {};
4876
4878
  const edit = h('button', { type: 'button', class: 'pb-btn pb-btn--ghost pbx-item__edit', 'data-testid': 'sua-' + n.code, title: T('S\u1EEDa m\u1EE5c n\xE0y'), html: P.icon('edit', { size: 16 }) + ' ' + T('S\u1EEDa') });
4879
+ // \xAB+ Th\xEAm\xBB ngay tr\xEAn th\u1EBB: th\xEAm m\xE0n v\xE0o ch\u1EE9c n\u0103ng, th\xEAm ch\u1EE9c n\u0103ng sau, th\xEAm c\xF9ng lo\u1EA1i sau\u2026 \u2014 kh\xF4ng ph\u1EA3i cu\u1ED9n l\xEAn \u0111\u1EA7u trang
4880
+ const add = h('button', { type: 'button', class: 'pb-btn pb-btn--ghost pbx-item__add', 'data-testid': 'them-' + n.code, title: T('Th\xEAm m\u1EE5c t\u1EA1i \u0111\xE2y'), 'aria-label': T('Th\xEAm m\u1EE5c t\u1EA1i \u0111\xE2y'), html: P.icon('plus', { size: 16 }) + ' ' + T('Th\xEAm') });
4881
+ add.addEventListener('click', (e) => { e.stopPropagation(); P.menu(add, addMenuItems(n.code, parent), { placement: 'bottom-end', testid: 'card-add-menu' }); });
4877
4882
  const cmN = commentCount(n.code);
4878
4883
  const cm = h('button', { type: 'button', class: 'pb-btn pb-btn--ghost pbx-item__cm' + (cmN ? ' has-open' : ''), 'data-testid': 'cm-badge-' + n.code, title: T('B\xECnh lu\u1EADn'), 'aria-label': T('B\xECnh lu\u1EADn') + (cmN ? ' (' + cmN + ')' : ''), html: P.icon('message', { size: 16 }) + (cmN ? ' ' + cmN : '') });
4879
4884
  cm.addEventListener('click', (e) => { e.stopPropagation(); openComments(n.code); });
4880
4885
  const ai = h('button', { type: 'button', class: 'pb-btn pb-btn--ghost pbx-item__ai', 'data-testid': 'ai-' + n.code, title: T('Nh\u1EDD AI'), html: P.icon('sparkles', { size: 16 }) + ' ' + T('Nh\u1EDD AI') });
4881
4886
  ai.addEventListener('click', (e) => { e.stopPropagation(); select(n.code, false); aiMenu(ai, n.code, it); });
4882
4887
  const card = h('section', { class: 'pb-card pbx-item', id: 'item-' + n.code, 'data-testid': 'item-' + n.code },
4883
- h('div', { class: 'pbx-item__head' }, h('span', { class: 'pbx-item__num' }, num(n)), h('span', { class: 'pb-code' }, n.code), h('b', null, it.tieuDe || n.title), P.badge(it.trangThai), cm, ai, edit));
4888
+ h('div', { class: 'pbx-item__head' }, h('span', { class: 'pbx-item__num' }, num(n)), h('span', { class: 'pb-code' }, n.code), h('b', null, it.tieuDe || n.title), P.badge(it.trangThai), cm, ai, add, edit));
4884
4889
  edit.addEventListener('click', (e) => { e.stopPropagation(); select(n.code, false); openEditor(n.code, card); });
4885
4890
  if (it.trangThai === 'du-kien') card.appendChild(h('p', { class: 'pb-muted' }, T('M\u1EE5c d\u1EF1 ki\u1EBFn: \u0111\xE3 c\xF3 m\xE3 v\xE0 ch\u1ED7 trong outline, ch\u01B0a \u0111\u1EB7c t\u1EA3.')));
4886
4891
  const intro = prose(it.gioiThieu, 'intro-' + n.code); if (intro) card.appendChild(intro);
@@ -4895,7 +4900,7 @@ function renderWork(el) {
4895
4900
  }
4896
4901
  card.addEventListener('click', (e) => { if (!e.target.closest('a,button,input,textarea,select') && !card.classList.contains('is-editing')) select(n.code, false); });
4897
4902
  el.appendChild(card);
4898
- walk((n.children || []).filter(isItem));
4903
+ walk((n.children || []).filter(isItem), n.code);
4899
4904
  });
4900
4905
  walk(g.children || []);
4901
4906
  }
@@ -5509,13 +5514,35 @@ async function move(code, dir) {
5509
5514
  }
5510
5515
 
5511
5516
  // ---------------------------------------------------------------- th\xEAm m\u1EE5c
5512
- export function newItemDialog(module) {
5517
+ // \xABTh\xEAm t\u1EA1i ch\u1ED7\xBB (10/11/2026): chu\u1ED9t ph\u1EA3i m\u1ED9t m\u1EE5c tr\xEAn c\xE2y, ho\u1EB7c n\xFAt \xAB+ Th\xEAm\xBB tr\xEAn th\u1EBB m\u1EE5c \u21D2 menu theo ng\u1EEF c\u1EA3nh; ch\u1ECDn xong h\u1ED9p
5518
+ // \xABTh\xEAm m\u1EE5c\xBB \u0111\xE3 \u0111i\u1EC1n s\u1EB5n lo\u1EA1i + v\u1ECB tr\xED, ch\u1EC9 c\xF2n g\xF5 ti\xEAu \u0111\u1EC1 r\u1ED3i Enter. \`parent\` = m\u1EE5c cha trong outline (n\u1EBFu c\xF3).
5519
+ const TYPE_OF = { 'man-hinh': 'screen', 'chuc-nang': 'function', 'quy-trinh': 'process', 'danh-muc': 'catalog', 'mau-bieu': 'form', 'muc': 'section' };
5520
+ const TYPE_LABEL = { screen: 'm\xE0n h\xECnh', function: 'ch\u1EE9c n\u0103ng', process: 'quy tr\xECnh', catalog: 'danh m\u1EE5c', form: 'm\u1EABu bi\u1EC3u', section: 'm\u1EE5c v\u0103n b\u1EA3n' };
5521
+ export function addMenuItems(code, parent) {
5522
+ const it = C.M().item(code); if (!it) return [];
5523
+ const mod = it.phanHe; const same = TYPE_OF[it.loai];
5524
+ const go = (type, place, testid) => ({ label: T('Th\xEAm {t} ' + (place.startsWith('parent:') ? 'v\xE0o' : 'sau') + ' {c}', { t: T(TYPE_LABEL[type]), c: place.split(':')[1] }), icon: 'plus', testid, run: () => newItemDialog(mod, { type, place }) });
5525
+ const items = [{ heading: code + ' \xB7 ' + (it.tieuDe || '') }];
5526
+ if (it.loai === 'chuc-nang') items.push(go('screen', 'parent:' + code, 'add-child-screen'), go('function', 'after:' + code, 'add-after-function'));
5527
+ else if (it.loai === 'man-hinh') {
5528
+ items.push(go('screen', 'after:' + code, 'add-after-screen'), go('form', 'parent:' + code, 'add-child-form'), go('screen', 'parent:' + code, 'add-child-screen'));
5529
+ const p = parent ? C.M().item(parent) : null;
5530
+ if (p && p.loai === 'chuc-nang') items.push(go('function', 'after:' + parent, 'add-after-function'));
5531
+ } else if (it.loai === 'quy-trinh') items.push(go('process', 'after:' + code, 'add-after-process'), go('screen', 'parent:' + code, 'add-child-screen'));
5532
+ else if (same) items.push(go(same, 'after:' + code, 'add-after-' + same));
5533
+ return items;
5534
+ }
5535
+
5536
+ export function newItemDialog(module, preset) {
5513
5537
  const h = C.h; const D = C.D(); const M = C.M();
5538
+ preset = preset || {};
5514
5539
  const mine = D.items.filter((x) => x.phanHe === module && x.trangThai !== 'da-xoa');
5515
- const typeIn = select([['screen', T('M\xE0n h\xECnh')], ['function', T('Ch\u1EE9c n\u0103ng')], ['process', T('Quy tr\xECnh')], ['catalog', T('Danh m\u1EE5c')], ['form', T('M\u1EABu bi\u1EC3u')], ['section', T('M\u1EE5c v\u0103n b\u1EA3n')]], 'screen', { 'data-testid': 'new-type' });
5540
+ const typeIn = select([['screen', T('M\xE0n h\xECnh')], ['function', T('Ch\u1EE9c n\u0103ng')], ['process', T('Quy tr\xECnh')], ['catalog', T('Danh m\u1EE5c')], ['form', T('M\u1EABu bi\u1EC3u')], ['section', T('M\u1EE5c v\u0103n b\u1EA3n')]], preset.type || 'screen', { 'data-testid': 'new-type' });
5516
5541
  const titleIn = h('input', { class: 'pb-input', 'data-testid': 'new-title' });
5517
5542
  const parents = mine.filter((x) => x.loai === 'chuc-nang' || x.loai === 'quy-trinh' || x.loai === 'man-hinh');
5518
- const placeIn = select([['', T('Cu\u1ED1i nh\xF3m (theo lo\u1EA1i)')]].concat(parents.map((x) => ['parent:' + x.ma, T('D\u01B0\u1EDBi') + ' ' + x.ma + ' \xB7 ' + x.tieuDe])).concat(mine.map((x) => ['after:' + x.ma, T('Sau') + ' ' + x.ma + ' \xB7 ' + x.tieuDe])), parents[0] ? 'parent:' + parents[0].ma : '', { 'data-testid': 'new-place' });
5543
+ const placeIn = select([['', T('Cu\u1ED1i nh\xF3m (theo lo\u1EA1i)')]].concat(parents.map((x) => ['parent:' + x.ma, T('D\u01B0\u1EDBi') + ' ' + x.ma + ' \xB7 ' + x.tieuDe])).concat(mine.map((x) => ['after:' + x.ma, T('Sau') + ' ' + x.ma + ' \xB7 ' + x.tieuDe])), preset.place || (parents[0] ? 'parent:' + parents[0].ma : ''), { 'data-testid': 'new-place' });
5544
+ // g\xF5 ti\xEAu \u0111\u1EC1 xong b\u1EA5m Enter = T\u1EA1o m\u1EE5c
5545
+ titleIn.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); const b = document.querySelector('[data-testid="new-create"]'); if (b) b.click(); } });
5519
5546
  // Ch\u01B0a c\xF3 ph\xE2n h\u1EC7 m\u1EABu \u21D2 m\u1EDDi th\xEAm: m\u1ED7i lo\u1EA1i \u1EDF \xF4 \xABLo\u1EA1i\xBB m\u1ED9t m\u1EE5c vi\u1EBFt s\u1EB5n \u0111\u1EC3 xem c\xE1ch vi\u1EBFt (10/11/2026)
5520
5547
  let dlg = null;
5521
5548
  const demo = D.modules.some((m) => m.ma === 'MAU') ? null : h('div', { class: 'pbx-aibanner', 'data-testid': 'demo-offer' },
@@ -5529,8 +5556,8 @@ export function newItemDialog(module) {
5529
5556
  C.P.module(r.json.module);
5530
5557
  }) }));
5531
5558
  dlg = C.P.dialog({
5532
- title: T('Th\xEAm m\u1EE5c v\xE0o ph\xE2n h\u1EC7 {m}', { m: module }), size: 'md', testid: 'new-dialog',
5533
- body: h('div', { class: 'pb-stack' }, demo, field(T('Lo\u1EA1i'), typeIn), field(T('Ti\xEAu \u0111\u1EC1'), titleIn), field(T('V\u1ECB tr\xED trong outline'), placeIn),
5559
+ title: preset.place ? T('Th\xEAm {t} ' + (preset.place.startsWith('parent:') ? 'v\xE0o' : 'sau') + ' {c}', { t: T(TYPE_LABEL[preset.type] || 'm\u1EE5c'), c: preset.place.split(':')[1] }) : T('Th\xEAm m\u1EE5c v\xE0o ph\xE2n h\u1EC7 {m}', { m: module }), size: 'md', testid: 'new-dialog',
5560
+ body: h('div', { class: 'pb-stack' }, preset.place ? null : demo, field(T('Lo\u1EA1i'), typeIn), field(T('Ti\xEAu \u0111\u1EC1'), titleIn), field(T('V\u1ECB tr\xED trong outline'), placeIn),
5534
5561
  h('p', { class: 'pb-small pb-muted' }, T('M\xE3 l\u1EA5y t\u1EEB l\xF4 BA Lead \u0111\xE3 c\u1EA5p cho b\u1EA1n (code-registry.yaml); s\u1ED1 m\u1EE5c t\u1EF1 t\xEDnh.'))),
5535
5562
  actions: [
5536
5563
  { label: T('Hu\u1EF7'), kind: 'ghost' },
@@ -6056,7 +6083,8 @@ function fbCard(s, cur, numbers) {
6056
6083
  'Pan BA ghi t\xEAn ng\u01B0\u1EDDi ph\u1EE5 tr\xE1ch v\xE0 ng\u01B0\u1EDDi s\u1EEDa v\xE0o t\u1EEBng m\u1EE5c. \u0110i\u1EC1n th\xF4ng tin c\u1EE7a b\u1EA1n \u2014 l\u01B0u v\xE0o th\xE0nh vi\xEAn d\u1EF1 \xE1n (.panba.yaml), nh\u1EDB \xABL\u01B0u phi\xEAn b\u1EA3n\xBB \u0111\u1EC3 \u0111\u1ED3ng \u0111\u1ED9i c\u0169ng th\u1EA5y.': 'Pan BA records the owner and editor of every item. Enter your details \u2014 saved to the project members (.panba.yaml); remember to \xABSave version\xBB so teammates see it too.',
6057
6084
  '\u0110\xE3 th\xEAm {n} v\xE0o th\xE0nh vi\xEAn d\u1EF1 \xE1n.': 'Added {n} to the project members.', 'Ch\u01B0a c\xF3 m\xE3 tr\u1ED1ng cho b\u1EA1n': 'No free code for you', 'C\u1EA5p l\xF4 v\xE0 t\u1EA1o m\u1EE5c': 'Allocate a lot and create',
6058
6085
  'T\u1EF1 c\u1EA5p m\u1ED9t l\xF4 10 m\xE3 n\u1ED1i ti\u1EBFp m\xE3 l\u1EDBn nh\u1EA5t c\u1EE7a ph\xE2n h\u1EC7 {m}. L\xF4 ghi t\xEAn b\u1EA1n l\xE0 ng\u01B0\u1EDDi c\u1EA5p trong code-registry.yaml \u2014 BA Lead th\u1EA5y khi r\xE0 phi\xEAn b\u1EA3n.': 'Allocate yourself a lot of 10 codes after the highest code of module {m}. The lot records you as the allocator in code-registry.yaml \u2014 the BA Lead sees it when reviewing versions.',
6059
- '\u0110\xE3 c\u1EA5p l\xF4 {a} \u2026 {b}.': 'Allocated lot {a} \u2026 {b}.', '\u0110\u1ECBnh d\u1EA1ng': 'Formatting', 'In \u0111\u1EADm (Ctrl+B)': 'Bold (Ctrl+B)', 'In nghi\xEAng (Ctrl+I)': 'Italic (Ctrl+I)',
6086
+ '\u0110\xE3 c\u1EA5p l\xF4 {a} \u2026 {b}.': 'Allocated lot {a} \u2026 {b}.', 'Th\xEAm {t} v\xE0o {c}': 'Add {t} under {c}', 'Th\xEAm {t} sau {c}': 'Add {t} after {c}', 'm\xE0n h\xECnh': 'screen', 'ch\u1EE9c n\u0103ng': 'function', 'quy tr\xECnh': 'process', 'danh m\u1EE5c': 'catalog', 'm\u1EABu bi\u1EC3u': 'form', 'm\u1EE5c v\u0103n b\u1EA3n': 'text section', 'm\u1EE5c': 'item',
6087
+ 'Th\xEAm m\u1EE5c t\u1EA1i \u0111\xE2y': 'Add an item here', 'Chu\u1ED9t ph\u1EA3i \u0111\u1EC3 th\xEAm m\u1EE5c t\u1EA1i \u0111\xE2y': 'Right-click to add an item here', '\u0110\u1ECBnh d\u1EA1ng': 'Formatting', 'In \u0111\u1EADm (Ctrl+B)': 'Bold (Ctrl+B)', 'In nghi\xEAng (Ctrl+I)': 'Italic (Ctrl+I)',
6060
6088
  'G\u1EA1ch \u0111\u1EA7u d\xF2ng': 'Bulleted list', 'Danh s\xE1ch s\u1ED1': 'Numbered list', 'M\xE0n h\xECnh trong d\u1EF1 \xE1n': 'Screens in the project', '\u0110\xE3 d\xF9ng trong d\u1EF1 \xE1n': 'Used in the project', 'Ki\u1EC3u ph\u1ED5 bi\u1EBFn': 'Common types', 'Vai trong d\u1EF1 \xE1n': 'Roles in the project',
6061
6089
  '\xF4 nh\u1EADp m\u1ED9t d\xF2ng': 'single-line input', 'nhi\u1EC1u d\xF2ng': 'multi-line', 's\u1ED1': 'number', 'ti\u1EC1n': 'money', 'ng\xE0y': 'date', 'ng\xE0y gi\u1EDD': 'date & time', 'kho\u1EA3ng ng\xE0y': 'date range', 'gi\u1EDD': 'time',
6062
6090
  'ch\u1ECDn m\u1ED9t, c\xF3 t\xECm': 'pick one, searchable', 'ch\u1ECDn nhi\u1EC1u': 'pick many', 'ch\u1ECDn m\u1ED9t, hi\u1EC7n h\u1EBFt': 'pick one, all shown', 'c\xF3 / kh\xF4ng': 'yes / no', 'b\u1EADt / t\u1EAFt': 'on / off',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pan",
3
3
  "displayName": "PAN",
4
- "version": "0.3.61",
4
+ "version": "0.3.62",
5
5
  "description": "Harness cho workspace PAN Stack: mọi commit của Claude mang danh tính AI + người chủ quản + máy; nguồn tài liệu (Pan Lineage) của tệp hiện ra trước khi sửa.",
6
6
  "author": {
7
7
  "name": "n46-labs"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pan",
3
- "version": "0.3.61",
3
+ "version": "0.3.62",
4
4
  "description": "PAN Stack harness for AI agents: every commit carries AI + owner + machine identity, document sources (Pan Lineage) show before edits, and PAN skills load on their own.",
5
5
  "author": {
6
6
  "name": "n46-labs"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pan",
3
3
  "displayName": "PAN",
4
- "version": "0.3.61",
4
+ "version": "0.3.62",
5
5
  "description": "PAN Stack harness for AI agents: every commit carries AI + owner + machine identity, document sources (Pan Lineage) show before edits, and PAN skills load on their own.",
6
6
  "author": {
7
7
  "name": "n46-labs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pan-stack/cli",
3
- "version": "0.3.61",
3
+ "version": "0.3.62",
4
4
  "description": "PAN Stack CLI — multi-repo git and project commands from .project.yaml",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "bin": {