lula2 0.6.2-nightly.1 → 0.6.3-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_app/immutable/chunks/{DsS_Ymqb.js → CnwkJbO2.js} +1 -1
- package/dist/_app/immutable/chunks/{DYH881pG.js → MTDiNHJy.js} +1 -1
- package/dist/_app/immutable/chunks/{D9NS9sy6.js → rc9CiIba.js} +2 -2
- package/dist/_app/immutable/entry/{app.C2_q7ef5.js → app.C9fkwjMz.js} +2 -2
- package/dist/_app/immutable/entry/start.D2hMBZNv.js +1 -0
- package/dist/_app/immutable/nodes/{0.7TiLCc65.js → 0.DTEvfwsS.js} +1 -1
- package/dist/_app/immutable/nodes/{1.qK8_Tc6M.js → 1.CVMum2jU.js} +1 -1
- package/dist/_app/immutable/nodes/{2.C0l3mgWP.js → 2.D-DlyZaW.js} +1 -1
- package/dist/_app/immutable/nodes/{3.bzLm8zUT.js → 3.CEMIejLc.js} +1 -1
- package/dist/_app/immutable/nodes/4.BRRWt-Y5.js +11 -0
- package/dist/_app/version.json +1 -1
- package/dist/cli/commands/crawl.js +90 -151
- package/dist/cli/commands/ui.js +45 -6
- package/dist/cli/server/index.js +45 -6
- package/dist/cli/server/server.js +45 -6
- package/dist/cli/server/spreadsheetRoutes.js +44 -5
- package/dist/cli/server/websocketServer.js +45 -6
- package/dist/index.html +6 -6
- package/dist/index.js +136 -151
- package/package.json +2 -2
- package/src/lib/components/setup/SpreadsheetImport.svelte +40 -15
- package/dist/_app/immutable/entry/start.CPOuKwpy.js +0 -1
- package/dist/_app/immutable/nodes/4.5BLVnpgw.js +0 -11
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import{aR as he,p as U,am as S,d as h,T as L,G as _,h as i,an as X,ao as A,c as r,n as P,r as a,b as p,e as Y,J as O,K as N,aj as le,a as K,f as I,ap as ze,g as ie,a0 as we,u as Ee,aq as Se,b0 as Le,s as $,i as He,o as Ae,b1 as De,b2 as ye}from"../chunks/DTWPdvjs.js";import{l as H,p as C,i as E,a as be,s as ke}from"../chunks/BXUi170M.js";import{g as Pe}from"../chunks/
|
|
1
|
+
import"../chunks/DsnmJJEf.js";import{aR as he,p as U,am as S,d as h,T as L,G as _,h as i,an as X,ao as A,c as r,n as P,r as a,b as p,e as Y,J as O,K as N,aj as le,a as K,f as I,ap as ze,g as ie,a0 as we,u as Ee,aq as Se,b0 as Le,s as $,i as He,o as Ae,b1 as De,b2 as ye}from"../chunks/DTWPdvjs.js";import{l as H,p as C,i as E,a as be,s as ke}from"../chunks/BXUi170M.js";import{g as Pe}from"../chunks/rc9CiIba.js";import{a as je,p as Re,D as Ne}from"../chunks/CnwkJbO2.js";import{i as q}from"../chunks/Cq7PwVfU.js";import{a as ee,f as Ce,e as Te,d as Ve,i as Be,w as ce}from"../chunks/e7OeeeKP.js";he(["change"]);var Oe=A("<title> </title>"),Ue=A('<svg><!><path d="M11.41 26.59L7.83 23 28 23 28 21 7.83 21 11.41 17.41 10 16 4 22 10 28 11.41 26.59zM28 10L22 4 20.59 5.41 24.17 9 4 9 4 11 24.17 11 20.59 14.59 22 16 28 10z"></path></svg>');function Ye(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=Ue();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=Oe(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(),a(n),p(v,n),Y()}var Ie=I('<a href="/setup" class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors" title="Switch control set"><!> Switch</a>'),Ge=I('<div class="text-sm text-gray-500 dark:text-gray-400">Loading...</div>');function Fe(v,t){U(t,!1);const e=()=>be(Ce,"$appState",y),[y,o]=ke();q();var m=le(),g=K(m);{var s=l=>{var b=Ie(),d=r(b);Ye(d,{size:16}),P(),a(b),p(l,b)},n=l=>{var b=Ge();p(l,b)};E(g,l=>{e().isConnected?l(s):l(n,!1)})}p(v,m),Y(),o()}var Ze=A("<title> </title>"),Je=A('<svg><!><path d="M17.4141 16L24 9.4141 22.5859 8 16 14.5859 9.4143 8 8 9.4141 14.5859 16 8 22.5859 9.4143 24 16 17.4141 22.5859 24 24 22.5859 17.4141 16z"></path></svg>');function Ke(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=Je();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=Ze(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(),a(n),p(v,n),Y()}function qe(v,t){v.target===v.currentTarget&&t()}var We=(v,t)=>v.key==="Escape"&&t(),Qe=v=>v.stopPropagation(),Xe=I("<option> </option>"),et=I(`<div class="fixed inset-0 bg-gray-700 dark:bg-gray-900 bg-opacity-50 dark:bg-opacity-75 overflow-y-auto h-full w-full z-50 flex items-center justify-center p-4" role="dialog" aria-modal="true" tabindex="-1"><div class="bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-md mx-auto" role="document"><div class="flex items-center justify-between mb-4"><h2 class="text-xl font-semibold text-gray-900 dark:text-white"> </h2> <button class="text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300" aria-label="Close dialog"><!></button></div> <div class="mb-6"><p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Choose which column should contain the mappings data:</p> <div class="space-y-2"><label for="column-select" class="block text-sm font-medium text-gray-700 dark:text-gray-300">Mappings Column</label> <select id="column-select" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"></select></div> <div class="mt-3 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-md"><p class="text-xs text-blue-600 dark:text-blue-400"><strong>Note:</strong> Mappings data will be formatted as "status: description..." in the
|
|
2
2
|
selected column.</p></div></div> <div class="flex justify-end space-x-3"><button class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">Cancel</button> <button class="px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 rounded-lg transition-colors"> </button></div></div></div>`);function tt(v,t){U(t,!0);let e=C(t,"isOpen",15),y=C(t,"columnHeaders",19,()=>[]),o=C(t,"defaultColumn",3,"Mappings");const m=ze();let g=ie(we(o()));Ee(()=>{e()&&h(g,o())});function s(z){return e()&&setTimeout(()=>z.focus(),0),{update(D){D&&setTimeout(()=>z.focus(),0)}}}function n(){m("export",{format:t.format,mappingsColumn:i(g)}),e(!1)}function l(){m("cancel"),e(!1)}function b(z){z.key==="Escape"?l():z.key==="Enter"&&n()}var d=le();Se("keydown",Le,b);var c=K(d);{var k=z=>{var D=et();D.__click=[qe,l],D.__keydown=[We,l];var te=r(D);te.__click=[Qe];var ae=r(te),re=r(ae),ue=r(re);a(re);var f=$(re,2);f.__click=l;var x=r(f);Ke(x,{class:"w-6 h-6"}),a(f),a(ae);var u=$(ae,2),M=$(r(u),2),w=$(r(M),2);Te(w,21,y,Be,(j,G)=>{var F=Xe(),ge=r(F,!0);a(F);var de={};O(()=>{N(ge,i(G).label),de!==(de=i(G).value)&&(F.value=(F.__value=i(G).value)??"")}),p(j,F)}),a(w),je(w,(j,G)=>s?.(j),e),He(()=>Ve(w,()=>i(g),j=>h(g,j))),a(M),P(2),a(u);var T=$(u,2),J=r(T);J.__click=l;var W=$(J,2);W.__click=n;var ve=r(W);a(W),a(T),a(te),a(D),O((j,G)=>{N(ue,`Export as ${j??""}`),N(ve,`Export ${G??""}`)},[()=>t.format.toUpperCase(),()=>t.format.toUpperCase()]),p(z,D)};E(c,z=>{e()&&z(k)})}p(v,d),Y()}he(["click","keydown"]);var at=A("<title> </title>"),rt=A('<svg><!><path d="M31 16L24 23 22.59 21.59 28.17 16 22.59 10.41 24 9 31 16zM1 16L8 9 9.41 10.41 3.83 16 9.41 21.59 8 23 1 16z"></path><path d="M5.91 15H26.080000000000002V17H5.91z" transform="rotate(-75 15.996 16)"></path></svg>');function ot(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=rt();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=at(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(2),a(n),p(v,n),Y()}var st=A("<title> </title>"),nt=A('<svg><!><path d="M13 21L26.17 21 23.59 23.59 25 25 30 20 25 15 23.59 16.41 26.17 19 13 19 13 21z"></path><path d="M22,14V10a1,1,0,0,0-.29-.71l-7-7A1,1,0,0,0,14,2H4A2,2,0,0,0,2,4V28a2,2,0,0,0,2,2H20a2,2,0,0,0,2-2V26H20v2H4V4h8v6a2,2,0,0,0,2,2h6v2Zm-8-4V4.41L19.59,10Z"></path></svg>');function it(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=nt();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=st(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(2),a(n),p(v,n),Y()}var lt=A("<title> </title>"),dt=A('<svg><!><path d="M26 24v4H6V24H4v4H4a2 2 0 002 2H26a2 2 0 002-2h0V24zM26 14L24.59 12.59 17 20.17 17 2 15 2 15 20.17 7.41 12.59 6 14 16 24 26 14z"></path></svg>');function _e(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=dt();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=lt(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(),a(n),p(v,n),Y()}var ct=A("<title> </title>"),ut=A('<svg><!><path fill-rule="evenodd" d="M16,2a14,14,0,0,0-4.43,27.28c.7.13,1-.3,1-.67s0-1.21,0-2.38c-3.89.84-4.71-1.88-4.71-1.88A3.71,3.71,0,0,0,6.24,22.3c-1.27-.86.1-.85.1-.85A2.94,2.94,0,0,1,8.48,22.9a3,3,0,0,0,4.08,1.16,2.93,2.93,0,0,1,.88-1.87c-3.1-.36-6.37-1.56-6.37-6.92a5.4,5.4,0,0,1,1.44-3.76,5,5,0,0,1,.14-3.7s1.17-.38,3.85,1.43a13.3,13.3,0,0,1,7,0c2.67-1.81,3.84-1.43,3.84-1.43a5,5,0,0,1,.14,3.7,5.4,5.4,0,0,1,1.44,3.76c0,5.38-3.27,6.56-6.39,6.91a3.33,3.33,0,0,1,.95,2.59c0,1.87,0,3.38,0,3.84s.25.81,1,.67A14,14,0,0,0,16,2Z"></path></svg>');function vt(v,t){const e=H(t,["children","$$slots","$$events","$$legacy"]),y=H(e,["size","title"]);U(t,!1);const o=L(),m=L();let g=C(t,"size",8,16),s=C(t,"title",8,void 0);S(()=>(_(e),_(s())),()=>{h(o,e["aria-label"]||e["aria-labelledby"]||s())}),S(()=>(i(o),_(e)),()=>{h(m,{"aria-hidden":i(o)?void 0:!0,role:i(o)?"img":void 0,focusable:Number(e.tabindex)===0?!0:void 0})}),X(),q();var n=ut();ee(n,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:g(),height:g(),...i(m),...y}));var l=r(n);{var b=d=>{var c=ct(),k=r(c,!0);a(c),O(()=>N(k,s())),p(d,c)};E(l,d=>{s()&&d(b)})}P(),a(n),p(v,n),Y()}var gt=(v,t)=>t("csv"),ft=(v,t)=>t("excel"),pt=(v,t)=>t("json"),mt=I('<div class="space-y-1 p-1"><button class="w-full text-left px-3 py-2 text-sm rounded-md transition-colors duration-200 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"><div class="flex items-center gap-2"><!> <span>Export as CSV</span></div></button> <button class="w-full text-left px-3 py-2 text-sm rounded-md transition-colors duration-200 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"><div class="flex items-center gap-2"><!> <span>Export as Excel</span></div></button> <button class="w-full text-left px-3 py-2 text-sm rounded-md transition-colors duration-200 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"><div class="flex items-center gap-2"><!> <span>Export as JSON</span></div></button></div>'),bt=I('<div class="flex-1 flex justify-center items-center"><div class="text-center"><div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div> <p class="text-gray-500 dark:text-gray-400">Switching control set...</p></div></div>'),ht=I('<div class="flex-1 flex justify-center items-center"><div class="text-center"><div class="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"></div> <p class="text-gray-500 dark:text-gray-400"> </p></div></div>'),xt=I('<header class="bg-white dark:bg-gray-900 shadow-sm border-b border-gray-200 dark:border-gray-700 flex-shrink-0"><div class="w-full px-6 lg:px-8"><div class="flex justify-between items-center h-16"><div class="flex items-center"><a href="/" class="flex items-center space-x-3 hover:opacity-80 transition-opacity"><img src="/lula.png" class="h-8 w-8" alt="Lula Logo"/> <div class="flex flex-col"><span class="text-xl font-bold text-gray-900 dark:text-white">Lula</span> <span class="text-xs text-gray-500 dark:text-gray-400 -mt-1">Gitops for Compliance</span></div></a></div> <div class="flex items-center space-x-4"><!> <!> <a class="p-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors" title="Github" href="https://github.com/defenseunicorns/lula" target="_blank"><!></a></div></div></div></header> <div class="flex-1 flex gap-6 p-6 overflow-hidden"><!></div>',1),yt=I('<div class="h-screen flex flex-col"><!></div> <!>',1);function Et(v,t){U(t,!0);const e=()=>be(Ce,"$appState",o),y=()=>be(Re,"$page",o),[o,m]=ke();let g=!1,s=ie(!1),n=ie("csv"),l=ie(we([])),b=ie("Mappings");async function d(){try{if(!e().currentPath){console.error("No current control set path available"),h(l,[{value:"Mappings",label:"Mappings (Default)"}],!0),h(b,"Mappings");return}const x=await fetch("/api/export-column-headers");if(x.ok){const u=await x.json();h(l,u.columnHeaders||[],!0),h(b,u.defaultColumn||"Mappings",!0)}else console.error("Failed to load column headers"),h(l,[{value:"Mappings",label:"Mappings (Default)"}],!0),h(b,"Mappings")}catch(f){console.error("Error loading column headers:",f),h(l,[{value:"Mappings",label:"Mappings (Default)"}],!0),h(b,"Mappings")}}async function c(f){if(f==="json")try{const x=`/api/export-controls?format=${f}`,u=document.createElement("a");u.href=x,u.download="",document.body.appendChild(u),u.click(),document.body.removeChild(u)}catch(x){console.error("Export failed:",x)}else h(n,f,!0),await d(),h(s,!0)}async function k(f){try{const{format:x,mappingsColumn:u}=f.detail,M=`/api/export-controls?format=${x}&mappingsColumn=${encodeURIComponent(u)}`,w=document.createElement("a");w.href=M,w.download="",document.body.appendChild(w),w.click(),document.body.removeChild(w)}catch(x){console.error("Export failed:",x)}}Ae(()=>{ce.connect();let f=null;const x=async()=>{if(g||y().url.pathname==="/setup"||e().isSwitchingControlSet)return;const u=e();if(u.isConnected){if(g=!0,(!u.name||u.name==="Unknown Control Set"||u.id==="unknown"||u.id==="default")&&(!u.controls||u.controls.length===0)){await ce.scanControlSets();const M=await new Promise(w=>{const T=J=>{window.removeEventListener("control-sets-list",T),w(J.detail)};window.addEventListener("control-sets-list",T),setTimeout(()=>{window.removeEventListener("control-sets-list",T),w(null)},2e3)});M&&Array.isArray(M)&&M.length===1?(console.log("Auto-loading single control set:",M[0].path),await ce.switchControlSet(M[0].path)):Pe("/setup")}}else f=window.setTimeout(x,500)};return f=window.setTimeout(x,100),()=>{f&&clearTimeout(f)}}),De(()=>{ce.disconnect()});var z=yt(),D=K(z),te=r(D);{var ae=f=>{var x=xt(),u=K(x),M=r(u),w=r(M),T=$(r(w),2),J=r(T);Fe(J,{});var W=$(J,2);{var ve=R=>{Ne(R,{buttonLabel:"Export",get buttonIcon(){return _e},buttonClass:"inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors",dropdownClass:"w-48",children:fe=>{var se=mt(),Q=r(se);Q.__click=[gt,c];var V=r(Q),Z=r(V);it(Z,{class:"w-4 h-4"}),P(2),a(V),a(Q);var B=$(Q,2);B.__click=[ft,c];var ne=r(B),pe=r(ne);_e(pe,{class:"w-4 h-4"}),P(2),a(ne),a(B);var me=$(B,2);me.__click=[pt,c];var xe=r(me),Me=r(xe);ot(Me,{class:"w-4 h-4"}),P(2),a(xe),a(me),a(se),p(fe,se)},$$slots:{default:!0}})};E(W,R=>{e().isConnected&&e().controls&&e().controls.length>0&&R(ve)})}var j=$(W,2),G=r(j);vt(G,{class:"w-5 h-5"}),a(j),a(T),a(w),a(M),a(u);var F=$(u,2),ge=r(F);{var de=R=>{var oe=bt();p(R,oe)},$e=R=>{var oe=le(),fe=K(oe);{var se=V=>{var Z=ht(),B=r(Z),ne=$(r(B),2),pe=r(ne,!0);a(ne),a(B),a(Z),O(()=>N(pe,e().isConnected?e().fieldSchema?"Loading controls...":"Loading schema...":"Connecting...")),p(V,Z)},Q=V=>{var Z=le(),B=K(Z);ye(B,()=>t.children),p(V,Z)};E(fe,V=>{!e().isConnected||!e().controls||e().controls.length===0||!e().fieldSchema?V(se):V(Q,!1)},!0)}p(R,oe)};E(ge,R=>{e().isSwitchingControlSet?R(de):R($e,!1)})}a(F),p(f,x)},re=f=>{var x=le(),u=K(x);ye(u,()=>t.children),p(f,x)};E(te,f=>{y().url.pathname!=="/setup"?f(ae):f(re,!1)})}a(D);var ue=$(D,2);tt(ue,{get format(){return i(n)},get columnHeaders(){return i(l)},get defaultColumn(){return i(b)},get isOpen(){return i(s)},set isOpen(f){h(s,f,!0)},$$events:{export:k,cancel:()=>{}}}),p(v,z),Y(),m()}he(["click"]);export{Et as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import{i as u}from"../chunks/Cq7PwVfU.js";import{p as h,f as g,a as l,J as v,b as d,e as _,c as s,r as a,s as x,K as o}from"../chunks/DTWPdvjs.js";import{s as $,p}from"../chunks/
|
|
1
|
+
import"../chunks/DsnmJJEf.js";import{i as u}from"../chunks/Cq7PwVfU.js";import{p as h,f as g,a as l,J as v,b as d,e as _,c as s,r as a,s as x,K as o}from"../chunks/DTWPdvjs.js";import{s as $,p}from"../chunks/rc9CiIba.js";const b={get error(){return p.error},get status(){return p.status}};$.updated.check;const i=b;var k=g("<h1> </h1> <p> </p>",1);function q(m,c){h(c,!1),u();var t=k(),r=l(t),n=s(r,!0);a(r);var e=x(r,2),f=s(e,!0);a(e),v(()=>{o(n,i.status),o(f,i.error?.message)}),d(m,t),_()}export{q as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import"../chunks/Cq7PwVfU.js";import{f,a as y,b as n,c as t,r,s as w,n as C}from"../chunks/DTWPdvjs.js";import{i as k,s as $,a as D}from"../chunks/BXUi170M.js";import{C as S,a as j,D as L}from"../chunks/
|
|
1
|
+
import"../chunks/DsnmJJEf.js";import"../chunks/Cq7PwVfU.js";import{f,a as y,b as n,c as t,r,s as w,n as C}from"../chunks/DTWPdvjs.js";import{i as k,s as $,a as D}from"../chunks/BXUi170M.js";import{C as S,a as j,D as L}from"../chunks/MTDiNHJy.js";import{s as N}from"../chunks/CnwkJbO2.js";var P=f('<div class=" h-full flex flex-col"><div class="flex-1 flex items-center justify-center p-8"><div class="text-center text-gray-500 dark:text-gray-400"><!> <h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">No Control Selected</h3> <p class="text-gray-600 dark:text-gray-400">Select a control from the list to view and edit its details</p></div></div></div>'),q=f('<div class="w-1/2 flex flex-col"><div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm h-full flex flex-col"><!></div></div> <div class="w-1/2 flex flex-col"><!></div>',1);function H(m){const o=()=>D(N,"$selectedControl",x),[x,g]=$();var l=q(),a=y(l),i=t(a),p=t(i);S(p,{}),r(i),r(a);var d=w(a,2),_=t(d);{var h=e=>{j(e,{get control(){return o()}})},b=e=>{var s=P(),c=t(s),v=t(c),u=t(v);L(u,{class:"mx-auto h-16 w-16 mb-4"}),C(4),r(v),r(c),r(s),n(e,s)};k(_,e=>{o()?e(h):e(b,!1)})}r(d),n(m,l),g()}export{H as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/DsnmJJEf.js";import{p as S,u as A,d as x,o as B,f as n,a as F,b as i,e as H,c as s,g as N,r as a,s as h,h as P,n as R}from"../chunks/DTWPdvjs.js";import{a as C,i as b,s as U}from"../chunks/BXUi170M.js";import{g as V}from"../chunks/
|
|
1
|
+
import"../chunks/DsnmJJEf.js";import{p as S,u as A,d as x,o as B,f as n,a as F,b as i,e as H,c as s,g as N,r as a,s as h,h as P,n as R}from"../chunks/DTWPdvjs.js";import{a as C,i as b,s as U}from"../chunks/BXUi170M.js";import{g as V}from"../chunks/rc9CiIba.js";import{p as q,s as _}from"../chunks/CnwkJbO2.js";import{C as G,a as J,D as K}from"../chunks/MTDiNHJy.js";import{w}from"../chunks/e7OeeeKP.js";var O=n('<div class="absolute top-4 right-4 z-10"><div class="w-8 h-8 flex items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30" title="Loading control..."><svg class="w-5 h-5 text-blue-600 dark:text-blue-400 animate-spin" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg></div></div>'),Q=n('<div class=" h-full flex flex-col"><div class="flex-1 flex items-center justify-center p-8"><div class="text-center text-gray-500 dark:text-gray-400"><!> <h3 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">No Control Selected</h3> <p class="text-gray-600 dark:text-gray-400">Select a control from the list to view and edit its details</p></div></div></div>'),T=n('<div class="w-1/2 flex flex-col"><div class="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm h-full flex flex-col"><!></div></div> <div class="w-1/2 flex flex-col relative"><!> <!></div>',1);function se(y,k){S(k,!0);const $=()=>C(q,"$page",c),d=()=>C(_,"$selectedControl",c),[c,D]=U();let v="",r=N(!1);A(()=>{const e=$().params.id;if(!e)return;const t=decodeURIComponent(e);t&&t!==v&&w.isConnected()&&(v=t,x(r,!0),w.getControlDetails(t))}),B(()=>{const e=t=>{const o=t.detail;x(r,!1),o?_.set(o):V("/")};return window.addEventListener("control-details",e),()=>{window.removeEventListener("control-details",e)}});var f=T(),l=F(f),p=s(l),L=s(p);G(L,{}),a(p),a(l);var g=h(l,2),m=s(g);{var I=e=>{var t=O();i(e,t)};b(m,e=>{P(r)&&e(I)})}var z=h(m,2);{var j=e=>{J(e,{get control(){return d()}})},E=e=>{var t=Q(),o=s(t),u=s(o),M=s(u);K(M,{class:"mx-auto h-16 w-16 mb-4"}),R(4),a(u),a(o),a(t),i(e,t)};b(z,e=>{d()?e(j):e(E,!1)})}a(g),i(y,f),H(),D()}export{se as component};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import"../chunks/DsnmJJEf.js";import{i as We}from"../chunks/Cq7PwVfU.js";import{p as Xe,am as Ve,d as o,T as k,G as pe,h as e,an as $r,ao as Ne,c as a,n as ke,r as t,b as d,e as Ke,J as P,K as I,ap as Nr,f as x,s as i,aq as c,a as we,ar as xr,aj as Ae,a3 as ze,ak as hr,al as tr,as as yr,k as de,o as ot,W as st}from"../chunks/DTWPdvjs.js";import{l as ar,p as Ye,i as M,a as lt,s as it}from"../chunks/BXUi170M.js";import{a as Lr,s as se,r as jr,e as ge,b as Je,c as Vr,d as _r,i as Cr,f as Sr,w as wr}from"../chunks/e7OeeeKP.js";import{g as nt}from"../chunks/rc9CiIba.js";function dt(ue){return function(...U){var F=U[0];return F.stopPropagation(),ue?.apply(this,U)}}var vt=Ne("<title> </title>"),ct=Ne('<svg><!><path d="M11 18L12.41 19.41 15 16.83 15 29 17 29 17 16.83 19.59 19.41 21 18 16 13 11 18z"></path><path d="M23.5,22H23V20h.5a4.5,4.5,0,0,0,.36-9L23,11l-.1-.82a7,7,0,0,0-13.88,0L9,11,8.14,11a4.5,4.5,0,0,0,.36,9H9v2H8.5A6.5,6.5,0,0,1,7.2,9.14a9,9,0,0,1,17.6,0A6.5,6.5,0,0,1,23.5,22Z"></path></svg>');function gt(ue,U){const F=ar(U,["children","$$slots","$$events","$$legacy"]),J=ar(F,["size","title"]);Xe(U,!1);const H=k(),j=k();let R=Ye(U,"size",8,16),b=Ye(U,"title",8,void 0);Ve(()=>(pe(F),pe(b())),()=>{o(H,F["aria-label"]||F["aria-labelledby"]||b())}),Ve(()=>(e(H),pe(F)),()=>{o(j,{"aria-hidden":e(H)?void 0:!0,role:e(H)?"img":void 0,focusable:Number(F.tabindex)===0?!0:void 0})}),$r(),We();var S=ct();Lr(S,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:R(),height:R(),...e(j),...J}));var K=a(S);{var G=E=>{var g=vt(),N=a(g,!0);t(g),P(()=>I(N,b())),d(E,g)};M(K,E=>{b()&&E(G)})}ke(2),t(S),d(ue,S),Ke()}var pt=Ne("<title> </title>"),ut=Ne('<svg><!><path d="M10 6H14V10H10zM18 6H22V10H18zM10 14H14V18H10zM18 14H22V18H18zM10 22H14V26H10zM18 22H22V26H18z"></path></svg>');function kr(ue,U){const F=ar(U,["children","$$slots","$$events","$$legacy"]),J=ar(F,["size","title"]);Xe(U,!1);const H=k(),j=k();let R=Ye(U,"size",8,16),b=Ye(U,"title",8,void 0);Ve(()=>(pe(F),pe(b())),()=>{o(H,F["aria-label"]||F["aria-labelledby"]||b())}),Ve(()=>(e(H),pe(F)),()=>{o(j,{"aria-hidden":e(H)?void 0:!0,role:e(H)?"img":void 0,focusable:Number(F.tabindex)===0?!0:void 0})}),$r(),We();var S=ut();Lr(S,()=>({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",preserveAspectRatio:"xMidYMid meet",width:R(),height:R(),...e(j),...J}));var K=a(S);{var G=E=>{var g=pt(),N=a(g,!0);t(g),P(()=>I(N,b())),d(E,g)};M(K,E=>{b()&&E(G)})}ke(),t(S),d(ue,S),Ke()}var bt=x('<div class="p-4 text-sm text-blue-800 rounded-lg bg-blue-50 dark:bg-gray-800 dark:text-blue-400"><div class="flex items-center"><svg class="flex-shrink-0 inline w-4 h-4 mr-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"></path></svg> <div><span class="font-medium">File loaded:</span> <div class="mt-1"><span class="font-medium">Sheets:</span> <span class="font-medium">Fields:</span> <span class="font-medium">Controls found:</span> </div></div></div></div>'),ft=x('<div class="p-4 text-sm text-red-800 rounded-lg bg-red-50 dark:bg-gray-800 dark:text-red-400"><div class="flex items-center"><svg class="flex-shrink-0 inline w-4 h-4 mr-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"></path></svg> <span> </span></div></div>'),mt=x('<div class="p-4 text-sm text-green-800 rounded-lg bg-green-50 dark:bg-gray-800 dark:text-green-400"><div class="flex items-center"><svg class="flex-shrink-0 inline w-4 h-4 mr-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"></path></svg> <span> </span></div></div>'),xt=x("<option> </option>"),ht=x("<option> </option>"),yt=x("<option> </option>"),_t=x('<span class="ml-auto text-xs text-blue-600 dark:text-blue-400">ID</span>'),wt=x('<div draggable="true" role="button" tabindex="0" class="flex items-center px-3 py-2 bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 rounded text-sm cursor-move hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors opacity-75"><svg class="w-3 h-3 mr-2 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20"><path d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"></path></svg> <span class="truncate line-through"> </span> <!></div>'),kt=x('<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">No excluded fields</p>'),Ct=x('<div draggable="true" role="button" tabindex="0"><!> <span class="truncate"> </span></div>'),St=x('<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">Drop fields here</p>'),$t=x('<div draggable="true" role="button" tabindex="0"><!> <span class="truncate"> </span></div>'),Dt=x('<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">Drop fields here</p>'),Mt=x('<div draggable="true" role="button" tabindex="0"><!> <span class="truncate"> </span></div>'),zt=x('<p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">Drop fields here</p>'),At=x('<div draggable="false" role="button" tabindex="0" class="flex items-center px-3 py-2 bg-orange-100 dark:bg-orange-900/30 text-orange-800 dark:text-orange-300 rounded text-sm hover:bg-orange-200 dark:hover:bg-orange-800/30 transition-colors"><span class="truncate"> </span> <button class="ml-auto text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400" title="Remove from mappings">×</button></div>'),Ft=x('<div role="region" aria-label="Justification field drop zone"><p class="text-xs text-gray-400 dark:text-gray-500 text-center py-4">Drop fields here</p></div>'),Ot=x('<th class="px-4 py-2"> </th>'),Pt=x('<td class="px-4 py-2"> </td>'),Ht=x('<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700"></tr>'),Et=x('<div class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700"><h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Sample Data Preview</h3> <div class="overflow-x-auto"><table class="w-full text-sm text-left text-gray-500 dark:text-gray-400"><thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-gray-600 dark:text-gray-400"><tr></tr></thead><tbody></tbody></table></div></div>'),It=x('<span class="flex items-center"><svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> Importing...</span>'),Tt=x(`<div class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700"><h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4">Import Options</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"><div><label for="controlSetName" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Control Set Name <span class="text-red-500">*</span></label> <input type="text" id="controlSetName" placeholder="e.g., NIST 800-53 Rev 4" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:text-white" required/> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">This will be used as the display name and folder name</p></div> <div><label for="controlSetDescription" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Description</label> <input type="text" id="controlSetDescription" placeholder="Optional description" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:text-white"/> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Brief description of this control set</p></div></div> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="sheet" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Sheet</label> <select id="sheet" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:text-white"></select> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Select which worksheet contains your control data</p></div> <div><label for="headerRow" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Select Header Row</label> <select id="headerRow" class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:text-white"></select> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Select the row containing column headers</p></div> <div><label for="controlIdField" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Control ID Field <span class="text-red-500">*</span></label> <select id="controlIdField" required><option disabled>Select Control ID field</option><!></select> <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Column containing unique control identifiers (e.g., AC-1, SC-7)</p></div></div></div> <div class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700"><h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Organize Fields</h3> <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Drag fields to organize them. <strong>Overview fields</strong> will appear as table columns in
|
|
2
|
+
the controls list.</p> <div class="grid grid-cols-1 lg:grid-cols-5 gap-4"><div class="border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800"><div class="p-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700 rounded-t-lg"><h4 class="text-sm font-semibold text-gray-700 dark:text-gray-300">Excluded Fields</h4> <p class="text-xs text-gray-500 dark:text-gray-400 mt-1">Not imported</p></div> <div role="region" aria-label="Excluded fields drop zone"><!> <!></div></div> <div class="border border-blue-300 dark:border-blue-700 rounded-lg bg-white dark:bg-gray-800"><div class="p-3 border-b border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 rounded-t-lg"><h4 class="text-sm font-semibold text-blue-700 dark:text-blue-300">Overview Tab</h4> <p class="text-xs text-blue-600 dark:text-blue-400 mt-1">Shows in details & table columns</p></div> <div role="region" aria-label="Overview tab drop zone"><!> <!></div></div> <div class="border border-green-300 dark:border-green-700 rounded-lg bg-white dark:bg-gray-800"><div class="p-3 border-b border-green-200 dark:border-green-800 bg-green-50 dark:bg-green-900/20 rounded-t-lg"><h4 class="text-sm font-semibold text-green-700 dark:text-green-300">Implementation Tab</h4> <p class="text-xs text-green-600 dark:text-green-400 mt-1">Status & compliance</p></div> <div role="region" aria-label="Implementation tab drop zone"><!> <!></div></div> <div class="border border-purple-300 dark:border-purple-700 rounded-lg bg-white dark:bg-gray-800"><div class="p-3 border-b border-purple-200 dark:border-purple-800 bg-purple-50 dark:bg-purple-900/20 rounded-t-lg"><h4 class="text-sm font-semibold text-purple-700 dark:text-purple-300">Custom Tab</h4> <p class="text-xs text-purple-600 dark:text-purple-400 mt-1">Additional fields</p></div> <div role="region" aria-label="Custom fields drop zone"><!> <!></div></div> <div class="border border-orange-300 dark:border-orange-700 rounded-lg bg-white dark:bg-gray-800"><div class="p-3 border-b border-orange-200 dark:border-orange-800 bg-orange-50 dark:bg-orange-900/20 rounded-t-lg"><h4 class="text-sm font-semibold text-orange-700 dark:text-orange-300">Mappings Tab</h4> <p class="text-xs text-orange-600 dark:text-orange-400 mt-1">Pre-populate justification for a control mapping</p></div> <div role="region" aria-label="Justifications tab drop zone"><div class="space-y-2"><!></div></div></div></div></div> <!> <div class="flex justify-center"><button class="px-5 py-2.5 text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm disabled:opacity-50 disabled:cursor-not-allowed"><!></button></div>`,1),jt=x('<div class="space-y-6"><div role="button" tabindex="0" class="relative"><label><div class="flex flex-col items-center justify-center pt-5 pb-6"><!> <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p> <p class="text-xs text-gray-500 dark:text-gray-400">XLSX, XLS or CSV files</p></div> <input type="file" class="hidden" accept=".xlsx,.xls,.csv"/></label></div> <!> <!> <!> <!></div>');function Vt(ue,U){Xe(U,!1);const F=Nr();let J=k(null),H=k(""),j=k(""),R=k([]),b=k([]),S=k([]),K=k(0),G=k([]),E=k([]),g=k(new Map),N=k(1),L=k(""),xe=k(""),Y=k(""),Q=k(!1),ee=k(""),be=k(""),Ce=k(!1),re=k(!1),$=k(null),Z=k(null),te=k(null);function Se(){o(b,[]),o(S,[]),o(K,0),e(g).clear(),o(g,new Map),o(E,[]),o(L,""),o(ee,""),o(be,""),o($,null),o(Z,null),o(te,null)}function p(s){s.preventDefault(),o(re,!0)}function u(){o(re,!1)}function D(s){s.preventDefault(),o(re,!1);const n=s.dataTransfer?.files;n&&n.length>0&&T(n[0])}function V(s){const n=s.target;n.files&&n.files.length>0&&T(n.files[0])}async function T(s){Se(),o(H,s.name),o(J,s),o(ee,""),o(Q,!0),o(xe,e(H).replace(/\.[^.]+$/,"").replace(/[-_]/g," ")),o(Y,`Imported from ${e(H)}`);try{const n=new FormData;n.append("file",s);const y=await fetch("/api/parse-excel",{method:"POST",body:n});if(!y.ok){const z=await y.json();throw new Error(z.error||"Failed to parse file")}const h=await y.json();o(R,h.sheets||[]),o(j,h.selectedSheet||e(R)[0]),o(G,h.rowPreviews||[]),e(G).length>0&&e(N)===1&&o(N,e(G)[0].row),await q(),o(Ce,!0)}catch(n){o(ee,"Error reading file: "+n.message)}finally{o(Q,!1)}}async function q(){if(!(!e(J)||!e(j))){o(Q,!0),e(g).clear(),o(g,new Map),o(L,"");try{const s=new FormData;s.append("file",e(J)),s.append("sheetName",e(j));const n=await fetch("/api/parse-excel-sheet-previews",{method:"POST",body:s});if(n.ok){const w=await n.json();o(G,w.rowPreviews||[]),e(G).length>0&&!e(G).some(A=>A.row===e(N))&&o(N,e(G)[0].row)}else{const w=await n.json();throw new Error(w.error||"Failed to load sheet previews")}const y=new FormData;y.append("file",e(J)),y.append("sheetName",e(j)),y.append("headerRow",e(N).toString());const h=await fetch("/api/parse-excel-sheet",{method:"POST",body:y});if(!h.ok){const w=await h.json();throw new Error(w.error||"Failed to parse sheet")}const z=await h.json();if(o(b,z.fields||[]),o(S,z.sampleData||[]),o(K,z.controlCount||0),e(b).forEach((w,A)=>{const _=w.toLowerCase();let ce="custom",fe="text";_.includes("implementation")||_.includes("status")||_.includes("narrative")||_.includes("guidance")?ce="implementation":(_.includes("id")||_.includes("title")||_.includes("family")||_.includes("cci")||_.includes("control")||_.includes("acronym"))&&(ce="overview"),_.includes("description")||_.includes("narrative")||_.includes("guidance")||_.includes("statement")?fe="textarea":_.includes("status")||_.includes("type")||_.includes("designation")?fe="select":_.includes("date")?fe="date":(_.includes("count")||_.includes("number"))&&(fe="number"),e(g).set(w,{originalName:w,tab:ce,displayOrder:A,fieldType:fe,required:_.includes("id")||_.includes("title")})}),o(g,e(g)),e(L)&&!e(b).includes(e(L))&&o(L,""),!e(L)&&e(b).includes("AP Acronym")){const w=!e(S).length||e(S).every(ne=>!ne["AP Acronym"]||String(ne["AP Acronym"]).length<25),A=e(S).map(ne=>ne["AP Acronym"]).filter(ne=>ne!=null&&ne!==""&&String(ne).trim()!==""),_=new Set(A),ce=!A.length||_.size===A.length,fe=A.length>0;w&&ce&&fe&&o(L,"AP Acronym")}}catch(s){o(ee,"Error loading sheet data: "+s.message)}finally{o(Q,!1)}}}function ve(s){if(!s)return s;let n=s.trim().replace(/\r?\n/g," ").replace(/\s+/g," ").trim();return Le(n)}function Le(s){return s.replace(/\W+/g," ").split(/ |\s/).map(n=>n.toLowerCase()).join("-")}function he(s,n){o($,n),s.dataTransfer&&(s.dataTransfer.effectAllowed="move",s.dataTransfer.setData("text/plain",n))}function ae(){o($,null),o(Z,null),o(te,null)}function C(s,n){s.preventDefault(),o(Z,n),s.dataTransfer&&(s.dataTransfer.dropEffect="move")}function le(){o(Z,null)}function ie(s,n,y){if(s.preventDefault(),e($)&&e(g).has(e($))){const h=e(g).get(e($));if(n==="mappings")e(E).includes(e($))||o(E,[...e(E),e($)]);else{if(h.tab=n,y!==void 0&&n!==null){const w=Array.from(e(g).entries()).filter(([A,_])=>_.tab===n).sort((A,_)=>A[1].displayOrder-_[1].displayOrder).filter(([A])=>A!==e($));w.splice(y,0,[e($),h]),w.forEach(([A,_],ce)=>{_.displayOrder=ce,e(g).set(A,_)})}else if(n!==null){const z=Math.max(0,...Array.from(e(g).values()).filter(w=>w.tab===n).map(w=>w.displayOrder));h.displayOrder=z+1}e(g).set(e($),h),o(g,e(g))}}o($,null),o(Z,null)}function Fe(s,n){s.preventDefault(),s.stopPropagation(),o(te,n)}function $e(){o(te,null)}function De(s,n,y){if(s.preventDefault(),s.stopPropagation(),e($)&&e($)!==n){const z=Array.from(e(g).entries()).filter(([w,A])=>A.tab===y).sort((w,A)=>w[1].displayOrder-A[1].displayOrder).findIndex(([w])=>w===n);z!==-1&&ie(s,y,z)}o(te,null)}async function Be(){if(!(!e(J)||!e(H))){if(!e(L)){o(ee,"Please select a Control ID field before importing"),o(be,"");return}if(!e(xe)||e(xe).trim()===""){o(ee,"Please enter a Control Set Name before importing"),o(be,"");return}o(Q,!0),o(ee,""),o(be,"");try{const s=new FormData;s.append("file",e(J),e(H)),s.append("controlIdField",e(L)),s.append("startRow",e(N).toString()),s.append("sheetName",e(j)),s.append("namingConvention","kebab-case"),s.append("skipEmpty","true"),s.append("skipEmptyRows","true"),s.append("controlSetName",e(xe)||e(H).replace(/\.[^.]+$/,"")),s.append("controlSetDescription",e(Y)||`Imported from ${e(H)}`);const n=Array.from(e(g).entries()).filter(([h,z])=>z.tab!==null).map(([h,z])=>({fieldName:ve(h),...z}));s.append("fieldSchema",JSON.stringify(n)),s.append("justificationFields",JSON.stringify(e(E).map(h=>ve(h))));let y;try{if(y=await fetch("/api/import-spreadsheet",{method:"POST",body:s}),!y.ok){const z=await y.json();throw new Error(z.error||"Import failed")}const h=await y.json();o(be,`Successfully imported ${h.controlCount} controls into ${h.families.length} families`),F("created",{path:h.outputDir})}catch(h){console.error("Error importing spreadsheet:",h)}}catch(s){o(ee,"Error importing spreadsheet: "+s.message)}finally{o(Q,!1)}}}We();var Re=jt(),ye=a(Re),Ze=a(ye),Oe=a(Ze),or=a(Oe);gt(or,{class:"w-8 h-8 mb-4 text-gray-500 dark:text-gray-400"}),ke(4),t(Oe);var Ge=i(Oe,2);t(Ze),t(ye);var Pe=i(ye,2);{var sr=s=>{var n=bt(),y=a(n),h=i(a(y),2),z=i(a(h)),w=i(z),A=i(a(w)),_=i(A,2),ce=i(_,2);t(w),t(h),t(y),t(n),P(()=>{I(z,` ${e(H)??""} `),I(A,` ${e(R).length??""} | `),I(_,` ${e(b).length??""} | `),I(ce,` ${e(K)??""}`)}),d(s,n)};M(Pe,s=>{e(H)&&s(sr)})}var Qe=i(Pe,2);{var lr=s=>{var n=ft(),y=a(n),h=i(a(y),2),z=a(h,!0);t(h),t(y),t(n),P(()=>I(z,e(ee))),d(s,n)};M(Qe,s=>{e(ee)&&s(lr)})}var qe=i(Qe,2);{var ir=s=>{var n=mt(),y=a(n),h=i(a(y),2),z=a(h,!0);t(h),t(y),t(n),P(()=>I(z,e(be))),d(s,n)};M(qe,s=>{e(be)&&s(ir)})}var nr=i(qe,2);{var dr=s=>{var n=Tt(),y=we(n),h=i(a(y),2),z=a(h),w=i(a(z),2);jr(w),ke(2),t(z);var A=i(z,2),_=i(a(A),2);jr(_),ke(2),t(A),t(h);var ce=i(h,2),fe=a(ce),ne=i(a(fe),2);P(()=>{e(j),xr(()=>{e(R)})}),ge(ne,5,()=>e(R),r=>r,(r,l)=>{var f=xt(),m=a(f,!0);t(f);var v={};P(()=>{I(m,e(l)),v!==(v=e(l))&&(f.value=(f.__value=e(l))??"")}),d(r,f)}),t(ne),ke(2),t(fe);var vr=i(fe,2),er=i(a(vr),2);P(()=>{e(N),xr(()=>{e(G)})}),ge(er,5,()=>e(G),r=>r.row,(r,l)=>{var f=ht(),m=a(f);t(f);var v={};P(()=>{I(m,`Row ${e(l).row??""}: ${e(l).preview??""}`),v!==(v=e(l).row)&&(f.value=(f.__value=e(l).row)??"")}),d(r,f)}),t(er),ke(2),t(vr);var Dr=i(vr,2),rr=i(a(Dr),2);P(()=>{e(L),xr(()=>{e(b),e(S)})});var cr=a(rr);cr.value=cr.__value="";var Br=i(cr);ge(Br,1,()=>e(b),r=>r,(r,l)=>{const f=ze(()=>e(S).length>0&&e(S)[0][e(l)]?String(e(S)[0][e(l)]).slice(0,30):""),m=ze(()=>!e(S).length||e(S).every(oe=>!oe[e(l)]||String(oe[e(l)]).length<25)),v=ze(()=>e(S).map(oe=>oe[e(l)]).filter(oe=>oe!=null&&oe!==""&&String(oe).trim()!=="")),W=ze(()=>new Set(e(v))),X=ze(()=>!e(v).length||e(W).size===e(v).length),B=ze(()=>e(v).length>0);var O=Ae(),me=we(O);{var Me=oe=>{var _e=yt(),mr=a(_e);t(_e);var Tr={};P(()=>{I(mr,`${e(l)??""}${e(f)?` (e.g., ${e(f)})`:""}`),Tr!==(Tr=e(l))&&(_e.value=(_e.__value=e(l))??"")}),d(oe,_e)};M(me,oe=>{e(m)&&e(X)&&e(B)&&oe(Me)})}d(r,O)}),t(rr),ke(2),t(Dr),t(ce),t(y);var gr=i(y,2),Mr=i(a(gr),4),pr=a(Mr),He=i(a(pr),2),zr=a(He);ge(zr,1,()=>e(b).filter(r=>!e(g).get(r)||e(g).get(r)?.tab===null),r=>r,(r,l)=>{var f=wt(),m=i(a(f),2),v=a(m,!0);t(m);var W=i(m,2);{var X=B=>{var O=_t();d(B,O)};M(W,B=>{e(l)===e(L)&&B(X)})}t(f),P(()=>{Je(f,"aria-label",`Drag ${e(l)??""} field`),I(v,e(l))}),c("dragstart",f,B=>he(B,e(l))),c("dragend",f,ae),d(r,f)});var Rr=i(zr,2);{var Zr=r=>{var l=kt();d(r,l)};M(Rr,r=>{e(b).filter(l=>!e(g).get(l)||e(g).get(l)?.tab===null).length===0&&r(Zr)})}t(He),t(pr);var ur=i(pr,2),Ee=i(a(ur),2),Ar=a(Ee);ge(Ar,3,()=>Array.from(e(g).entries()).filter(([r,l])=>l.tab==="overview").sort((r,l)=>r[1].displayOrder-l[1].displayOrder),([r,l])=>r,(r,l)=>{var f=hr(()=>yr(e(l),2));let m=()=>e(f)[0];var v=Ct(),W=a(v);kr(W,{class:"w-3 h-3 mr-2 flex-shrink-0"});var X=i(W,2),B=a(X,!0);t(X),t(v),P(()=>{Je(v,"aria-label",`${m()??""} field in Overview tab`),se(v,1,`flex items-center px-3 py-2 bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-300 rounded text-sm cursor-move hover:bg-blue-200 dark:hover:bg-blue-800/30 transition-colors
|
|
3
|
+
${e(te)===m()&&e($)!==m()?"border-t-2 border-blue-500":""}`),I(B,m())}),c("dragstart",v,O=>he(O,m())),c("dragend",v,ae),c("dragover",v,O=>Fe(O,m())),c("dragleave",v,$e),c("drop",v,O=>De(O,m(),"overview")),d(r,v)});var qr=i(Ar,2);{var Ur=r=>{var l=St();d(r,l)};M(qr,r=>{Array.from(e(g).entries()).filter(([l,f])=>f.tab==="overview").length===0&&r(Ur)})}t(Ee),t(ur);var br=i(ur,2),Ie=i(a(br),2),Fr=a(Ie);ge(Fr,3,()=>Array.from(e(g).entries()).filter(([r,l])=>l.tab==="implementation").sort((r,l)=>r[1].displayOrder-l[1].displayOrder),([r,l])=>r,(r,l)=>{var f=hr(()=>yr(e(l),2));let m=()=>e(f)[0];var v=$t(),W=a(v);kr(W,{class:"w-3 h-3 mr-2 flex-shrink-0"});var X=i(W,2),B=a(X,!0);t(X),t(v),P(()=>{Je(v,"aria-label",`${m()??""} field in Implementation tab`),se(v,1,`flex items-center px-3 py-2 bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-300 rounded text-sm cursor-move hover:bg-green-200 dark:hover:bg-green-800/30 transition-colors
|
|
4
|
+
${e(te)===m()&&e($)!==m()?"border-t-2 border-green-500":""}`),I(B,m())}),c("dragstart",v,O=>he(O,m())),c("dragend",v,ae),c("dragover",v,O=>Fe(O,m())),c("dragleave",v,$e),c("drop",v,O=>De(O,m(),"implementation")),d(r,v)});var Jr=i(Fr,2);{var Yr=r=>{var l=Dt();d(r,l)};M(Jr,r=>{Array.from(e(g).entries()).filter(([l,f])=>f.tab==="implementation").length===0&&r(Yr)})}t(Ie),t(br);var fr=i(br,2),Te=i(a(fr),2),Or=a(Te);ge(Or,3,()=>Array.from(e(g).entries()).filter(([r,l])=>l.tab==="custom").sort((r,l)=>r[1].displayOrder-l[1].displayOrder),([r,l])=>r,(r,l)=>{var f=hr(()=>yr(e(l),2));let m=()=>e(f)[0];var v=Mt(),W=a(v);kr(W,{class:"w-3 h-3 mr-2 flex-shrink-0"});var X=i(W,2),B=a(X,!0);t(X),t(v),P(()=>{Je(v,"aria-label",`${m()??""} field in Custom tab`),se(v,1,`flex items-center px-3 py-2 bg-purple-100 dark:bg-purple-900/30 text-purple-800 dark:text-purple-300 rounded text-sm cursor-move hover:bg-purple-200 dark:hover:bg-purple-800/30 transition-colors
|
|
5
|
+
${e(te)===m()&&e($)!==m()?"border-t-2 border-purple-500":""}`),I(B,m())}),c("dragstart",v,O=>he(O,m())),c("dragend",v,ae),c("dragover",v,O=>Fe(O,m())),c("dragleave",v,$e),c("drop",v,O=>De(O,m(),"custom")),d(r,v)});var Wr=i(Or,2);{var Xr=r=>{var l=zt();d(r,l)};M(Wr,r=>{Array.from(e(g).entries()).filter(([l,f])=>f.tab==="custom").length===0&&r(Xr)})}t(Te),t(fr);var Pr=i(fr,2),je=i(a(Pr),2),Hr=a(je),Kr=a(Hr);{var Gr=r=>{var l=Ae(),f=we(l);ge(f,1,()=>e(E),Cr,(m,v)=>{var W=At(),X=a(W),B=a(X,!0);t(X);var O=i(X,2);t(W),P(()=>I(B,e(v))),c("click",O,dt(()=>{o(E,e(E).filter(me=>me!==e(v)))})),d(m,W)}),d(r,l)},Qr=r=>{var l=Ft();P(()=>se(l,1,`p-4 transition-colors
|
|
6
|
+
${e(Z)==="mappings"?"bg-orange-50 dark:bg-orange-900/10":""}`)),c("dragover",l,f=>{f.preventDefault(),C(f,"mappings")}),c("dragleave",l,le),c("drop",l,f=>{if(f.preventDefault(),e($)&&e(g).has(e($))){e(E).includes(e($))||o(E,[...e(E),e($)]);const m=e(g).get(e($));m.tab="mappings",e(g).set(e($),m),o(g,new Map(e(g))),o(Z,null)}}),d(r,l)};M(Kr,r=>{e(E).length>0?r(Gr):r(Qr,!1)})}t(Hr),t(je),t(Pr),t(Mr),t(gr);var Er=i(gr,2);{var et=r=>{var l=Et(),f=i(a(l),2),m=a(f),v=a(m),W=a(v);ge(W,5,()=>e(b).slice(0,5),B=>B,(B,O)=>{var me=Ot(),Me=a(me,!0);t(me),P(()=>I(Me,e(O))),d(B,me)}),t(W),t(v);var X=i(v);ge(X,5,()=>e(S),Cr,(B,O)=>{var me=Ht();ge(me,5,()=>e(b).slice(0,5),Me=>Me,(Me,oe)=>{var _e=Pt(),mr=a(_e,!0);t(_e),P(()=>I(mr,e(O)[e(oe)]||"")),d(Me,_e)}),t(me),d(B,me)}),t(X),t(m),t(f),t(l),d(r,l)};M(Er,r=>{e(S).length>0&&r(et)})}var Ir=i(Er,2),Ue=a(Ir),rt=a(Ue);{var tt=r=>{var l=It();d(r,l)},at=r=>{var l=tr("Import to Control Set");d(r,l)};M(rt,r=>{e(Q)?r(tt):r(at,!1)})}t(Ue),t(Ir),P(()=>{se(rr,1,`bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:text-white ${e(L)?"":"border-red-500"}`),se(He,1,`p-3 min-h-[400px] max-h-[600px] overflow-y-auto space-y-2 transition-colors
|
|
7
|
+
${e(Z)===null?"bg-gray-100 dark:bg-gray-800":""}`),se(Ee,1,`p-3 min-h-[400px] max-h-[600px] overflow-y-auto space-y-2 transition-colors
|
|
8
|
+
${e(Z)==="overview"?"bg-blue-50 dark:bg-blue-900/10":""}`),se(Ie,1,`p-3 min-h-[400px] max-h-[600px] overflow-y-auto space-y-2 transition-colors
|
|
9
|
+
${e(Z)==="implementation"?"bg-green-50 dark:bg-green-900/10":""}`),se(Te,1,`p-3 min-h-[400px] max-h-[600px] overflow-y-auto space-y-2 transition-colors
|
|
10
|
+
${e(Z)==="custom"?"bg-purple-50 dark:bg-purple-900/10":""}`),se(je,1,`p-3 min-h-[400px] max-h-[600px] overflow-y-auto transition-colors
|
|
11
|
+
${e(Z)==="mappings"?"bg-orange-50 dark:bg-orange-900/10":""}`),Ue.disabled=e(Q)||!e(J)||!e(L),Je(Ue,"title",e(L)?"":"Please select a Control ID field")}),Vr(w,()=>e(xe),r=>o(xe,r)),Vr(_,()=>e(Y),r=>o(Y,r)),_r(ne,()=>e(j),r=>o(j,r)),c("change",ne,async()=>{await q()}),_r(er,()=>e(N),r=>o(N,r)),c("change",er,q),_r(rr,()=>e(L),r=>o(L,r)),c("dragover",He,r=>C(r,null)),c("dragleave",He,le),c("drop",He,r=>ie(r,null)),c("dragover",Ee,r=>C(r,"overview")),c("dragleave",Ee,le),c("drop",Ee,r=>ie(r,"overview")),c("dragover",Ie,r=>C(r,"implementation")),c("dragleave",Ie,le),c("drop",Ie,r=>ie(r,"implementation")),c("dragover",Te,r=>C(r,"custom")),c("dragleave",Te,le),c("drop",Te,r=>ie(r,"custom")),c("dragover",je,r=>C(r,"mappings")),c("dragleave",je,le),c("drop",je,r=>ie(r,"mappings")),c("click",Ue,Be),d(s,n)};M(nr,s=>{e(Ce)&&e(b).length>0&&s(dr)})}t(Re),P(()=>se(Ze,1,`flex flex-col items-center justify-center w-full h-64 border-2 border-dashed rounded-lg cursor-pointer transition-all duration-300 ${e(re)?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600"}`)),c("change",Ge,V),c("dragover",ye,p),c("dragleave",ye,u),c("drop",ye,D),d(ue,Re),Ke()}var Nt=x('<span class="ml-2"> </span>'),Lt=x('<div class="text-sm text-gray-500 dark:text-gray-400"><span class="font-medium"> </span> <!></div>'),Bt=x('<div class="text-center space-y-6"><div class="p-6 bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 rounded-lg border-2 border-green-500"><svg class="w-12 h-12 text-green-600 mx-auto mb-4" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg> <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">Already Using Control Set</h3> <p class="text-gray-600 dark:text-gray-400 mb-4">You are already using the only available control set in this project.</p> <!></div> <div class="flex justify-center gap-4"><a href="/" class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors shadow-lg">Continue to Controls</a> <button class="px-6 py-3 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-900 dark:text-white font-medium rounded-lg transition-colors">Import New Control Set</button></div></div>'),Rt=x('<div class="p-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300"><div class="flex items-center"><svg class="flex-shrink-0 inline w-4 h-4 mr-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"><path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"></path></svg> <span> </span></div></div>'),Zt=x('<p class="text-sm text-gray-600 dark:text-gray-400 mt-1"> </p>'),qt=x('<span class="text-xs text-gray-500 dark:text-gray-400"><svg class="inline w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M4 3a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V5a2 2 0 00-2-2H4zm12 12H4l4-8 3 6 2-4 3 6z" clip-rule="evenodd"></path></svg> </span>'),Ut=x('<div class="flex flex-col items-center"><svg class="w-8 h-8 text-green-600" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg> <span class="text-xs text-green-600 font-medium mt-1">Current</span></div>'),Jt=Ne('<svg class="w-8 h-8 text-blue-600" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path></svg>'),Yt=Ne('<svg class="w-8 h-8 text-gray-300 dark:text-gray-600" fill="none" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><circle cx="10" cy="10" r="9" stroke="currentColor" stroke-width="2"></circle></svg>'),Wt=x('<div role="button" tabindex="0"><div class="flex items-center justify-between"><div class="flex-1"><div class="flex items-center gap-3"><h3 class="text-lg font-semibold text-gray-900 dark:text-white"> </h3> <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"> </span></div> <!> <div class="flex items-center gap-4 mt-2"><span class="text-xs text-gray-500 dark:text-gray-400"><svg class="inline w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M2 6a2 2 0 012-2h12a2 2 0 012 2v8a2 2 0 01-2 2H4a2 2 0 01-2-2V6zm2-1a1 1 0 00-1 1v8a1 1 0 001 1h12a1 1 0 001-1V6a1 1 0 00-1-1H4z" clip-rule="evenodd"></path></svg> </span> <!></div></div> <div class="flex items-center ml-4"><!></div></div></div>'),Xt=x('<div class="mt-6 flex justify-center"><button class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors shadow-lg">Use Selected Control Set</button></div>'),Kt=x('<div class="space-y-3"></div> <!>',1),Gt=x('<div class="space-y-6"><div class="text-center"><h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-2">Select an Existing Control Set</h2> <p class="text-gray-600 dark:text-gray-400">Choose from control sets found in your project directory</p></div> <!></div>');function Qt(ue,U){Xe(U,!1);const F=()=>lt(Sr,"$appState",J),[J,H]=it(),j=k(),R=Nr();let b=Ye(U,"controlSets",24,()=>[]),S=k(""),K=k(null);function G(Y){g(Y)||o(K,Y)}function E(){e(K)&&!g(e(K))&&R("selected",{path:e(K).path})}function g(Y){const Q=e(j)?.replace(/\/$/,""),ee=Y.path?.replace(/\/$/,"");return!!(Q&&ee&&Q===ee)}Ve(()=>F(),()=>{o(j,F().currentPath||"")}),Ve(()=>pe(b()),()=>{if(b())if(b().length===0)o(S,"No existing control sets found. Try importing from a spreadsheet instead.");else{const Y=b().filter(Q=>!g(Q));Y.length===1?o(K,Y[0]):Y.length===0&&b().length>0&&o(S,"already-using-only-set")}}),$r(),We();var N=Gt(),L=i(a(N),2);{var xe=Y=>{var Q=Ae(),ee=we(Q);{var be=re=>{var $=Bt(),Z=a($),te=i(a(Z),6);{var Se=D=>{var V=Lt(),T=a(V),q=a(T,!0);t(T);var ve=i(T,2);{var Le=he=>{var ae=Nt(),C=a(ae);t(ae),P(()=>I(C,`(${pe(b()),de(()=>b()[0].controlCount)??""} controls)`)),d(he,ae)};M(ve,he=>{pe(b()),de(()=>b()[0].controlCount)&&he(Le)})}t(V),P(()=>I(q,(pe(b()),de(()=>b()[0].name)))),d(D,V)};M(te,D=>{pe(b()),de(()=>b().length>0)&&D(Se)})}t(Z);var p=i(Z,2),u=i(a(p),2);t(p),t($),c("click",u,()=>R("tab-change",{tab:"import"})),d(re,$)},Ce=re=>{var $=Ae(),Z=we($);{var te=p=>{var u=Rt(),D=a(u),V=i(a(D),2),T=a(V,!0);t(V),t(D),t(u),P(()=>I(T,e(S))),d(p,u)},Se=p=>{var u=Ae(),D=we(u);{var V=T=>{var q=Kt(),ve=we(q);ge(ve,5,b,Cr,(ae,C)=>{const le=ze(()=>(e(C),de(()=>g(e(C)))));var ie=Wt(),Fe=a(ie),$e=a(Fe),De=a($e),Be=a(De),Re=a(Be,!0);t(Be);var ye=i(Be,2),Ze=a(ye);t(ye),t(De);var Oe=i(De,2);{var or=s=>{var n=Zt(),y=a(n,!0);t(n),P(()=>I(y,(e(C),de(()=>e(C).description)))),d(s,n)};M(Oe,s=>{e(C),de(()=>e(C).description)&&s(or)})}var Ge=i(Oe,2),Pe=a(Ge),sr=i(a(Pe));t(Pe);var Qe=i(Pe,2);{var lr=s=>{var n=qt(),y=i(a(n));t(n),P(()=>I(y,` ${e(C),de(()=>e(C).file)??""}`)),d(s,n)};M(Qe,s=>{e(C),de(()=>e(C).file)&&s(lr)})}t(Ge),t($e);var qe=i($e,2),ir=a(qe);{var nr=s=>{var n=Ut();d(s,n)},dr=s=>{var n=Ae(),y=we(n);{var h=w=>{var A=Jt();d(w,A)},z=w=>{var A=Yt();d(w,A)};M(y,w=>{e(K)===e(C)?w(h):w(z,!1)},!0)}d(s,n)};M(ir,s=>{e(le)?s(nr):s(dr,!1)})}t(qe),t(Fe),t(ie),P(()=>{se(ie,1,`p-4 bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg border-2 transition-all duration-200 ${e(le)?"border-green-500 !bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 cursor-not-allowed opacity-75":e(K)===e(C)?"border-blue-500 !bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-900/20 dark:to-indigo-900/20 shadow-lg cursor-pointer":"border-gray-200 dark:border-gray-700 hover:border-blue-300 dark:hover:border-blue-700 hover:shadow-md cursor-pointer"}`),I(Re,(e(C),de(()=>e(C).name))),I(Ze,`${e(C),de(()=>e(C).controlCount||0)??""} controls`),I(sr,` ${e(C),de(()=>e(C).path||"root")??""}`)}),c("click",ie,()=>!e(le)&&G(e(C))),c("keydown",ie,s=>s.key==="Enter"&&!e(le)&&G(e(C))),d(ae,ie)}),t(ve);var Le=i(ve,2);{var he=ae=>{var C=Xt(),le=a(C);t(C),c("click",le,E),d(ae,C)};M(Le,ae=>{e(K)&&ae(he)})}d(T,q)};M(D,T=>{pe(b()),de(()=>b().length>0)&&T(V)},!0)}d(p,u)};M(Z,p=>{e(S)?p(te):p(Se,!1)},!0)}d(re,$)};M(ee,re=>{e(S)==="already-using-only-set"?re(be):re(Ce,!1)},!0)}d(Y,Q)};M(L,Y=>{Y(xe,!1)})}t(N),d(ue,N),Ke(),H()}var ea=x('<div class="flex justify-center mb-8"><div class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 inline-flex"><button data-testid="tab-existing">Select Existing Control Set</button> <button data-testid="tab-import">Import New from Spreadsheet</button></div></div>'),ra=x('<div data-testid="pane-import"><!></div>'),ta=x('<div data-testid="pane-existing"><!></div>'),aa=x('<div data-testid="switch-overlay" class="absolute inset-0 bg-gray-900 bg-opacity-50 flex items-center justify-center rounded-lg"><div class="bg-white dark:bg-gray-700 rounded-lg p-6 text-center"><svg class="animate-spin h-8 w-8 text-blue-600 mx-auto mb-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg> <p class="text-gray-900 dark:text-white">Switching control set...</p></div></div>'),oa=x('<div class=" p-4"><div class="max-w-6xl mx-auto"><div class="text-center py-8"><h1 class="text-4xl font-extrabold text-gray-900 dark:text-white mb-4 flex items-center justify-center gap-3"><img src="/lula.png" class="h-12 w-12" alt="Lula"/> <span id="title">Lula</span></h1> <p id="description" class="text-lg text-gray-600 dark:text-gray-400"><!></p></div> <!> <div class="bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900 rounded-lg shadow-xl p-6 relative border border-gray-200 dark:border-gray-700"><!> <!></div></div></div>');function ca(ue,U){Xe(U,!1);let F=k("import"),J=k(""),H=k(!1),j=k(!1),R=k([]);ot(()=>{wr.connect();const p=Sr.subscribe(D=>{D.name&&D.name!=="Unknown Control Set"&&D.id!=="unknown"&&D.id!=="default"&&o(J,D.currentPath||"")}),u=async D=>{const V=D.detail;if(V&&V.controlSets){if(o(R,V.controlSets||[]),o(H,e(R).length>0),e(R).length===1){const T=e(R)[0];if(!(e(J)&&e(J).includes(T.path))&&!e(J)){console.log("Only one control set found and none loaded, auto-loading:",T.path),await b(T.path);return}}e(H)&&o(F,"existing")}};return window.addEventListener("control-sets-list",u),wr.scanControlSets().catch(D=>{console.error("Error scanning control sets:",D)}),()=>{p(),window.removeEventListener("control-sets-list",u)}});async function b(p){console.log("Starting control set switch to:",p),o(j,!0);try{await wr.switchControlSet(p),console.log("WebSocket command sent, waiting for state update..."),await new Promise(u=>{let D=0;const V=50,T=setInterval(()=>{D++;const q=st(Sr);!q.isSwitchingControlSet&&q.currentPath&&q.currentPath.includes(p)?(clearInterval(T),console.log("Control set switch completed successfully"),u()):D>=V&&(clearInterval(T),console.error("Control set switch timed out"),alert("Control set switch timed out. Please try again."),u())},100)}),o(j,!1),nt("/")}catch(u){console.error("Error switching control set:",u),alert("Failed to switch control set: "+u.message),o(j,!1)}}async function S(p){const{path:u}=p.detail;await b(u)}async function K(p){const{path:u}=p.detail;await b(u)}function G(p){const{tab:u}=p.detail;u&&o(F,u)}We();var E=oa(),g=a(E),N=a(g),L=i(a(N),2),xe=a(L);{var Y=p=>{var u=tr("You have an existing control set. You can continue using it or create a new one.");d(p,u)},Q=p=>{var u=Ae(),D=we(u);{var V=q=>{var ve=tr("Select an existing control set or import a new one from a spreadsheet.");d(q,ve)},T=q=>{var ve=tr("Let's get started by importing a control set from a spreadsheet.");d(q,ve)};M(D,q=>{e(H)?q(V):q(T,!1)},!0)}d(p,u)};M(xe,p=>{e(J)?p(Y):p(Q,!1)})}t(L),t(N);var ee=i(N,2);{var be=p=>{var u=ea(),D=a(u),V=a(D),T=i(V,2);t(D),t(u),P(()=>{se(V,1,`px-6 py-3 rounded-l-lg font-medium transition-colors ${e(F)==="existing"?"bg-blue-600 text-white":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`),se(T,1,`px-6 py-3 rounded-r-lg font-medium transition-colors ${e(F)==="import"?"bg-blue-600 text-white":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`)}),c("click",V,()=>o(F,"existing")),c("click",T,()=>o(F,"import")),d(p,u)};M(ee,p=>{e(H)&&p(be)})}var Ce=i(ee,2),re=a(Ce);{var $=p=>{var u=ra(),D=a(u);Vt(D,{$$events:{created:S}}),t(u),d(p,u)},Z=p=>{var u=ta(),D=a(u);Qt(D,{get controlSets(){return e(R)},$$events:{selected:K,"tab-change":G}}),t(u),d(p,u)};M(re,p=>{e(F)==="import"?p($):p(Z,!1)})}var te=i(re,2);{var Se=p=>{var u=aa();d(p,u)};M(te,p=>{e(j)&&p(Se)})}t(Ce),t(g),t(E),d(ue,E),Ke()}export{ca as component};
|
package/dist/_app/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1759969891884"}
|
|
@@ -123,209 +123,155 @@ function containsLulaAnnotations(text) {
|
|
|
123
123
|
const lines = text.split("\n");
|
|
124
124
|
return lines.some((line) => line.includes("@lulaStart") || line.includes("@lulaEnd"));
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return
|
|
126
|
+
function crawlCommand() {
|
|
127
|
+
return new Command().command("crawl").description("Detect compliance-related changes between @lulaStart and @lulaEnd in PR files").addOption(
|
|
128
|
+
new Option("--post-mode <mode>", "How to post findings").choices(["review", "comment"]).default("review")
|
|
129
|
+
).action(async (opts) => {
|
|
130
|
+
let leavePost = false;
|
|
131
|
+
const { owner, repo, pull_number } = getPRContext();
|
|
132
|
+
console.log(`Analyzing PR #${pull_number} in ${owner}/${repo} for compliance changes...`);
|
|
133
|
+
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
|
134
|
+
const pr = await octokit.pulls.get({ owner, repo, pull_number });
|
|
135
|
+
const prBranch = pr.data.head.ref;
|
|
136
|
+
const { data: files } = await octokit.pulls.listFiles({ owner, repo, pull_number });
|
|
137
|
+
let commentBody = `${LULA_SIGNATURE}
|
|
128
138
|
## Lula Compliance Overview
|
|
129
139
|
|
|
130
140
|
Please review the changes to ensure they meet compliance standards.
|
|
131
141
|
|
|
132
142
|
### Reviewed Changes
|
|
133
143
|
|
|
134
|
-
Lula reviewed ${
|
|
144
|
+
Lula reviewed ${files.length} files changed that affect compliance.
|
|
135
145
|
|
|
136
146
|
`;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
const deletedFilesWithAnnotations = [];
|
|
148
|
+
for (const file of files) {
|
|
149
|
+
if (file.status === "removed") {
|
|
150
|
+
try {
|
|
151
|
+
const oldText = await fetchRawFileViaAPI({
|
|
152
|
+
octokit,
|
|
153
|
+
owner,
|
|
154
|
+
repo,
|
|
155
|
+
path: file.filename,
|
|
156
|
+
ref: "main"
|
|
157
|
+
});
|
|
158
|
+
if (containsLulaAnnotations(oldText)) {
|
|
159
|
+
deletedFilesWithAnnotations.push(file.filename);
|
|
160
|
+
}
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.error(`Error checking deleted file ${file.filename}: ${err}`);
|
|
153
163
|
}
|
|
154
|
-
} catch (err) {
|
|
155
|
-
console.error(`Error checking deleted file ${file.filename}: ${err}`);
|
|
156
164
|
}
|
|
157
165
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
let warningContent = `
|
|
166
|
+
if (deletedFilesWithAnnotations.length > 0) {
|
|
167
|
+
leavePost = true;
|
|
168
|
+
commentBody += `
|
|
163
169
|
|
|
164
170
|
**Compliance Warning: Files with Lula annotations were deleted**
|
|
165
171
|
|
|
166
172
|
`;
|
|
167
|
-
|
|
173
|
+
commentBody += `The following files contained compliance annotations (\`@lulaStart\`/\`@lulaEnd\`) and were deleted in this PR. This may affect compliance coverage:
|
|
168
174
|
|
|
169
175
|
`;
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
for (const filename of deletedFilesWithAnnotations) {
|
|
177
|
+
commentBody += `- \`${filename}\`
|
|
172
178
|
`;
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
}
|
|
180
|
+
commentBody += `
|
|
175
181
|
Please review whether:
|
|
176
182
|
`;
|
|
177
|
-
|
|
183
|
+
commentBody += `- The compliance coverage provided by these files is still needed
|
|
178
184
|
`;
|
|
179
|
-
|
|
185
|
+
commentBody += `- Alternative compliance measures have been implemented
|
|
180
186
|
`;
|
|
181
|
-
|
|
187
|
+
commentBody += `- The deletion is intentional and compliance-approved
|
|
182
188
|
|
|
183
189
|
`;
|
|
184
|
-
|
|
190
|
+
commentBody += `---
|
|
185
191
|
|
|
186
192
|
`;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
}
|
|
194
|
+
for (const file of files) {
|
|
195
|
+
if (file.status === "added" || file.status === "removed") continue;
|
|
196
|
+
try {
|
|
197
|
+
const [oldText, newText] = await Promise.all([
|
|
198
|
+
fetchRawFileViaAPI({ octokit, owner, repo, path: file.filename, ref: "main" }),
|
|
199
|
+
fetchRawFileViaAPI({ octokit, owner, repo, path: file.filename, ref: prBranch })
|
|
200
|
+
]);
|
|
201
|
+
const changedBlocks = getChangedBlocks(oldText, newText);
|
|
202
|
+
const removedBlocks = getRemovedBlocks(oldText, newText);
|
|
203
|
+
for (const block of changedBlocks) {
|
|
204
|
+
console.log(`Commenting regarding \`${file.filename}\`.`);
|
|
205
|
+
leavePost = true;
|
|
206
|
+
commentBody += `
|
|
194
207
|
|
|
195
208
|
---
|
|
196
209
|
| File | Lines Changed |
|
|
197
210
|
| ---- | ------------- |
|
|
198
211
|
`;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
const newBlockText = newText.split("\n").slice(block.startLine, block.endLine).join("\n");
|
|
213
|
+
const blockSha256 = createHash("sha256").update(newBlockText).digest("hex");
|
|
214
|
+
commentBody += `| \`${file.filename}\` | \`${block.startLine + 1}\u2013${block.endLine}\` |
|
|
202
215
|
> **uuid**-\`${block.uuid}\`
|
|
203
216
|
**sha256** \`${blockSha256}\`
|
|
204
217
|
|
|
205
218
|
`;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return "";
|
|
212
|
-
}
|
|
213
|
-
console.log(`Found removed annotations in \`${filename}\`.`);
|
|
214
|
-
let content = `
|
|
219
|
+
}
|
|
220
|
+
if (removedBlocks.length > 0) {
|
|
221
|
+
leavePost = true;
|
|
222
|
+
console.log(`Found removed annotations in \`${file.filename}\`.`);
|
|
223
|
+
commentBody += `
|
|
215
224
|
|
|
216
|
-
**Compliance Warning: Lula annotations were removed from \`${filename}\`**
|
|
225
|
+
**Compliance Warning: Lula annotations were removed from \`${file.filename}\`**
|
|
217
226
|
|
|
218
227
|
`;
|
|
219
|
-
|
|
228
|
+
commentBody += `The following compliance annotation blocks were present in the original file but are missing in the updated version:
|
|
220
229
|
|
|
221
230
|
`;
|
|
222
|
-
|
|
231
|
+
commentBody += `| File | Original Lines | UUID |
|
|
223
232
|
`;
|
|
224
|
-
|
|
233
|
+
commentBody += `| ---- | -------------- | ---- |
|
|
225
234
|
`;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
235
|
+
for (const block of removedBlocks) {
|
|
236
|
+
const oldBlockText = oldText.split("\n").slice(block.startLine, block.endLine).join("\n");
|
|
237
|
+
const blockSha256 = createHash("sha256").update(oldBlockText).digest("hex");
|
|
238
|
+
commentBody += `| \`${file.filename}\` | \`${block.startLine + 1}\u2013${block.endLine}\` | \`${block.uuid}\` |
|
|
230
239
|
`;
|
|
231
|
-
|
|
240
|
+
commentBody += `> **sha256** \`${blockSha256}\`
|
|
232
241
|
|
|
233
242
|
`;
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
}
|
|
244
|
+
commentBody += `Please review whether:
|
|
236
245
|
`;
|
|
237
|
-
|
|
246
|
+
commentBody += `- The removal of these compliance annotations is intentional
|
|
238
247
|
`;
|
|
239
|
-
|
|
248
|
+
commentBody += `- Alternative compliance measures have been implemented
|
|
240
249
|
`;
|
|
241
|
-
|
|
250
|
+
commentBody += `- The compliance coverage is still adequate
|
|
242
251
|
|
|
243
252
|
`;
|
|
244
|
-
|
|
253
|
+
commentBody += `---
|
|
245
254
|
|
|
246
255
|
`;
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const { octokit, owner, repo, prBranch, files } = context;
|
|
251
|
-
let changesContent = "";
|
|
252
|
-
let hasFindings = false;
|
|
253
|
-
for (const file of files) {
|
|
254
|
-
if (file.status === "added" || file.status === "removed") continue;
|
|
255
|
-
try {
|
|
256
|
-
const [oldText, newText] = await Promise.all([
|
|
257
|
-
fetchRawFileViaAPI({ octokit, owner, repo, path: file.filename, ref: "main" }),
|
|
258
|
-
fetchRawFileViaAPI({ octokit, owner, repo, path: file.filename, ref: prBranch })
|
|
259
|
-
]);
|
|
260
|
-
const changedBlocks = getChangedBlocks(oldText, newText);
|
|
261
|
-
const removedBlocks = getRemovedBlocks(oldText, newText);
|
|
262
|
-
if (changedBlocks.length > 0) {
|
|
263
|
-
hasFindings = true;
|
|
264
|
-
changesContent += generateChangedBlocksContent(file.filename, changedBlocks, newText);
|
|
265
|
-
}
|
|
266
|
-
if (removedBlocks.length > 0) {
|
|
267
|
-
hasFindings = true;
|
|
268
|
-
changesContent += generateRemovedBlocksContent(file.filename, removedBlocks, oldText);
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
console.error(`Error processing ${file.filename}: ${err}`);
|
|
269
259
|
}
|
|
270
|
-
} catch (err) {
|
|
271
|
-
console.error(`Error processing ${file.filename}: ${err}`);
|
|
272
260
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
if (deletedAnalysis.hasFindings) {
|
|
281
|
-
hasFindings = true;
|
|
282
|
-
commentBody += deletedAnalysis.warningContent;
|
|
283
|
-
}
|
|
284
|
-
const modifiedAnalysis = await analyzeModifiedFiles(context);
|
|
285
|
-
if (modifiedAnalysis.hasFindings) {
|
|
286
|
-
hasFindings = true;
|
|
287
|
-
commentBody += modifiedAnalysis.changesContent;
|
|
288
|
-
}
|
|
289
|
-
return { hasFindings, commentBody };
|
|
290
|
-
}
|
|
291
|
-
async function cleanupOldPosts(context, postMode) {
|
|
292
|
-
const { octokit, owner, repo, pull_number } = context;
|
|
293
|
-
if (postMode === "comment") {
|
|
294
|
-
await deleteOldIssueComments({ octokit, owner, repo, pull_number });
|
|
295
|
-
} else {
|
|
296
|
-
await dismissOldReviews({ octokit, owner, repo, pull_number });
|
|
297
|
-
await deleteOldReviewComments({ octokit, owner, repo, pull_number });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function crawlCommand() {
|
|
301
|
-
return new Command().command("crawl").description("Detect compliance-related changes between @lulaStart and @lulaEnd in PR files").addOption(
|
|
302
|
-
new Option("--post-mode <mode>", "How to post findings").choices(["review", "comment"]).default("review")
|
|
303
|
-
).action(async (opts) => {
|
|
304
|
-
const { owner, repo, pull_number } = getPRContext();
|
|
305
|
-
console.log(`Analyzing PR #${pull_number} in ${owner}/${repo} for compliance changes...`);
|
|
306
|
-
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
|
307
|
-
const pr = await octokit.pulls.get({ owner, repo, pull_number });
|
|
308
|
-
const prBranch = pr.data.head.ref;
|
|
309
|
-
const { data: files } = await octokit.pulls.listFiles({ owner, repo, pull_number });
|
|
310
|
-
const context = {
|
|
311
|
-
octokit,
|
|
312
|
-
owner,
|
|
313
|
-
repo,
|
|
314
|
-
pull_number,
|
|
315
|
-
prBranch,
|
|
316
|
-
files
|
|
317
|
-
};
|
|
318
|
-
const analysisResult = await performComplianceAnalysis(context);
|
|
319
|
-
await cleanupOldPosts(context, opts.postMode);
|
|
320
|
-
if (analysisResult.hasFindings) {
|
|
321
|
-
const finalBody = analysisResult.commentBody + closingBody;
|
|
261
|
+
if (opts.postMode === "comment") {
|
|
262
|
+
await deleteOldIssueComments({ octokit, owner, repo, pull_number });
|
|
263
|
+
} else {
|
|
264
|
+
await dismissOldReviews({ octokit, owner, repo, pull_number });
|
|
265
|
+
await deleteOldReviewComments({ octokit, owner, repo, pull_number });
|
|
266
|
+
}
|
|
267
|
+
if (leavePost) {
|
|
322
268
|
await postFinding({
|
|
323
269
|
octokit,
|
|
324
270
|
postMode: opts.postMode,
|
|
325
271
|
owner,
|
|
326
272
|
repo,
|
|
327
273
|
pull_number,
|
|
328
|
-
body:
|
|
274
|
+
body: commentBody + closingBody
|
|
329
275
|
});
|
|
330
276
|
const header = `Posted (${opts.postMode})`;
|
|
331
277
|
const underline = "-".repeat(header.length);
|
|
@@ -333,7 +279,7 @@ function crawlCommand() {
|
|
|
333
279
|
${header}
|
|
334
280
|
${underline}
|
|
335
281
|
|
|
336
|
-
${
|
|
282
|
+
${commentBody + closingBody}
|
|
337
283
|
|
|
338
284
|
`);
|
|
339
285
|
}
|
|
@@ -426,22 +372,15 @@ async function dismissOldReviews({
|
|
|
426
372
|
}
|
|
427
373
|
export {
|
|
428
374
|
LULA_SIGNATURE,
|
|
429
|
-
analyzeDeletedFiles,
|
|
430
|
-
analyzeModifiedFiles,
|
|
431
|
-
cleanupOldPosts,
|
|
432
375
|
containsLulaAnnotations,
|
|
433
376
|
crawlCommand,
|
|
434
|
-
createInitialCommentBody,
|
|
435
377
|
deleteOldIssueComments,
|
|
436
378
|
deleteOldReviewComments,
|
|
437
379
|
dismissOldReviews,
|
|
438
380
|
extractMapBlocks,
|
|
439
381
|
fetchRawFileViaAPI,
|
|
440
|
-
generateChangedBlocksContent,
|
|
441
|
-
generateRemovedBlocksContent,
|
|
442
382
|
getChangedBlocks,
|
|
443
383
|
getPRContext,
|
|
444
384
|
getRemovedBlocks,
|
|
445
|
-
performComplianceAnalysis,
|
|
446
385
|
postFinding
|
|
447
386
|
};
|