UNPKG

license-kit

Version:

Aggregate license notes of OSS libraries used in your Node.js project, analyze & visualize OSS licenses with AI-turbocharged tooling

1 lines 49 kB
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{64:(e,t,n)=>{"use strict";var r=Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},a=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},i=function(){var e=function(t){return(e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t})(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i=e(t),o=0;o<i.length;o++)"default"!==i[o]&&r(n,t,i[o]);return a(n,t),n}}(),o=function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.Types=void 0,t.Types=i(n(28126)),o(n(85010),t),o(n(47095),t),o(n(38286),t)},4010:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.categorizeLicense=o,t.analyzeLicenses=function(e){let t={[a.LicenseCategory.STRONG_COPYLEFT]:0,[a.LicenseCategory.WEAK_COPYLEFT]:0,[a.LicenseCategory.PERMISSIVE]:0,[a.LicenseCategory.UNKNOWN]:0},n={},r={};Object.entries(e).forEach(e=>{let[a,i]=e,l=i.type,s=o(l);t[s]++;{var c;let e=null!=l?l:"unknown";n[e]=(null!=(c=n[e])?c:0)+1}r[a]=s});let l=Object.keys(e).length,{categoriesPresence:s,description:c}=(0,i.getGraphStateInfo)(t);return{total:l,byCategory:t,byLicense:n,description:c,categoriesPresence:s,categorizedLicenses:r}};let r=n(44362),a=n(93816),i=n(42494);function o(e){return e&&"unknown"!==e?r.STRONG_COPYLEFT_LICENSES_LOWERCASE.has(e.toLowerCase())?a.LicenseCategory.STRONG_COPYLEFT:r.WEAK_COPYLEFT_LICENSES_LOWERCASE.has(e.toLowerCase())?a.LicenseCategory.WEAK_COPYLEFT:a.LicenseCategory.PERMISSIVE:a.LicenseCategory.UNKNOWN}},7542:(e,t)=>{"use strict";function n(e){return""===e||/^[#:>|-]/.test(e)||/^['"{}[\],&*#?|<>=!%@`]/.test(e)||/^[\s]|[\s]$/.test(e)||/^[\d.+-]/.test(e)||/[\n"'\\\s]/.test(e)||/^(true|false|yes|no|null|on|off)$/i.test(e)}function r(e){return/[@/_.]/.test(e)?'"'.concat(e,'"'):e}function a(e,t){if(e.includes("\n")){let n=e.split("\n").map(e=>"".concat(" ".repeat(t)).concat(e)).join("\n");return"|".concat(n?"\n"+n:"")}return n(e)?e.includes("'")&&!e.includes('"')?'"'.concat(e.replace(/["\\]/g,"\\$&"),'"'):"'".concat(e.replace(/'/g,"''"),"'"):e}Object.defineProperty(t,"__esModule",{value:!0}),t.needsQuoting=n,t.formatYamlKey=r,t.formatYamlValue=a,t.toYaml=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=" ".repeat(n);return null==t?"":Array.isArray(t)?t.map(t=>"".concat(i,"- ").concat(e(t,n+2).trimStart())).join("\n"):"object"==typeof t?Object.entries(t).filter(e=>{let[,t]=e;return null!=t}).map(t=>{let[a,o]=t,l=r(a),s=e(o,n+2);return Array.isArray(o)||"object"==typeof o&&null!==o?"".concat(i).concat(l,":\n").concat(s):("string"==typeof o&&o.includes("\n"),"".concat(i).concat(l,": ").concat(s))}).join("\n"):"string"==typeof t?a(t,n):String(t)}},16619:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},16637:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},16902:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>eJ});var r=n(54568),a=n(7620),i=n(64),o=n(31930),l=n(71774),s=n(13909),c=n(41321),d=n(25663),u=n(47226),p=n(94332),h=n(22348),g=n(96238),f=n(31141);function m(e){return"".concat(e.name,"@").concat(e.version)}let y={name:"root",dependencyType:"dependency",version:"0.0.0",requiredVersion:"0.0.0",parentPackages:[]},x=m(y);var j=n(71620),v=n(15263),b=function(e){return e.DEPENDENCY="dependency",e.DEV_DEPENDENCY="devDependency",e.OPTIONAL_DEPENDENCY="optionalDependency",e}({});let A=(0,j.v)()((0,v.D)(e=>({report:null,setReport:(t,n)=>e(e=>{e.report=t,e.reportName=n,e.loadedAt=new Date}),reportName:void 0,visibleDependencyTypes:[b.DEPENDENCY,b.DEV_DEPENDENCY,b.OPTIONAL_DEPENDENCY],toggleDependencyTypeVisibility:t=>e(e=>{e.visibleDependencyTypes=e.visibleDependencyTypes.includes(t)?e.visibleDependencyTypes.filter(e=>e!==t):[...e.visibleDependencyTypes,t]}),autoLoadFromServer:!1,setAutoLoadFromServer:t=>e({autoLoadFromServer:t}),selectedRoot:null,selectRoot:t=>e({selectedRoot:t}),hoveredLicense:null,setHoveredLicense:t=>e({hoveredLicense:t})})));var C=n(78204),L=n.n(C);function w(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:y,n=L().cloneDeep(e),r=new o.graphlib.Graph().setGraph({ranksep:144,nodesep:72}),a=m(t),i={meta:{...t,parentPackageKeys:[],key:a},rank:0},l={};l[i.meta.key]=i,r.setNode(a,i);let s=0,c=!1,d=!0;for(;Object.keys(n).length>0&&d;){for(let[e,a]of(d=!1,Object.entries(n))){let i=a.parentPackages.length?a.parentPackages.map(e=>m({name:e.name,version:e.resolvedVersion})):t===y?[x]:[];for(let t of i)if(t in l){if(!r.hasNode(e)){let t={meta:{...a,parentPackageKeys:i,key:e},rank:s};r.setNode(e,t),l[e]=t,d=!0}r.hasEdge(t,e)||(r.setEdge(t,e,{label:a.dependencyType}),d=!0)}delete n[e]}if(++s>300&&i.meta.key===x){console.warn("Reached maximum tree parsing depth of ".concat(300," (construction of direct sub-graph of selected root). Stopping to prevent infinite loop.")),c=!0;break}}n=L().cloneDeep(e);let u=-1;d=!0;let p=new Set(t===y?[]:[t]);for(;Object.keys(n).length>0&&d;){for(let[e,t]of(d=!1,p.entries())){for(let a of t.parentPackages.length?t.parentPackages:[y]){let t=m("resolvedVersion"in a?{name:a.name,version:a.resolvedVersion}:a),i="resolvedVersion"in a?n[t]:a;if(!r.node(t)){let e={meta:{...i,parentPackageKeys:[t],key:t},rank:u};r.setNode(t,e),l[t]=e,d=!0}r.hasEdge(t,m(e))||(r.setEdge(t,m(e),{label:i.dependencyType}),i!==y&&p.add(i))}p.delete(e)}if(Math.abs(--u)>300&&i.meta.key===x){console.warn("Reached maximum graph depth of ".concat(300," (construction of root trait). Stopping to prevent infinite loop.")),c=!0;break}}return{graph:r,incomplete:c,rootPackageKey:a}}var P=n(59560);let E=e=>e.y-24-10,k=e=>e.y+3.5,O=e=>e.y+24+10+10;var S=n(16879),N=n(54247),_=n(20596),I=n(18871),T=n(9257),D=n(30494),R=n(11239),z=n(88259),M=n(38456),G=n(41255),Y=n(5299),F=n(37187),W=n(27730),K=n(80761),V=n(48779),B=n(5005),U=n(33482),H=n(92622),J=n(44166),q=n(36624),Z=n(42800),X=n(42234),$=n(31352),Q=n(16678),ee=n(21338),et=n(58222);function en(e,t){switch(e){case i.LicenseCategory.STRONG_COPYLEFT:return(0,r.jsx)(Q.A,{color:null!=t?t:"strongCopyleft"});case i.LicenseCategory.WEAK_COPYLEFT:return(0,r.jsx)(ee.A,{color:null!=t?t:"weakCopyleft"});case i.LicenseCategory.PERMISSIVE:return(0,r.jsx)(et.A,{color:null!=t?t:"permissive"});default:return(0,r.jsx)(G.A,{color:null!=t?t:"unknown"})}}function er(e){switch(e){case i.LicenseCategory.STRONG_COPYLEFT:return"strongCopyleft";case i.LicenseCategory.WEAK_COPYLEFT:return"weakCopyleft";case i.LicenseCategory.PERMISSIVE:return"permissive";case i.LicenseCategory.UNKNOWN:default:return"unknown"}}var ea=n(81203),ei=n(4933);function eo(e){let{href:t,children:n,inline:a=!1}=e;return(0,r.jsxs)(ei.default,{href:t,target:"_blank",rel:"noopener noreferrer",sx:{display:a?"inline-flex":"flex",alignItems:"center",gap:.5},children:[null!=n?n:t," ",(0,r.jsx)(ea.default,{fontSize:"small"})]})}var el=n(85648),es=n(80366);function ec(e){var t,n;let{children:a,...i}=e;return(0,r.jsx)(el.oz,{...i,remarkPlugins:[...null!=(t=i.remarkPlugins)?t:[],es.A],components:{...null!=(n=i.components)?n:{},a:e=>{let{children:t,href:n}=e;return(0,r.jsx)(eo,{href:n,inline:!0,children:t})}},children:a})}function ed(){var e,t,n,o,l,s,d;let{classes:h}=eu(),{hoveredLicense:g}=A(),f=(0,p.ZC)(g),m=null!=g?g:f,y=(0,a.useMemo)(()=>(0,i.categorizeLicense)(null==m?void 0:m.type),[m]);return(0,r.jsxs)(c.default,{direction:"column",alignItems:"center",justifyContent:"center",gap:2,padding:2,children:[(0,r.jsxs)(c.default,{direction:"column",alignItems:"center",children:[(0,r.jsx)(u.A,{variant:"caption",children:"Currently hovered package ☝️"}),(0,r.jsx)(u.A,{variant:"h6",component:"span",children:(0,r.jsx)("pre",{className:h.hoveredPackageName,children:m?"".concat(null==m?void 0:m.name,"@").concat(null==m?void 0:m.version):"N/A"})})]}),(0,r.jsxs)(c.default,{direction:"row",alignItems:"center",justifyContent:"center",gap:2,width:"100%",flexWrap:"wrap",children:[(0,r.jsx)(W.A,{arrow:!0,title:"Dependency type",children:(0,r.jsx)($.A,{icon:(0,r.jsx)(Z.A,{}),label:null!=(t=null==m?void 0:m.dependencyType)?t:"N/A"})}),(0,r.jsx)(W.A,{arrow:!0,title:"License type & category (package.json 'type' field)",children:(0,r.jsx)($.A,{sx:{backgroundColor:null==(e=(0,P.n)(y))?void 0:e.main},icon:en(y),label:"".concat(null!=(n=null==m?void 0:m.type)?n:"---"," (").concat(y,")"),color:er(y)})}),(0,r.jsx)(W.A,{arrow:!0,title:"Version specifier",children:(0,r.jsx)($.A,{icon:(0,r.jsx)(X.A,{}),label:"Ver. spec.: ".concat(null!=(o=null==m?void 0:m.requiredVersion)?o:"N/A")})})]}),(0,r.jsxs)(c.default,{direction:"column",alignItems:"center",children:[(null==m?void 0:m.url)&&(0,r.jsx)(eo,{href:m.url}),(0,r.jsxs)(u.A,{variant:"body1",children:["Author: ",null!=(l=null==m?void 0:m.author)?l:"---"]}),(0,r.jsx)(u.A,{variant:"body1",textAlign:"center",width:"100%",paddingLeft:2,paddingRight:2,children:null!=(s=null==m?void 0:m.description)?s:"(No package description available)"})]}),(0,r.jsx)(J.A,{orientation:"horizontal",flexItem:!0}),(0,r.jsx)(u.A,{variant:"body1",width:"100%",paddingLeft:2,paddingRight:2,component:"div",children:(0,r.jsx)(ec,{children:"".concat((null==m?void 0:m.file)?"*Source: `".concat(m.file,"`*"):"","\n\n").concat(null!=(d=null==m?void 0:m.content)?d:"(No license text available)")})})]})}let eu=f.Df.create(()=>({hoveredPackageName:{display:"inline-block",whiteSpace:"pre-wrap",margin:0}}));var ep=n(50246),eh=n(47537),eg=n(16212),ef=n(55958);function em(e){let{reportName:t,loadedAt:n}=e,[i,o]=(0,a.useState)(()=>new Date);return(0,a.useEffect)(()=>{let e=setInterval(()=>{o(new Date)},1e3);return()=>clearInterval(e)},[]),(0,r.jsxs)(u.A,{variant:"caption",children:[t?"".concat(t,", "):"","loaded"," ",n&&((0,ep.v)(n,{start:new Date(i.getTime()-12e4),end:i})?(0,eh.m)(n,{addSuffix:!0,includeSeconds:!0}):(0,eg.r)(n,i)?"at "+(0,ef.GP)(n,"HH:mm"):"on "+(0,ef.GP)(n,"dd.MM HH:mm"))]})}var ey=n(69274),ex=n(81227),ej=n(61264),ev=n(54492),eb=n(20511);let eA=f.Df.create(e=>{let{theme:t}=e;return{container:{padding:t.spacing(2)},card:{minWidth:350,maxWidth:500},gridContainer:{display:"flex",flexDirection:"column",gap:t.spacing(3)},descriptionContainer:{display:"flex",flexDirection:"column"},descriptionSection:{textAlign:"center"},progressBar:{height:8,borderRadius:4,flex:1},categoryContainer:{display:"flex",flexDirection:"column"},categoryGrid:{display:"flex",flexDirection:"column",gap:t.spacing(1)},categoryItem:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:t.spacing(.5)},groupContainer:{display:"flex",flexDirection:"column",flex:1},licenseList:{maxHeight:300,overflowY:"auto"}}});function eC(e){let{analysis:t}=e,{classes:n}=eA(),[o,l]=(0,a.useState)(!1),s=(0,a.useMemo)(()=>{let e=Object.values(i.LicenseCategory),n={[i.LicenseCategory.STRONG_COPYLEFT]:[],[i.LicenseCategory.WEAK_COPYLEFT]:[],[i.LicenseCategory.PERMISSIVE]:[],[i.LicenseCategory.UNKNOWN]:[]};Object.entries(t.categorizedLicenses).forEach(e=>{let[t,r]=e;n[r]&&n[r].push(t)});let r=Object.keys(t.byLicense),a=r.map((n,a)=>{let o=(0,i.categorizeLicense)(n),l=h.exT(h.SVL).domain([0,r.length]);return{label:n,data:e.map(e=>e===o?t.byLicense[n]:0),backgroundColor:l(a),borderColor:l(a),borderWidth:1}});return{labels:e.map(e=>(0,i.getLicenseCategoryDescription)(e)),datasets:a}},[t]),c={responsive:!0,maintainAspectRatio:!1,scales:{x:{stacked:!0},y:{stacked:!0,...o?{type:"logarithmic",min:1,ticks:{callback:function(e){return Number(e).toString()}}}:{}}},plugins:{legend:{position:"bottom",labels:{boxWidth:12,font:{size:10}}},tooltip:{callbacks:{label:e=>{let n=e.dataset.label,r=e.parsed.y,a=(r/t.total*100).toFixed(1);return"".concat(n,": ").concat(r," (").concat(a,"%)")}}}}},d=(0,a.useMemo)(()=>{let e=Object.values(i.LicenseCategory),n=e.map(e=>{var n;return(null!=(n=t.byCategory[e])?n:0)/t.total*100});return{labels:e.map(e=>(0,i.getLicenseCategoryDescription)(e)),datasets:[{label:"Packages share",data:n,backgroundColor:(0,ey.X4)(ej.A[500],.25),borderColor:ej.A[700],borderWidth:2,pointBackgroundColor:ej.A[500],pointBorderColor:"#fff",pointHoverBackgroundColor:"#fff",pointHoverBorderColor:ej.A[500]}]}},[t]),p=Object.keys(t.byLicense),g=Object.values(t.byLicense),f=(0,a.useMemo)(()=>{let e=h.exT(h.SVL).domain([0,p.length]);return h.y17(p.length).map(t=>e(t))},[p]),m=(0,a.useCallback)(()=>{l(e=>!e)},[]);return(0,r.jsx)(F.A,{className:n.container,children:(0,r.jsxs)(F.A,{className:n.gridContainer,children:[(0,r.jsxs)(F.A,{className:n.groupContainer,children:[(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,children:"License types in categories"}),(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(u.A,{variant:"body2",children:"Logarithmic scale"}),(0,r.jsx)(ex.A,{size:"small",checked:o,onChange:m})]}),(0,r.jsx)(F.A,{sx:{height:400,position:"relative"},children:(0,r.jsx)(eb.yP,{data:s,options:c})})]}),(0,r.jsxs)(F.A,{className:n.groupContainer,children:[(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,children:"License type distribution"}),(0,r.jsx)(F.A,{sx:{height:400,position:"relative"},children:(0,r.jsx)(eb.Fq,{data:{labels:p,datasets:[{data:g,backgroundColor:f,borderColor:f,borderWidth:1}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom"},tooltip:{callbacks:{label:e=>{let n=(e.parsed/t.total*100).toFixed(1);return"".concat(e.label,": ").concat(e.parsed," (").concat(n,"%)")}}}}}})})]}),(0,r.jsxs)(F.A,{className:n.groupContainer,children:[(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,children:"License category distribution"}),(0,r.jsx)(F.A,{sx:{height:400,position:"relative"},children:(0,r.jsx)(eb.Vd,{data:d,options:{responsive:!0,maintainAspectRatio:!1,scales:{r:{beginAtZero:!0,max:100,ticks:{stepSize:20}}},plugins:{legend:{position:"bottom"},tooltip:{callbacks:{label:e=>"License Distribution"===e.dataset.label?"".concat(e.label,": ").concat(e.parsed.r.toFixed(1),"%"):"".concat(e.dataset.label,": ").concat(e.parsed.r.toFixed(1))}}}}})})]})]})})}function eL(){return(0,r.jsxs)(c.default,{children:[(0,r.jsx)(u.A,{variant:"h6",children:"Disclaimer"}),(0,r.jsx)(u.A,{children:"This tool does not serve as any sort of legal advice. Your use of this tool is at your own risk, remember to always verify results manually & consult with a legal professional before making any decisions."}),(0,r.jsx)(u.A,{children:"This tool is not affiliated with any of the companies or organizations that are listed in the report."}),(0,r.jsx)(u.A,{children:"This tool is not responsible for any errors or omissions in the report."}),(0,r.jsxs)(u.A,{children:["As to the mechanics of the way this tool operates, please see the limitations and design assumptions"," ",(0,r.jsx)(eo,{href:"https://callstackincubator.github.io/react-native-legal/docs/programmatic-usage.html#additional-details",inline:!0,children:"in the documentation"}),"."]})]})}function ew(){return(0,r.jsxs)(c.default,{gap:2,children:[(0,r.jsx)(u.A,{variant:"h6",children:"Help"}),(0,r.jsx)(u.A,{children:"This tool visualizes the license dependencies of your project."}),(0,r.jsx)(u.A,{children:"The first accordion section above presents you the breakdown of license types into categories and the share of specific license types in your project, which gives a quick overview of what was scanned."}),(0,r.jsx)(u.A,{children:"The second accordion section above presents you with a breakdown of the license categories, and the count of packages in each of them. Respective charts show you the share of specific license types within each of the categories, the share of license types in the project, and the share of license categories in the project."}),(0,r.jsxs)(u.A,{children:["The third accordion section above presents you (",(0,r.jsx)(eo,{href:"https://caniuse.com/mdn-api_summarizer",inline:!0,children:"if available in your browser"}),") an AI-generated summary of the graph, which may help you get some insights before the first manual look at the graph."]}),(0,r.jsx)(u.A,{children:"The GUI allows you to browse the graph, view information about the most-recently-hovered node on top of this sidebar. Clicking on a node changes the view to browse the subgraph rooted at this node, with the trace of nodes between the root project and the selected node, allowing you to see the causal hierarchy of packages. To cancel the filtered mode, click the selected root node again, or click the yellow text button on top of the graph pane, which will reset the view to be rooted at the root project node (i.e., show all nodes)."}),(0,r.jsx)(u.A,{children:"Remember that all data presented by the tool require manual verification. The presented information may be inaccurate or incomplete. Moreover, for packages classified as with 'unknown' license, manual inspection is required to check the conditions of the actual license."}),(0,r.jsxs)(u.A,{children:["OSS license attributions for this project can be found"," ",(0,r.jsx)(eo,{href:"/licenses",inline:!0,children:"here"}),"."]})]})}ev.t1.register(ev.Bs,ev.m_,ev.s$,ev.E8,ev.PP,ev.kc,ev.OJ,ev.pr,ev.FN,ev.No,ev.dN);var eP=n(96987),eE=n(72101),ek=n(3775);function eO(e){let{analysis:t}=e,{classes:n}=eA(),{palette:o}=(0,l.A)(),s=(0,a.useMemo)(()=>Object.entries(t.byLicense).sort((e,t)=>{let[,n]=e,[,r]=t;return r-n}),[t.byLicense]),c=t.total;return(0,r.jsx)(F.A,{className:n.container,children:(0,r.jsxs)(F.A,{className:n.gridContainer,children:[(0,r.jsx)(F.A,{className:n.descriptionContainer,children:(0,r.jsx)(F.A,{className:n.descriptionSection,children:(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,style:{color:t.categoriesPresence.hasAllPermissive?o.permissive.main:t.categoriesPresence.hasAnyUnknown?o.unknown.main:t.categoriesPresence.hasAnyStrongCopyleft?o.strongCopyleft.main:o.weakCopyleft.main},children:t.description})})}),(0,r.jsxs)(F.A,{className:n.categoryContainer,children:[(0,r.jsxs)(u.A,{variant:"subtitle1",gutterBottom:!0,children:["License Categories (",c," packages)"]}),(0,r.jsx)(F.A,{className:n.categoryGrid,children:Object.entries(t.byCategory).map(e=>{let[t,a]=e,o=c>0?Math.round(a/c*100):0;return a>0&&0===o&&(o=1),100===o&&a<c&&(o=99),(0,r.jsxs)(F.A,{className:n.categoryItem,children:[(0,r.jsxs)(F.A,{display:"flex",alignItems:"center",gap:1,children:[en(t,0===a?"disabled":void 0),(0,r.jsx)(u.A,{variant:"body2",color:0===a?"textDisabled":void 0,children:(0,i.getLicenseCategoryDescription)(t)})]}),(0,r.jsx)(F.A,{display:"flex",alignItems:"center",gap:1,children:(0,r.jsx)($.A,{disabled:0===a,label:"".concat(a," (").concat(o,"%)"),size:"small",color:er(t),variant:"outlined"})})]},t)})})]}),(0,r.jsxs)(F.A,{className:n.groupContainer,children:[(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,children:"Discovered license types"}),(0,r.jsx)(eP.A,{className:n.licenseList,children:s.map((e,t)=>{let[n,i]=e,o=c>0?Math.round(i/c*100):0;return(0,r.jsxs)(a.Fragment,{children:[(0,r.jsx)(eE.Ay,{children:(0,r.jsx)(ek.A,{primary:n,secondary:"".concat(i," packages (").concat(o,"%)")})}),t<s.length-1&&(0,r.jsx)(J.A,{})]},n)})})]})]})})}var eS=n(37931),eN=n(44822),e_=n(49292),eI=n(65310),eT=function(e){return e[e.CHECKING_AVAILABILITY=0]="CHECKING_AVAILABILITY",e[e.UNAVAILABLE=1]="UNAVAILABLE",e[e.DOWNLOADING=2]="DOWNLOADING",e[e.READY=3]="READY",e}({});let eD=(0,j.v)()((0,v.D)(e=>({ensureInitialized:async()=>{if(!("Summarizer"in window))return console.error("[Summarizer] Summarizer API not available in this browser"),e({summarizerState:1}),null;let t=await Summarizer.availability();if(console.log("[Summarizer] Model availability result: ".concat(t)),"unavailable"===t)return e({summarizerState:1}),null;e({summarizerState:2});let n=await Summarizer.create({type:"tldr",format:"markdown",length:"long",monitor(t){t.addEventListener("downloadprogress",t=>{console.log("[TLDR Summarizer] Model downloaded ".concat(100*t.loaded,"%")),e({summarizerDownloadProgress:100*t.loaded}),1===t.loaded&&e({summarizerState:3})})}}),r=await Summarizer.create({type:"key-points",format:"markdown",length:"long",monitor(t){t.addEventListener("downloadprogress",t=>{console.log("[Key-Points Summarizer] Model downloaded ".concat(100*t.loaded,"%")),e({summarizerDownloadProgress:100*t.loaded}),1===t.loaded&&e({summarizerState:3})})}});e({tldrSummarizer:n,keyPointsSummarizer:r})},tldrSummarizer:null,keyPointsSummarizer:null,summarizerState:0,summarizerDownloadProgress:0})));function eR(){let{classes:e}=eA(),{selectedRoot:t,report:n}=A(),{ensureInitialized:o,tldrSummarizer:l,keyPointsSummarizer:s,summarizerDownloadProgress:p,summarizerState:h}=eD(),[g,f]=(0,a.useState)(null),[m,y]=(0,a.useState)(""),[x,j]=(0,a.useState)(0),v=(0,a.useRef)(0);(0,a.useEffect)(()=>{o()},[o]),(0,a.useEffect)(()=>{if(!l||!s||!n)return;let e=++v.current,t=Object.entries(n).filter(e=>{let[,t]=e;return(0,i.categorizeLicense)(t.type)!==i.LicenseCategory.PERMISSIVE}).map(e=>{let[t,r]=e,{graph:a}=w(n,n[t]),i=new Set,o=[t];for(;null==o?void 0:o.length;){let e=[];for(let t of o){if(i.has(t))continue;i.add(t);let n=a.predecessors(t);n&&e.push(...n)}e.length||(e=void 0),o=e}return"- `".concat(t,"`: ").concat(r.type," license").concat(r.parentPackages.length?", is introduced to the project by the following libraries: ".concat(Array.from(i).toReversed().map(e=>"`".concat(e,"`")).join(" - ")):"")}).join("\n"),r="Core analysis: project graph includes the following packages that were not classified as fully permissive:\n"+t.replaceAll("`","");y(t),console.log("Running AI summarizations (TLDR + Key Points) of the following text:\n",r),f(null),Promise.all([l.summarize(r),s.summarize(r)]).then(t=>{let[n,r]=t;v.current===e&&(console.log("Generated summary:\n",n,r),f("##### TL;DR of the project\n"+n+"\n\n##### Key points\n"+r))})},[n,t,x,l,s]);let b=(0,a.useCallback)(()=>{j(e=>e+1)},[]);return(0,r.jsx)(F.A,{className:e.container,children:(0,r.jsx)(F.A,{className:e.gridContainer,children:(0,r.jsxs)(F.A,{className:e.groupContainer,children:[(0,r.jsxs)(c.default,{justifyContent:"space-between",alignItems:"center",direction:"row",mb:2,children:[(0,r.jsx)(u.A,{variant:"subtitle1",gutterBottom:!0,children:"AI-generated summary"}),(0,r.jsx)(H.A,{startIcon:(0,r.jsx)(eS.A,{}),onClick:b,children:"Re-generate"})]}),(0,r.jsxs)(eN.A,{severity:"info",sx:{mb:2},children:["The information below is generated by your browser's built-in language model using the"," ",(0,r.jsx)(eo,{href:"https://webmachinelearning.github.io/writing-assistance-apis/#summarizer",inline:!0,children:"Summarization API"}),", based on information from the report. Please be aware that the information may not be accurate or even may be false, as it usual with language models."]}),h===eT.CHECKING_AVAILABILITY?(0,r.jsx)(d.A,{}):h===eT.UNAVAILABLE?(0,r.jsxs)(u.A,{children:["Sorry, the required Summarization API is not available on your browser. Please consult"," ",(0,r.jsx)(eo,{href:"https://caniuse.com/mdn-api_summarizer",inline:!0,children:"Can I use..."})," ","to check which browsers currently support it."]}):h===eT.DOWNLOADING?(0,r.jsxs)(c.default,{justifyContent:"center",alignContent:"center",gap:1,direction:"column",children:[(0,r.jsx)(e_.A,{value:p}),(0,r.jsxs)(u.A,{textAlign:"center",children:["Downloading Summarization API model - ",p,"%"]})]}):g?(0,r.jsx)(ec,{children:"#### AI-generated summary\n"+g+"\n\n#### Additional details for licenses not classified as fully permissive *(these are non-AI-generated)*:\n"+m}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{width:"80%"}),(0,r.jsx)("br",{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)("br",{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)("br",{}),(0,r.jsx)(eI.A,{}),(0,r.jsx)(eI.A,{width:"40%"})]})]})})})}function ez(e){let{analysis:t}=e,{classes:n}=eM(),{reportName:i,loadedAt:o}=A(),{themeMode:l,setThemeMode:s}=(0,q.C)(),[d,p]=(0,a.useState)(!0),h=(0,a.useCallback)(()=>{p(e=>!e)},[]),g=(0,a.useCallback)(()=>{s("dark"===l?"light":"dark")},[s,l]);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(Y.A,{elevation:3,className:n.sidebar,style:{width:d?550:50},children:[(0,r.jsxs)(c.default,{direction:"column",className:n.sidebarHeader,children:[(0,r.jsxs)(F.A,{className:n.toggleContainer,children:[(0,r.jsx)("pre",{className:n.sidebarHeading,children:"license-kit visualize"}),(0,r.jsx)(W.A,{title:"Toggle theme",arrow:!0,children:(0,r.jsx)(K.A,{onClick:g,children:"dark"===l?(0,r.jsx)(S.A,{}):(0,r.jsx)(N.A,{})})}),(0,r.jsx)(W.A,{title:d?"Collapse sidebar":"Expand sidebar",arrow:!0,children:(0,r.jsx)(K.A,{onClick:h,className:n.toggleButton,children:d?(0,r.jsx)(_.A,{}):(0,r.jsx)(I.A,{})})})]}),d&&(0,r.jsx)(em,{reportName:i,loadedAt:o})]}),d?(0,r.jsxs)(c.default,{sx:{flex:1,display:"flex",flexDirection:"column"},children:[(0,r.jsx)(ed,{}),(0,r.jsxs)(V.A,{defaultExpanded:!0,children:[(0,r.jsx)(B.A,{expandIcon:(0,r.jsx)(T.A,{}),children:(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(D.A,{}),(0,r.jsx)(u.A,{variant:"body2",children:"Stats & graph state"})]})}),(0,r.jsx)(U.A,{children:(0,r.jsx)(F.A,{className:n.accordionContents,children:(0,r.jsx)(eO,{analysis:t})})})]}),(0,r.jsxs)(V.A,{defaultExpanded:!0,children:[(0,r.jsx)(B.A,{expandIcon:(0,r.jsx)(T.A,{}),children:(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(R.A,{}),(0,r.jsx)(u.A,{variant:"body2",children:"Statistics"})]})}),(0,r.jsx)(U.A,{children:(0,r.jsx)(F.A,{className:n.accordionContents,children:(0,r.jsx)(eC,{analysis:t})})})]}),(0,r.jsxs)(V.A,{defaultExpanded:!0,children:[(0,r.jsx)(B.A,{expandIcon:(0,r.jsx)(T.A,{}),children:(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(z.A,{}),(0,r.jsx)(u.A,{variant:"body2",children:"AI summary"})]})}),(0,r.jsx)(U.A,{children:(0,r.jsx)(F.A,{className:n.accordionContents,children:(0,r.jsx)(eR,{})})})]}),(0,r.jsxs)(V.A,{defaultExpanded:!0,children:[(0,r.jsx)(B.A,{expandIcon:(0,r.jsx)(T.A,{}),children:(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(M.A,{}),(0,r.jsx)(u.A,{variant:"body2",children:"Disclaimer"})]})}),(0,r.jsx)(U.A,{children:(0,r.jsx)(F.A,{className:n.accordionContents,children:(0,r.jsx)(eL,{})})})]}),(0,r.jsxs)(V.A,{defaultExpanded:!0,children:[(0,r.jsx)(B.A,{expandIcon:(0,r.jsx)(T.A,{}),children:(0,r.jsxs)(F.A,{sx:{display:"flex",alignItems:"center",gap:1},children:[(0,r.jsx)(G.A,{}),(0,r.jsx)(u.A,{variant:"body2",children:"Help"})]})}),(0,r.jsx)(U.A,{children:(0,r.jsx)(F.A,{className:n.accordionContents,children:(0,r.jsx)(ew,{})})})]})]}):(0,r.jsxs)(c.default,{className:n.collapsedContent,spacing:1,children:[(0,r.jsx)(W.A,{title:"Analysis",placement:"right",arrow:!0,children:(0,r.jsx)("span",{children:(0,r.jsx)(H.A,{onClick:h,color:"primary",size:"large",sx:{flexDirection:"column"},children:(0,r.jsx)(D.A,{})})})}),(0,r.jsx)(J.A,{orientation:"horizontal",flexItem:!0}),(0,r.jsx)(W.A,{title:"Report",placement:"right",arrow:!0,children:(0,r.jsx)("span",{children:(0,r.jsx)(H.A,{onClick:h,color:"primary",size:"large",sx:{flexDirection:"column"},children:(0,r.jsx)(R.A,{})})})}),(0,r.jsx)(J.A,{orientation:"horizontal",flexItem:!0}),(0,r.jsx)(W.A,{title:"Disclaimer",placement:"right",arrow:!0,children:(0,r.jsx)("span",{children:(0,r.jsx)(H.A,{onClick:h,color:"primary",size:"large",sx:{flexDirection:"column"},children:(0,r.jsx)(M.A,{})})})}),(0,r.jsx)(J.A,{orientation:"horizontal",flexItem:!0}),(0,r.jsx)(W.A,{title:"Help",placement:"right",arrow:!0,children:(0,r.jsx)("span",{children:(0,r.jsx)(H.A,{onClick:h,color:"primary",size:"large",sx:{flexDirection:"column"},children:(0,r.jsx)(G.A,{})})})})]})]})})}let eM=f.Df.create(e=>{let{theme:t}=e;return{mainContainer:{display:"flex",width:"100%",height:"100%",position:"relative"},sidebar:{flexShrink:0,height:"100vh",overflow:"auto",borderRadius:0,borderRight:"1px solid ".concat(t.palette.divider),transition:t.transitions.create("width",{easing:t.transitions.easing.sharp,duration:t.transitions.duration.enteringScreen}),display:"flex",flexDirection:"column"},sidebarHeader:{padding:t.spacing(1),borderBottom:"1px solid ".concat(t.palette.divider),paddingLeft:t.spacing(2)},toggleContainer:{display:"flex",justifyContent:"flex-end",alignItems:"center"},toggleButton:{padding:t.spacing(1)},collapsedContent:{display:"flex",flexDirection:"column",alignItems:"center",padding:t.spacing(2,1)},accordionContents:{flex:1,overflow:"auto"},container:{flex:1,overflow:"hidden",display:"flex",width:"100%",height:"100%"},svg:{display:"flex",flex:1},sidebarHeading:{flex:1,textAlign:"start"}}});function eG(e){let{data:t}=e,{width:n,height:f}=(0,p.lW)(),y=(0,l.A)(),{enqueueSnackbar:j}=(0,g.dh)(),{classes:v}=eY(),{selectedRoot:b,selectRoot:C,setHoveredLicense:L}=A(),[S,N]=(0,a.useState)(!1),_=(0,a.useRef)(null),I=(0,a.useRef)(null),{graph:T,incomplete:D,rootPackageKey:R}=(0,a.useMemo)(()=>{console.log("Re-generating graph...");let e=w(t,null!=b?b:void 0);return console.log("Graph re-generated"),e},[t,b]),z=(0,a.useMemo)(()=>(0,i.analyzeLicenses)(t),[t]),M=function(e){let t=(0,l.A)();return(0,a.useCallback)(function(n,r){let{rectFillFactory:a,backgroundRectAlpha:i=.65}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.each(function(n){var o,l;let s=h.Ltv(this),c=null==(o=e.node(n))?void 0:o.meta,d=r(s,c).node().getBBox();s.insert("rect","text").attr("x",d.x-4).attr("y",d.y-2).attr("width",d.width+8).attr("height",d.height+4).attr("fill",null!=(l=null==a?void 0:a(c))?l:t.palette.background.paper).attr("fill-opacity",i).attr("rx",10).style("pointer-events","none")})},[e,t.palette.background.paper])}(T);(0,a.useEffect)(()=>{D&&j({message:"Stopped parsing the tree early due to excessive depth. This is likely a bug. The tree may be INCOMPLETE.",variant:"warning"})},[j,D]);let{selectedNodeStrokeColor:G,linkColor:Y,labelTextColor:F,licenseTextColor:W}=(0,a.useMemo)(()=>"dark"===y.palette.mode?{selectedNodeStrokeColor:"#fff",linkColor:"#999",labelTextColor:"#fff",licenseTextColor:"#fff"}:{selectedNodeStrokeColor:"#000",linkColor:"#666",labelTextColor:"#000",licenseTextColor:"#000"},[y.palette.mode]),K=(0,a.useRef)(!1),V=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(n&&f&&_.current){if(null!==V.current){if(K.current)return;clearTimeout(V.current)}console.log("Preparing to render graph..."),N(!0),V.current=setTimeout(()=>{if(K.current)return;K.current=!0,console.log("Rendering new graph...",T.nodes());let e=h.Ltv(_.current),t=e.select("g");t.selectAll("*").remove(),T.nodes().forEach(function(e){let t=T.node(e);t.rx=t.ry=5,t.width=t.height=48}),(0,o.layout)(T);let n=h.s_O().extent([[0,0],[T.graph().width,T.graph().height]]).scaleExtent([.1,20]).on("zoom",function(){t.attr("transform",h._V(this))});e.call(n).on("wheel.zoom",t=>{var r;t.preventDefault();let a=null!=(r=e.property("__zoom").k)?r:1;t.ctrlKey?n.scaleTo(e,a*Math.pow(2,-t.deltaY/100),h.WnM(t)):n.translateBy(e,-(t.deltaX/a),-(t.deltaY/a))});{let t=T.node(R);e.call(n.transform,h.GSI.translate(e.node().getBoundingClientRect().width/2-.75*t.x,e.node().getBoundingClientRect().height/2-.75*t.y).scale(.75))}let r=t.selectAll("line").data(T.edges()).enter().append("line").attr("x1",e=>{var t,n;return null!=(n=null==(t=T.node(e.v))?void 0:t.x)?n:null}).attr("y1",e=>{var t,n;return null!=(n=null==(t=T.node(e.v))?void 0:t.y)?n:null}).attr("x2",e=>{var t,n;return null!=(n=null==(t=T.node(e.w))?void 0:t.x)?n:null}).attr("y2",e=>{var t,n;return null!=(n=null==(t=T.node(e.w))?void 0:t.y)?n:null}).attr("stroke",Y).attr("stroke-width",2),a=t.selectAll("circle").data(T.nodes()).enter().append("circle").attr("cx",e=>{var t,n;return null!=(n=null==(t=T.node(e))?void 0:t.x)?n:null}).attr("cy",e=>{var t,n;return null!=(n=null==(t=T.node(e))?void 0:t.y)?n:null}).attr("r",24).style("fill",e=>(function(e){let t=z.categorizedLicenses[e],n=(0,P.n)(t);return n?n.main:y.palette.success.main})(e)).attr("stroke",null).attr("stroke-width",2).attr("cursor","pointer").on("mouseover",(e,t)=>{let n=h.kYK().duration(200),i=T.node(t);for(let[a,o,d]of(L(i.meta),h.Ltv(e.currentTarget).raise().transition(n).attr("r",29).attr("stroke-width",3).attr("stroke",G).filter(e=>e===t).style("opacity",()=>1),r.transition(n).style("opacity",e=>i.meta.parentPackageKeys.find(t=>t===e.v||t===e.w)?1:.3),[[l,E,"up"],[s,k,null],[c,O,"down"]]))a.filter(e=>e===t).raise(),a.select("rect").transition(n).style("fill-opacity",1),a.transition(n).style("opacity",e=>{let t=T.node(e);return 0===i.meta.parentPackageKeys.length||i.meta.parentPackageKeys.includes(t.meta.key)||t.meta.parentPackageKeys.find(e=>i.meta.parentPackageKeys.includes(e))?1:.3}),d&&a.transition(n).attr("transform",e=>{var t;let n=T.node(e),r=null!=(t=null==n?void 0:n.x)?t:0,a=n.meta===i.meta?o(n)+("up"===d?-1:1)*29/4:o(n);return"translate(".concat(r,", ").concat(a,")")}),a.transition(n).select("text").attr("font-size",e=>e===i.meta.key?"".concat(21,"px"):"".concat(14,"px"));a.filter(e=>e!==t).transition(n).style("opacity",e=>{let t=T.node(e);return 0===i.meta.parentPackageKeys.length||i.meta.parentPackageKeys.includes(t.meta.key)||t.meta.parentPackageKeys.find(e=>i.meta.parentPackageKeys.includes(e))?1:.3})}).on("mouseout",()=>{let e=h.kYK().duration(200);for(let[t,n]of(L(null),r.transition(e).style("opacity",1),[[l,E],[s,k],[c,O]]))t.transition(e).attr("transform",e=>{let t=T.node(e);return"translate(".concat(t.x,", ").concat(n(t),")")}),t.transition(e).style("opacity",1);for(let t of[l,s,c])t.transition(e).select("text").attr("font-size","".concat(14,"px"));a.transition(e).style("opacity",1).attr("r",24).attr("stroke-width",2).attr("stroke",null)}).on("click",(e,t)=>{var n;let r=null==(n=T.node(t))?void 0:n.meta;r.key===R||r.key===x?C(null):C(null!=r?r:null)}),l=t.selectAll("g.label").data(T.nodes()).enter().append("g").attr("class","label").attr("transform",e=>{var t;let n=T.node(e),r=null!=(t=null==n?void 0:n.x)?t:0,a=E(n);return"translate(".concat(r,", ").concat(a,")")}).style("pointer-events","none");M(l,(e,t)=>{let n=m(t),r=z.categorizedLicenses[n],a=n!==x&&r!==i.LicenseCategory.PERMISSIVE,o=e.append("text").attr("text-anchor","middle").attr("font-size","".concat(14,"px")).attr("fill",F).attr("stroke",F).attr("stroke-width",.2).text(a?"".concat(t.name," ⚠️"):t.name).style("pointer-events","none");return a&&o.attr("font-weight","bold"),o});let s=t.selectAll("g.version-label").data(T.nodes()).enter().append("g").attr("class","version-label").attr("transform",e=>{var t;let n=T.node(e),r=null!=(t=null==n?void 0:n.x)?t:0,a=k(n);return"translate(".concat(r,", ").concat(a,")")});M(s,(e,t)=>e.append("text").attr("text-anchor","middle").attr("font-size","".concat(14,"px")).attr("fill",W).text(t.version).style("pointer-events","none"),{rectFillFactory:e=>{let t=m(e),n=t===x?i.LicenseCategory.PERMISSIVE:z.categorizedLicenses[t],r=(0,P.n)(n);return null==r?void 0:r.main},backgroundRectAlpha:1});let c=t.selectAll("g.license-label").data(T.nodes()).enter().append("g").attr("class","license-label").attr("transform",e=>{var t;let n=T.node(e),r=null!=(t=null==n?void 0:n.x)?t:0,a=O(n);return"translate(".concat(r,", ").concat(a,")")}).attr("fill",e=>{var t;let n=z.categorizedLicenses[e],r=(0,P.n)(n);return null!=(t=null==r?void 0:r.main)?t:W});M(c,(e,t)=>{var n,r;let a=m(t),i=z.categorizedLicenses[a],o=(0,P.n)(i),l=null!=(n="dark"===y.palette.mode?null==o?void 0:o.light:null==o?void 0:o.dark)?n:W;return e.append("text").attr("text-anchor","middle").attr("font-size","".concat(14,"px")).attr("fill",l).attr("stroke",y.palette.getContrastText(y.palette.background.default)).attr("stroke-width",.2).text(null!=(r=t.type)?r:"(unknown)").style("pointer-events","none")}),console.log("Graph rendered"),N(!1),K.current=!1,V.current=null},1e3)}},[n,f,T,F,z.categorizedLicenses,W,Y,M,R,C,G,y.palette,L]);let B=R!==x;return(0,r.jsxs)("div",{className:v.mainContainer,children:[(0,r.jsx)(ez,{analysis:z}),(0,r.jsx)(s.A,{sx:e=>({color:"#fff",zIndex:e.zIndex.drawer+1}),open:S,children:(0,r.jsxs)(c.default,{alignItems:"center",gap:2,justifyContent:"center",direction:"column",children:[(0,r.jsx)(d.A,{disableShrink:!0}),(0,r.jsx)(u.A,{children:"Rendering dependency graph, this may take some time based on the size of your project..."})]})}),(0,r.jsxs)("div",{className:v.flex,children:[(0,r.jsxs)(c.default,{direction:"row",justifyContent:"space-evenly",alignItems:"center",gap:1,children:[(0,r.jsxs)(u.A,{textAlign:"center",display:"inline-flex",alignItems:"center",whiteSpace:"break-spaces",component:"span",children:["\uD83C\uDF34 Current root: ",(0,r.jsx)("pre",{className:v.inline,children:R}),(0,r.jsxs)(u.A,{color:B?"warning":void 0,variant:"caption",sx:{cursor:B?"pointer":"default"},onClick:()=>C(null),children:[" ","(",B?"override ⚠️ click here to reset view":"default",")"]})]}),(0,r.jsxs)(u.A,{textAlign:"center",variant:"caption",children:["Dependency graph with ","".concat(T.nodes().length," nodes & ").concat(T.edges().length," edges"),"."]})]}),(0,r.jsx)("div",{ref:I,className:v.container,children:(0,r.jsx)("svg",{className:v.svg,ref:_,children:(0,r.jsx)("g",{})})})]})]})}let eY=f.Df.create(()=>({mainContainer:{display:"flex",width:"100%",height:"100%",position:"relative",flexDirection:"row"},container:{flex:1,overflow:"hidden",display:"flex",width:"100%",height:"100%"},svg:{display:"flex",flex:1},sidebarHeading:{flex:1,textAlign:"start"},flex:{flex:1},inline:{display:"inline-flex"}}));var eF=n(4919),eW=n(51622),eK=n(16848);function eV(){let{autoLoadFromServer:e,setReport:t}=A(),{enqueueSnackbar:n}=(0,g.dh)();return(0,a.useEffect)(()=>{if(e){console.log("Setting up event source");let e=new EventSource("/api/events");return e.onmessage=e=>{try{let{type:r,report:a,projectName:i}=JSON.parse(e.data);"UPDATE"===r?(n({message:"Project updated, regenerating graph...",variant:"info"}),t(a,i)):console.warn("Unknown event type with raw event packet:",e.data)}catch(e){console.error("Error processing event data",e)}},()=>{console.log("Closing event source"),e.close()}}},[e,n,t]),null}let eB=eK.P.create(eW.A);function eU(e){let{children:t}=e,{enqueueSnackbar:n}=(0,g.dh)(),{classes:i,cx:o}=eH(),{report:s,setReport:p,setAutoLoadFromServer:h}=A(),{palette:f}=(0,l.A)(),m=(0,a.useRef)(null),[y,x]=(0,a.useState)(!1),[j,v]=(0,a.useState)(!1),[b,C]=(0,a.useState)(!1),[L,w]=(0,a.useState)(!1),[P,E]=(0,a.useState)(null),k=(0,a.useCallback)(e=>{if(!e||"application/json"!==e.type)return void n({message:"Please select a valid JSON file.",variant:"error"});let t=new FileReader;t.onload=()=>{try{if(!t.result)throw Error("File reading error");let n=JSON.parse(t.result);h(!1),p(n,e.name)}catch(e){console.error("Error parsing JSON file:",e),n({message:"Failed to parse JSON file. Please ensure it is a valid JSON.",variant:"error"}),E(e)}finally{w(!1)}},w(!0),t.readAsText(e)},[n,h,p]),O=(0,a.useMemo)(()=>y||!s&&!L&&j&&!b,[y,s,L,j,b]),S=(0,a.useRef)(0);return(0,r.jsxs)(eK.P.div,{className:o(i.dropZone,null===s&&i.emptyDropZone),onDragEnter:e=>(S.current++,x(!0),e.preventDefault(),!0),onDragOver:e=>(e.preventDefault(),!0),onDragLeave:()=>{S.current=Math.max(0,S.current-1),x(S.current>0)},onMouseOver:()=>v(!0),onMouseOut:()=>v(!1),onDrop:e=>{e.preventDefault(),S.current=0,x(!1),v(!1),e.dataTransfer.files.length>0&&k(e.dataTransfer.files[0])},onClick:()=>{if(S.current=0,x(!1),v(!1),!s){var e;null==(e=m.current)||e.click()}},variants:{hovered:{borderWidth:4,borderRadius:40*!s,backgroundColor:(0,ey.X4)(f.secondary.light,.35),borderStyle:"dashed"},defaultNoReport:{borderWidth:2,borderRadius:10,backgroundColor:(0,ey.X4)(f.secondary.light,.05),borderStyle:"solid"},defaultReport:{borderWidth:4,borderStyle:"solid"}},style:{borderColor:O?f.secondary.main:s?"transparent":f.secondary.main},transition:{type:"tween"},animate:O?"hovered":s?"defaultReport":"defaultNoReport",children:[(0,r.jsx)(eV,{}),(0,r.jsx)("input",{type:"file",accept:".json,application/json",ref:m,className:i.hidden,onChange:e=>{e.target.files&&e.target.files.length>0&&k(e.target.files[0])}}),L?(0,r.jsxs)(c.default,{alignItems:"center",gap:2,justifyContent:"center",direction:"column",children:[(0,r.jsx)(d.A,{disableShrink:!0}),(0,r.jsx)(u.A,{children:"Loading report, this may take some time based on the size of your project..."})]}):s?t:(0,r.jsxs)(c.default,{alignItems:"center",children:[(0,r.jsx)(eB,{sx:{padding:6},variants:{hovered:{scale:1.1,color:f.secondary.main},default:{scale:1}},animate:y?"hovered":"default",children:(0,r.jsx)(eF.A,{sx:{fontSize:60}})}),(0,r.jsxs)("span",{className:o(i.helpText,i.inlineFlexChildren,i.honorWhiteSpace),children:["Drag & drop a ",(0,r.jsx)("pre",{className:i.honorWhiteSpace,children:"react-native-legal"})," JSON report here, or click to select a file."]}),(0,r.jsx)("p",{children:"or"}),(0,r.jsx)(F.A,{onMouseOver:()=>C(!0),onMouseOut:()=>C(!1),onClick:e=>{e.stopPropagation()},className:i.reenablePointerEvents,children:(0,r.jsx)(H.A,{size:"large",onClick:async()=>{h(!0),w(!0);try{let e=await fetch("".concat(window.location.origin,"/api/report")),t=await e.json();p(t.report,t.name)}catch(e){console.error("Error auto-loading report:",e),n({message:"Failed to auto-load report. Please try again.",variant:"error"}),h(!1)}finally{w(!1)}},variant:"outlined",className:o(i.helpText,i.inlineFlexChildren,i.honorWhiteSpace,i.reenablePointerEvents,i.autoLoadButton),children:"Auto-load from the server"})}),P&&(0,r.jsx)("pre",{children:"string"==typeof P?P:P.message})]})]})}let eH=f.Df.create(e=>{let{theme:t}=e;return{helpText:{fontSize:20},dropZone:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",boxSizing:"border-box"},emptyDropZone:{padding:10,margin:10,cursor:"pointer","& > *":{pointerEvents:"none"}},inlineFlexChildren:{"& > *":{display:"inline-flex"}},reenablePointerEvents:{pointerEvents:"all"},honorWhiteSpace:{whiteSpace:"pre-wrap"},hidden:{display:"none"},autoLoadButton:{margin:t.spacing(4)}}});function eJ(){let{report:e}=A();return(0,r.jsx)(eU,{children:e?(0,r.jsx)(eG,{data:e}):null})}},28126:(e,t,n)=>{"use strict";var r=Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},a=function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(67741),t),a(n(16619),t),a(n(72195),t),a(n(64379),t),a(n(72003),t),a(n(64979),t),a(n(16637),t),a(n(49524),t),a(n(84391),t),a(n(31862),t),a(n(52414),t),a(n(41268),t)},31862:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},36624:(e,t,n)=>{"use strict";n.d(t,{C:()=>i});var r=n(71620),a=n(15263);let i=(0,r.v)()((0,a.D)(e=>({themeMode:"dark",setThemeMode:t=>e({themeMode:t})})))},38286:(e,t,n)=>{"use strict";var r=Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)}(n(44362),t)},41268:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},42494:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getGraphStateInfo=function(e){let t=e[r.LicenseCategory.UNKNOWN]>0,n=e[r.LicenseCategory.WEAK_COPYLEFT]>0,a=e[r.LicenseCategory.STRONG_COPYLEFT]>0,i=!t&&!a&&!n,o="";return o=n||a?"Some detected licenses are ".concat([n?"weak":null,a?"strong":null].filter(e=>!!e).map(e=>"".concat(e,"-")).join(" and "),"copyleft"):"".concat(i?"All":e[r.LicenseCategory.PERMISSIVE]," detected licenses are permissive"),t&&(o+=", ".concat(i?"but ":"").concat(e[r.LicenseCategory.UNKNOWN]," are unknown.")),{description:o,categoriesPresence:{hasAnyUnknown:t,hasAnyWeakCopyleft:n,hasAnyStrongCopyleft:a,hasAllPermissive:i}}},t.getLicenseCategoryDescription=function(e){switch(e){case r.LicenseCategory.STRONG_COPYLEFT:return"Strong Copyleft";case r.LicenseCategory.WEAK_COPYLEFT:return"Weak Copyleft";case r.LicenseCategory.PERMISSIVE:return"Permissive";case r.LicenseCategory.UNKNOWN:return"Unknown"}};let r=n(93816)},44362:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WEAK_COPYLEFT_LICENSES_LOWERCASE=t.STRONG_COPYLEFT_LICENSES_LOWERCASE=t.WEAK_COPYLEFT_LICENSES=t.STRONG_COPYLEFT_LICENSES=void 0,t.STRONG_COPYLEFT_LICENSES=new Set(["GPL","GPL-1.0","GPL-1.0+","GPL-2.0","GPL-2.0+","GPL-2.0-only","GPL-2.0-or-later","GPL-3.0","GPL-3.0+","GPL-3.0-only","GPL-3.0-or-later","AGPL-3.0","AGPL-3.0-only","AGPL-3.0-or-later","EUPL-1.0","EUPL-1.1","EUPL-1.2","OSL-1.0","OSL-1.1","OSL-2.0","OSL-2.1","OSL-3.0"]),t.WEAK_COPYLEFT_LICENSES=new Set(["CDDL-1.0","CDDL-1.1","EPL-1.0","EPL-2.0","LGPL","LGPL-2.0","LGPL-2.0+","LGPL-2.0-only","LGPL-2.0-or-later","LGPL-2.1","LGPL-2.1+","LGPL-2.1-only","LGPL-2.1-or-later","LGPL-3.0","LGPL-3.0+","LGPL-3.0-only","LGPL-3.0-or-later","MPL-1.1","MPL-2.0"]),t.STRONG_COPYLEFT_LICENSES_LOWERCASE=new Set(Array.from(t.STRONG_COPYLEFT_LICENSES).map(e=>e.toLowerCase())),t.WEAK_COPYLEFT_LICENSES_LOWERCASE=new Set(Array.from(t.WEAK_COPYLEFT_LICENSES).map(e=>e.toLowerCase()))},47095:(e,t,n)=>{"use strict";var r=Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},a=function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(93816),t),a(n(42494),t),a(n(4010),t)},49524:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},52414:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},59560:(e,t,n)=>{"use strict";n.d(t,{n:()=>s});var r=n(64),a=n(21047),i=n(1094),o=n(66435),l=n(93035);function s(e){switch(e){case r.LicenseCategory.STRONG_COPYLEFT:return{main:a.A[500],light:a.A[400],dark:a.A[700]};case r.LicenseCategory.WEAK_COPYLEFT:return{main:i.A[700],light:i.A[600],dark:i.A[800]};case r.LicenseCategory.PERMISSIVE:return{main:o.A[700],light:o.A[600],dark:o.A[800]};case r.LicenseCategory.UNKNOWN:return{main:l.A[400],light:l.A[300],dark:l.A[700]};default:return null}}},64379:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},64979:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},67741:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},72003:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},72195:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},73259:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeRepositoryUrl=function(e){return e.replace("git+ssh://git@","git://").replace(".git","").replace("git+https://github.com","https://github.com").replace(".git","").replace("git://github.com","https://github.com").replace(".git","").replace("git@github.com:","https://github.com/").replace(".git","").replace("github:","https://github.com/").replace(".git","").replace("github.com:","github.com/")}},84391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},85010:(e,t,n)=>{"use strict";var r=Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},a=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},i=function(){var e=function(t){return(e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t})(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i=e(t),o=0;o<i.length;o++)"default"!==i[o]&&r(n,t,i[o]);return a(n,t),n}}();Object.defineProperty(t,"__esModule",{value:!0}),t.YamlUtils=t.RepositoryUtils=void 0,t.RepositoryUtils=i(n(73259)),t.YamlUtils=i(n(7542))},89445:(e,t,n)=>{Promise.resolve().then(n.bind(n,16902))},93816:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LicenseCategory=void 0,function(e){e.STRONG_COPYLEFT="strong copyleft",e.WEAK_COPYLEFT="weak copyleft",e.PERMISSIVE="permissive",e.UNKNOWN="unknown"}(n||(t.LicenseCategory=n={}))}},e=>{e.O(0,[288,129,906,665,847,75,587,18,358],()=>e(e.s=89445)),_N_E=e.O()}]);