@package-broker/ui 2.0.0-rc.4 → 2.0.0-rc.5

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.
Files changed (77) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/api-types.d.ts +848 -22
  3. package/dist/api-types.d.ts.map +1 -1
  4. package/dist/assets/{access.62e9484517a0.js → access.def9a17dc4a8.js} +1 -1
  5. package/dist/assets/app.ec678c27ec0a.css +2 -0
  6. package/dist/assets/{app.c064670cdc0d.js → app.fba0d059b40b.js} +2 -2
  7. package/dist/assets/{audit.b7c40b9dc998.js → audit.453367b59daf.js} +1 -1
  8. package/dist/assets/{chunk.56d473a1587d.js → chunk.2c3648a5bad1.js} +1 -1
  9. package/dist/assets/{chunk.a6d755a9789f.js → chunk.304a2b5d1663.js} +1 -1
  10. package/dist/assets/{chunk.741aec8d1ff9.js → chunk.3f077ff17cea.js} +1 -1
  11. package/dist/assets/{chunk.d18497920e4d.js → chunk.4721d4544d48.js} +1 -1
  12. package/dist/assets/{chunk.6ea6bdcaa465.js → chunk.4acf8fa7653f.js} +1 -1
  13. package/dist/assets/{chunk.28a4d8aab337.js → chunk.53134c7df4e5.js} +1 -1
  14. package/dist/assets/{chunk.965b76812604.js → chunk.56e058d97e0f.js} +1 -1
  15. package/dist/assets/{chunk.3fcd6998795a.js → chunk.75e1357175af.js} +1 -1
  16. package/dist/assets/chunk.837eb41f53ef.js +1 -0
  17. package/dist/assets/{chunk.f54ea1378c8c.js → chunk.ab1a14143dc6.js} +1 -1
  18. package/dist/assets/{chunk.d813fefb410d.js → chunk.dc41ee9219cf.js} +1 -1
  19. package/dist/assets/{chunk.8442124f6802.js → chunk.f0fd799728ef.js} +1 -1
  20. package/dist/assets/chunk.fac952720b72.js +4 -0
  21. package/dist/assets/{import.e7a1e5834631.js → import.4275bbce08ac.js} +1 -1
  22. package/dist/assets/index.html +7 -7
  23. package/dist/assets/manifest.json +30 -30
  24. package/dist/assets/{notifications.19225fe12044.js → notifications.bd7d4c3f9882.js} +1 -1
  25. package/dist/assets/{npm-login.e059678af13d.js → npm-login.d8b60e11fe87.js} +1 -1
  26. package/dist/assets/packages.bdd474bcfc11.js +2 -0
  27. package/dist/assets/{projects.927fe18c785c.js → projects.44006a838c67.js} +1 -1
  28. package/dist/assets/{setup.8e977608d413.js → setup.7bc86366227c.js} +1 -1
  29. package/dist/assets/setup.html +2 -2
  30. package/dist/assets/sources.d95aabfbec73.js +1 -0
  31. package/dist/assets/{tokens.6b86d8d97e07.js → tokens.4ee13a722abb.js} +1 -1
  32. package/dist/auth.d.ts +1 -0
  33. package/dist/auth.d.ts.map +1 -1
  34. package/dist/auth.js +13 -2
  35. package/dist/auth.js.map +1 -1
  36. package/dist/pages/audit.d.ts.map +1 -1
  37. package/dist/pages/packages/discovery-labels.d.ts +8 -0
  38. package/dist/pages/packages/discovery-labels.d.ts.map +1 -0
  39. package/dist/pages/packages/discovery-labels.js +25 -0
  40. package/dist/pages/packages/discovery-labels.js.map +1 -0
  41. package/dist/pages/packages/discovery-picker-view.d.ts +8 -0
  42. package/dist/pages/packages/discovery-picker-view.d.ts.map +1 -0
  43. package/dist/pages/packages/discovery-picker-view.js +109 -0
  44. package/dist/pages/packages/discovery-picker-view.js.map +1 -0
  45. package/dist/pages/packages/discovery-picker.d.ts +67 -0
  46. package/dist/pages/packages/discovery-picker.d.ts.map +1 -0
  47. package/dist/pages/packages/discovery-picker.js +238 -0
  48. package/dist/pages/packages/discovery-picker.js.map +1 -0
  49. package/dist/pages/packages/source-actions.d.ts +3 -1
  50. package/dist/pages/packages/source-actions.d.ts.map +1 -1
  51. package/dist/pages/packages/source-actions.js +19 -9
  52. package/dist/pages/packages/source-actions.js.map +1 -1
  53. package/dist/pages/sources/discovery-rule-prefill.d.ts +13 -0
  54. package/dist/pages/sources/discovery-rule-prefill.d.ts.map +1 -0
  55. package/dist/pages/sources/discovery-rule-prefill.js +9 -0
  56. package/dist/pages/sources/discovery-rule-prefill.js.map +1 -0
  57. package/dist/pages/sources/discovery-rules-view.d.ts +9 -0
  58. package/dist/pages/sources/discovery-rules-view.d.ts.map +1 -0
  59. package/dist/pages/sources/discovery-rules-view.js +144 -0
  60. package/dist/pages/sources/discovery-rules-view.js.map +1 -0
  61. package/dist/pages/sources/discovery-rules.d.ts +57 -0
  62. package/dist/pages/sources/discovery-rules.d.ts.map +1 -0
  63. package/dist/pages/sources/discovery-rules.js +383 -0
  64. package/dist/pages/sources/discovery-rules.js.map +1 -0
  65. package/dist/pages/sources.d.ts.map +1 -1
  66. package/dist/pages/sources.js +4 -1
  67. package/dist/pages/sources.js.map +1 -1
  68. package/dist/pending.d.ts +6 -1
  69. package/dist/pending.d.ts.map +1 -1
  70. package/dist/pending.js +1 -1
  71. package/dist/pending.js.map +1 -1
  72. package/package.json +3 -3
  73. package/dist/assets/app.45b156168495.css +0 -2
  74. package/dist/assets/chunk.51497edc7697.js +0 -4
  75. package/dist/assets/chunk.fd375c54b526.js +0 -1
  76. package/dist/assets/packages.ab5ab25b1c75.js +0 -2
  77. package/dist/assets/sources.ae50f239f80f.js +0 -1
@@ -0,0 +1,4 @@
1
+ import{a as Je}from"./chunk.675b635d9462.js";import{e as Se}from"./chunk.4acf8fa7653f.js";import{b as nt}from"./chunk.53134c7df4e5.js";import{a as we,b as rt}from"./chunk.2c3648a5bad1.js";import{b as tt}from"./chunk.f0fd799728ef.js";import{a as ke}from"./chunk.304a2b5d1663.js";import{a as et,b as je,c as ae}from"./chunk.56e058d97e0f.js";import{a as ge}from"./chunk.dc41ee9219cf.js";import{a as Q}from"./chunk.3f077ff17cea.js";import{A as le,B as X,C as J,D as te,E as $,F as L,K as Ze,c as U,d as De,g as ee,j as Qe,p as N,q as Ae,r as Ie,s as Le,t as Te,x as Y,y as W,z as re}from"./chunk.837eb41f53ef.js";var A=U(De(),1);function at(t){return`${t.sourceNames.join(", ")}${t.sourceCount>t.sourceNames.length?` and ${t.sourceCount-t.sourceNames.length} more sources`:""} \xB7 Installation ${t.installationId}`}var it="Use * for any name or ? for one character. The default * includes all names.",ot="Enter a repository name pattern of 1 to 100 letters, numbers, dots, underscores, hyphens, * or ?.";function st(t){return/^[A-Za-z0-9._*?-]{1,100}$/.test(t||"*")}var Dt={fork:"Fork \u2014 Enable Include forks to consider this repository.",archived:"Archived \u2014 Archived repositories are not imported.",no_manifest:"No package manifest \u2014 Add a manifest for this ecosystem before importing.",invalid_name:"Invalid package name \u2014 Correct the manifest name before importing.",name_public:"Public package name \u2014 Choose a private name before importing.",name_public_unverified:"Name could not be verified \u2014 Try again when the public registry is available.",claim_overlap:"Name claimed by another source \u2014 Resolve the source conflict before importing.",filtered_out:"Outside the name pattern \u2014 Change the pattern to include this repository.",error_451:"Repository legally unavailable (451) \u2014 This repository cannot be imported.",error_404:"Repository unavailable (404) \u2014 Check the connection has access before trying again.",unsupported_ecosystem:"Unsupported ecosystem \u2014 This repository has no Composer or npm package to import."};function lt(t){return Dt[t??""]??"Import refused \u2014 Review the repository settings before trying again."}var me=new WeakMap;function Qt(t,e){me.set(t,{id:null,revision:null,options:{name:"",enabled:!0,intervalSeconds:86400,...e}})}function fe(t){return t.status===412?"This rule changed while you were editing. The newer rule is shown. Review the latest settings before saving.":t.status===404?"This discovery rule is no longer available. Reload the rules.":t.code==="duplicate"?"A discovery rule with this name already exists. Choose another name.":t.code==="reauth_required"?"Sign in again, then confirm the discovery rule settings.":t.status===429?"GitHub is rate limiting requests. Try again later.":t.status===409&&t.code==="discovery_rule_disabled"?"Enable this rule before requesting a scan.":t.status===409?"The rule conflicts with its current state. Reload and try again.":t.status===403?"You do not have permission to change discovery rules.":"Discovery rules could not be updated. Check the settings and try again."}function qe(t,e=0){return t!=="disabled"&&t!=="discovery_failed"?`Finished with ${e} failed repositories`:t==="disabled"?"The rule was disabled before the scan finished.":"The scan could not finish. Check the GitHub connection and try again."}function ct(t){return t.enabled?"outcome"in t?t.outcome==="running"?"Running":t.outcome==="rate_limited"?"Waiting for GitHub rate limit":t.outcome==="failed"?qe(t.failureReason,t.failed):"Waiting for the next scheduled scan":"Current run information is available to source managers.":"Disabled"}function dt(t){if(t%86400===0)return t===86400?"Every day":`Every ${t/86400} days`;if(t%3600===0)return t===3600?"Every hour":`Every ${t/3600} hours`;let e=Math.floor(t/3600),r=Math.floor(t%3600/60);return`Every ${e?`${e} ${e===1?"hour":"hours"} and `:""}${r} ${r===1?"minute":"minutes"}`}function ut(t){let e=me.get(t),r={visible:!1,manager:!1,loading:!0,busy:!1,reauthPending:e?.reauthPending??!1,items:[],next:null,connections:[],connectionsError:!1,draft:e?.options??null,editing:e?.id??null,revision:e?.revision??null,stale:!1,error:null,notice:null,patternError:null},s=0,o=new Set,p=n=>{r={...r,...n},o.forEach(d=>d())},l=()=>{r.draft?me.set(t,{options:r.draft,id:r.editing,revision:r.revision,reauthPending:r.reauthPending}):me.delete(t)};async function m(n=!1,d=!0){if(r.busy||n&&!r.next)return;let C=++s;p({loading:!0,error:null,...d?{notice:"Loading discovery rules\u2026"}:{}});let S=await t.client.request("get","/_pb/me/permissions");if(C!==s)return;let k=S.ok&&S.data.organization.includes("org:sources:write"),E=k||S.ok&&S.data.organization.includes("org:sources:read");if(p({manager:k,visible:E}),!E){p({loading:!1,items:[],draft:null,error:S.ok?null:"Discovery rule permissions could not be loaded. Try again."});return}let[T,V]=await Promise.all([t.client.request("get","/_pb/sources/discovery/rules",n?{query:{after:r.next}}:{}),k?t.client.request("get","/_pb/sources/discovery/connections"):null]);C===s&&p({loading:!1,...d?{notice:null}:{},connections:V?.ok?V.data.items:[],connectionsError:k&&!V?.ok,...T.ok?{items:n?[...new Map([...r.items,...T.data.items].map(z=>[z.id,z])).values()]:T.data.items,next:T.data.next}:{error:"Discovery rules could not be loaded. Try again."}})}async function w(n,d,C="The scan restarts."){if(p({error:fe(n)}),n.code==="reauth_required"&&(p({reauthPending:!0}),l(),t.requireReauth(n.request,{credential:!1,secretFields:[],display:{label:`Change discovery rule ${d?.name??r.draft?.name??"New rule"}`,effect:C,scope:"Organization sources"}})),n.status===412&&d){p({stale:r.editing===d.id&&r.draft!==null});let S=s,k=await t.client.request("get","/_pb/sources/discovery/rules/{id}",{params:{id:d.id}});if(S!==s)return;k.ok?p({items:r.items.some(E=>E.id===d.id)?r.items.map(E=>E.id===d.id?k.data:E):[...r.items,k.data]}):p({error:fe(k)})}}async function y(n,d,C,S="The scan restarts."){if(!r.manager||r.busy||r.reauthPending||r.loading||r.stale)return;p({busy:!0,error:null,notice:null});let k=await n();return k.ok||await w(k,C,S),p({busy:!1}),k.ok&&(await m(!1,!1),p({notice:d})),!k.ok&&k.status===404&&(await m(!1,!1),p({error:fe(k)})),k.ok}let b=(n,d)=>{if(!r.manager||r.busy||r.reauthPending||r.loading||r.draft)return;let C=r.connections[0],S=n?{name:n.name,pattern:n.pattern,ecosystem:n.ecosystem,includeForks:n.includeForks,enabled:n.enabled,intervalSeconds:n.intervalSeconds,credentialId:"credentialId"in n?n.credentialId:"",installationId:"installationId"in n?n.installationId:0}:{name:"",credentialId:C?.credentialId??"",installationId:C?.installationId??0,ecosystem:"both",pattern:"*",includeForks:!1,intervalSeconds:86400,enabled:!0,...d};p({draft:S,editing:n?.id??null,revision:n?.revision??null,stale:!1,error:null,patternError:null}),l()};return{snapshot:()=>r,subscribe(n){return o.add(n),()=>{o.delete(n)}},load:m,dispose(){s++},edit:b,configure(n){r.busy||r.reauthPending||!r.draft||(p({draft:{...r.draft,...n},patternError:null}),l())},close(){r.busy||r.reauthPending||(p({draft:null,editing:null,stale:!1,error:null}),l())},reviewLatest(){let n=r.items.find(d=>d.id===r.editing);n?(p({draft:null}),b(n)):p({stale:!1})},async save(){if(!r.manager||!r.draft||r.stale||r.busy||r.reauthPending)return;let n={...r.draft,name:r.draft.name.trim(),pattern:r.draft.pattern||"*"};if(!st(n.pattern)){p({patternError:ot});return}let d=r.items.find(E=>E.id===r.editing),C=d&&"credentialId"in d&&d.credentialId===n.credentialId&&d.installationId===n.installationId;if(!Number.isInteger(n.intervalSeconds/3600)||n.intervalSeconds<3600||n.intervalSeconds>2592e3){p({error:"Enter a whole number of hours from 1 to 720."});return}if(!n.name||n.name.length>80||!C&&!r.connections.some(E=>E.credentialId===n.credentialId&&E.installationId===n.installationId)){p({error:"Enter a name of up to 80 characters and choose an available GitHub connection."});return}let S={...n};d&&"credentialId"in d&&d.credentialId===n.credentialId&&d.installationId===n.installationId&&(delete S.credentialId,delete S.installationId),await y(()=>r.editing===null?t.client.request("post","/_pb/sources/discovery/rules",{body:n,idempotencyKey:crypto.randomUUID()}):t.client.request("patch","/_pb/sources/discovery/rules/{id}",{params:{id:r.editing},headers:{"If-Match":Se(r.revision)},body:S}),"Discovery rule saved.",d??(r.editing?{id:r.editing,name:n.name}:void 0),!d||!C||d.ecosystem!==n.ecosystem||d.pattern!==n.pattern||d.includeForks!==n.includeForks?"The scan restarts. Imported sources stay.":"Save the settings. The scan keeps its progress.")&&(p({draft:null,editing:null}),l())},run:n=>n.enabled?y(()=>t.client.request("post","/_pb/sources/discovery/rules/{id}/run",{params:{id:n.id},body:{},idempotencyKey:crypto.randomUUID()}),"Scan requested. It will start on a scheduler tick when GitHub is available.",n,"Request a scan on the next scheduler tick."):Promise.resolve(!1),toggle:n=>y(()=>t.client.request("patch","/_pb/sources/discovery/rules/{id}",{params:{id:n.id},headers:{"If-Match":Se(n.revision)},body:{enabled:!n.enabled}}),"Discovery rule updated.",n,n.enabled?"Scheduled scans stop.":"Scheduled scans resume."),remove:async n=>{let d=r.items.find(C=>C.id===n.id);return d?y(()=>t.client.request("delete","/_pb/sources/discovery/rules/{id}",{params:{id:d.id},headers:{"If-Match":Se(d.revision)}}),"Discovery rule deleted. Imported sources stay.",d,"Scheduled scans stop. Imported sources stay."):(await m(!1,!1),p({error:fe({status:404})}),!1)},async replayed(n){if(p({reauthPending:!1}),l(),!n.ok&&n.cancelled){p({error:null,notice:"Discovery rule was not sent. Review the settings before trying again."});return}n.ok&&(p({draft:null,editing:null}),l());let d=m(!1,!1),C=s;if(await d,C===s&&(n.ok&&p({notice:"Discovery rule saved."}),!n.ok&&(p({error:fe(n),stale:n.status===412&&r.draft!==null}),n.status===412&&r.editing))){let S=s,k=r.editing,E=await t.client.request("get","/_pb/sources/discovery/rules/{id}",{params:{id:r.editing}});if(S!==s||k!==r.editing)return;E.ok&&p({items:r.items.some(T=>T.id===r.editing)?r.items.map(T=>T.id===r.editing?E.data:T):[...r.items,E.data]})}}}}var c=U(ee(),1);function pt({value:t}){if(!t)return(0,c.jsx)(c.Fragment,{children:"Not yet"});let e=new Date(t);return Number.isNaN(e.valueOf())?(0,c.jsx)(c.Fragment,{children:"Time unavailable"}):(0,c.jsxs)("time",{dateTime:t,children:[e.toLocaleString()," (",Intl.DateTimeFormat().resolvedOptions().timeZone,")"]})}function At({rule:t}){let e=t.completed;return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("h4",{className:"font-semibold",children:"Last completed run"}),e?.lastRunAt?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("p",{children:(0,c.jsx)(pt,{value:e.lastRunAt})}),(0,c.jsxs)("p",{children:[e.created," created \xB7 ",e.existing," existing \xB7 ",e.skipped," ","skipped \xB7 ",e.failed," failed"]}),(0,c.jsxs)("details",{children:[(0,c.jsx)("summary",{className:"min-h-11 cursor-pointer",children:"Last-run details"}),e.outcome==="failed"?(0,c.jsx)("p",{children:qe(e.failureReason,e.failed)}):null,e.skips.length?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("h4",{className:"font-semibold",children:"Skipped repositories"}),(0,c.jsx)("ul",{children:e.skips.map((r,s)=>(0,c.jsxs)("li",{className:"break-words",children:[r.repository,": ",lt(r.reason)]},s))}),(0,c.jsx)("p",{children:"Up to 50 skipped repositories are retained."})]}):(0,c.jsx)("p",{children:"No retained skip details."}),e.failed>0?(0,c.jsx)("p",{children:"Repository failure details are not retained for completed runs. Check the connection and run the rule again."}):null]})]}):(0,c.jsx)("p",{children:"No completed run yet."})]})}function It({model:t}){let e=(0,A.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),r=e.draft,s=e.items.find(b=>b.id===e.editing),o=s&&(s.ecosystem!==r.ecosystem||s.pattern!==r.pattern||s.includeForks!==r.includeForks||"credentialId"in s&&(s.credentialId!==r.credentialId||s.installationId!==r.installationId)),p=(0,A.useRef)(null),l=(0,A.useRef)(null);(0,A.useEffect)(()=>{l.current?.focus()},[]),(0,A.useEffect)(()=>{e.patternError&&p.current?.focus()},[e.patternError]);let m=s&&"credentialId"in s&&s.credentialId===r.credentialId&&s.installationId===r.installationId,w=e.busy||e.reauthPending,y=e.connections.findIndex(b=>b.credentialId===r.credentialId&&b.installationId===r.installationId);return(0,c.jsxs)("form",{className:"grid max-w-5xl items-start gap-x-6 gap-y-4 rounded border p-4 lg:grid-cols-2","aria-label":e.editing?"Edit discovery rule":"New discovery rule","aria-busy":w,onSubmit:b=>{b.preventDefault(),t.save()},children:[(0,c.jsxs)("p",{className:"lg:col-span-2",children:[e.editing?"Edit discovery rule":"New discovery rule"," \xB7 Organization sources. Matching repositories become shared sources. Projects attach these sources to use their packages."]}),(0,c.jsxs)("div",{children:[(0,c.jsx)(L,{htmlFor:"rule-name",children:"Name (required)"}),(0,c.jsx)($,{id:"rule-name",ref:l,className:"min-h-11",required:!0,maxLength:80,value:r.name,disabled:w,onChange:b=>t.configure({name:b.target.value})})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)(L,{htmlFor:"rule-connection",children:"GitHub connection (required)"}),(0,c.jsxs)(Q,{id:"rule-connection",className:"min-h-11 max-w-full",disabled:w||!e.connections.length,value:y<0?"":String(y),onChange:b=>{let n=e.connections[Number(b.target.value)];n&&t.configure({credentialId:n.credentialId,installationId:n.installationId})},children:[(0,c.jsx)("option",{value:"",disabled:!0,children:m?"Current connection (no longer used by any source)":"Choose a connection"}),e.connections.map((b,n)=>(0,c.jsx)("option",{value:String(n),children:at(b)},n))]}),y<0&&!m?(0,c.jsx)("p",{children:"The saved connection is unavailable. Choose an available GitHub connection."}):null]}),(0,c.jsxs)("div",{children:[(0,c.jsx)(L,{htmlFor:"rule-ecosystem",children:"Package ecosystem"}),(0,c.jsxs)(Q,{id:"rule-ecosystem",className:"min-h-11",disabled:w,value:r.ecosystem,onChange:b=>t.configure({ecosystem:b.target.value}),children:[(0,c.jsx)("option",{value:"npm",children:"npm"}),(0,c.jsx)("option",{value:"composer",children:"Composer"}),(0,c.jsx)("option",{value:"both",children:"Composer and npm"})]})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)(L,{htmlFor:"rule-pattern",children:"Repository name pattern (optional)"}),(0,c.jsx)($,{id:"rule-pattern",ref:p,className:"min-h-11",maxLength:100,value:r.pattern,disabled:w,"aria-invalid":!!e.patternError,"aria-describedby":`rule-pattern-help${e.patternError?" rule-pattern-error":""}`,onChange:b=>t.configure({pattern:b.target.value})}),(0,c.jsx)("p",{id:"rule-pattern-help",children:it}),e.patternError?(0,c.jsx)("p",{id:"rule-pattern-error",role:"alert",children:e.patternError}):null]}),(0,c.jsxs)("div",{children:[(0,c.jsx)(L,{htmlFor:"rule-interval",children:"Scan interval in hours (required)"}),(0,c.jsx)($,{id:"rule-interval",className:"min-h-11",type:"number",required:!0,min:1,max:720,step:1,value:(r.intervalSeconds??86400)/3600,disabled:w,"aria-describedby":"rule-interval-help",onChange:b=>t.configure({intervalSeconds:Math.round(Number(b.target.value)*3600)})}),(0,c.jsx)("p",{id:"rule-interval-help",children:"From one hour to 30 days. GitHub limits may delay a scan."})]}),(0,c.jsxs)("fieldset",{children:[(0,c.jsx)("legend",{children:"Scan settings"}),(0,c.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,c.jsx)("input",{type:"checkbox",checked:r.includeForks??!1,disabled:w,onChange:b=>t.configure({includeForks:b.target.checked})}),"Include forks"]}),(0,c.jsxs)("label",{className:"flex min-h-11 items-center gap-2",children:[(0,c.jsx)("input",{type:"checkbox",checked:r.enabled??!0,disabled:w,onChange:b=>t.configure({enabled:b.target.checked})}),"Enabled"]})]}),o?(0,c.jsx)("p",{className:"lg:col-span-2",children:"Changing the connection, ecosystem, pattern or forks restarts the scan. Imported sources stay."}):null,e.stale?(0,c.jsxs)("div",{className:"lg:col-span-2",children:[(0,c.jsx)("p",{children:"Your draft is retained above. The newer rule is shown in the list below."}),(0,c.jsx)(N,{type:"button",className:"min-h-11",onClick:()=>t.reviewLatest(),children:"Use latest settings and review"})]}):null,(0,c.jsxs)("div",{className:"flex flex-wrap gap-2 lg:col-span-2",children:[(0,c.jsx)(N,{type:"submit",className:"min-h-11 w-full sm:w-auto",disabled:w||e.loading||e.stale||y<0&&!m,children:e.busy?"Saving rule\u2026":"Save rule"}),(0,c.jsx)(N,{type:"button",variant:"outline",className:"min-h-11 w-full sm:w-auto",disabled:w,onClick:()=>t.close(),children:"Cancel"})]})]})}function gt({services:t}){let e=(0,A.useMemo)(()=>ut(t),[t]);return(0,A.useEffect)(()=>{e.load().then(()=>{new URLSearchParams(window.location.hash.split("?")[1]).get("discovery")==="new"&&!e.snapshot().draft&&e.edit()});let r=t.subscribeReplay?.(s=>{s.path.startsWith("/_pb/sources/discovery/rules")&&e.replayed(s)});return()=>{r?.(),e.dispose()}},[e,t]),(0,c.jsx)(Lt,{model:e})}function Lt({model:t}){let e=(0,A.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),[r,s]=(0,A.useState)(null),o=(0,A.useRef)(null),p=(0,A.useRef)(null),l=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{e.notice&&!e.loading&&!e.draft&&p.current?.focus()},[e.notice,e.loading,e.draft]),(0,A.useEffect)(()=>{r||!l.current||(l.current=!1,o.current?.focus())},[r]),!e.visible&&!e.loading&&!e.error?null:(0,c.jsxs)("section",{"aria-labelledby":"discovery-rules-heading",className:"mt-8 grid min-w-0 gap-4",children:[(0,c.jsx)("h2",{ref:o,tabIndex:-1,id:"discovery-rules-heading",className:"text-lg font-semibold",children:"Discovery rules"}),(0,c.jsx)("p",{children:"Organization rules keep matching GitHub repositories available as shared sources. Existing sources are counted, never duplicated. Deleting a rule leaves imported sources in place."}),(0,c.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,c.jsx)(N,{className:"min-h-11",variant:"outline",disabled:e.loading||e.busy,onClick:()=>{t.load()},children:"Reload rules"}),e.manager?(0,c.jsx)(N,{className:"min-h-11",disabled:e.loading||e.busy||!!e.draft,onClick:()=>t.edit(),children:"Create discovery rule"}):null]}),(0,c.jsx)("p",{role:"status","aria-live":"polite",ref:p,tabIndex:-1,children:e.notice}),e.error&&!r?(0,c.jsx)("p",{role:"alert",children:e.error}):null,e.connectionsError?(0,c.jsx)("p",{children:"GitHub connections could not be loaded. Reload rules to try again."}):e.manager&&!e.loading&&!e.connections.length?(0,c.jsxs)("p",{children:["No GitHub App connections yet. Add an organization GitHub source with GitHub App authentication first."," ",(0,c.jsx)("a",{className:"underline",href:"#/sources?create=vcs&provider=github",children:"Add a GitHub source"})]}):null,e.draft&&e.manager?(0,c.jsx)(It,{model:t}):null,!e.loading&&!e.items.length&&!e.error?(0,c.jsx)("p",{children:"No discovery rules yet."}):null,(0,c.jsx)("ul",{className:"grid min-w-0 gap-4",children:e.items.map(m=>(0,c.jsxs)("li",{className:"min-w-0 space-y-2 rounded border p-4",children:[(0,c.jsx)("h3",{className:"break-words font-semibold",children:m.name}),(0,c.jsxs)("dl",{className:"grid gap-2 sm:grid-cols-2",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"Ecosystem"}),(0,c.jsx)("dd",{children:m.ecosystem==="both"?"Composer and npm":m.ecosystem==="composer"?"Composer":"npm"})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"Repository pattern"}),(0,c.jsx)("dd",{className:"break-words",children:m.pattern})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"Forks"}),(0,c.jsx)("dd",{children:m.includeForks?"Included":"Excluded"})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"Schedule"}),(0,c.jsx)("dd",{children:dt(m.intervalSeconds)})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"Enabled"}),(0,c.jsx)("dd",{children:m.enabled?"Enabled":"Disabled"})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("dt",{children:"State"}),(0,c.jsxs)("dd",{children:[m.enabled?ct(m):"Scheduled scans stopped","outcome"in m&&m.outcome==="rate_limited"?(0,c.jsxs)(c.Fragment,{children:[" ","until ",(0,c.jsx)(pt,{value:m.nextRunAt})]}):null]})]})]}),(0,c.jsx)(At,{rule:m}),e.manager&&"created"in m?(0,c.jsxs)("p",{children:["Current run: ",m.created," created \xB7 ",m.existing," existing \xB7 ",m.skipped," ","skipped \xB7 ",m.failed," failed \xB7 ",m.remaining.length," repositories remaining in the current page",m.cursor?"; more pages to scan":"","."]}):null,e.manager?(0,c.jsx)(we,{entityLabel:m.name,actions:[{id:"run",label:"Run now",disabled:e.busy||e.reauthPending||e.loading||e.stale||!m.enabled,onSelect:()=>{t.run(m)}}],overflow:[{id:"edit",label:"Edit",disabled:e.busy||e.reauthPending||e.loading||!!e.draft,onSelect:()=>t.edit(m)},{id:"toggle",label:m.enabled?"Disable":"Enable",disabled:e.busy||e.reauthPending||e.loading||e.stale,onSelect:()=>{t.toggle(m)}},{id:"delete",label:"Delete",variant:"destructive",disabled:e.busy||e.reauthPending||e.loading||e.stale,onSelect:()=>s(m)}]}):null,e.manager&&!m.enabled?(0,c.jsx)("p",{children:"Enable this rule before requesting a scan."}):null]},m.id))}),e.next?(0,c.jsx)(N,{className:"min-h-11",disabled:e.loading||e.busy,onClick:()=>{t.load(!0)},children:"Load more rules"}):null,(0,c.jsx)(Y,{open:r!==null,onOpenChange:m=>{!m&&!e.busy&&s(null)},children:(0,c.jsxs)(W,{children:[(0,c.jsx)(X,{children:"Delete discovery rule"}),(0,c.jsxs)(J,{children:["Remove the rule ",r?.name," in this organization? Scheduled scans stop. Imported sources stay. This cannot be undone."]}),e.error&&r?(0,c.jsx)("p",{role:"alert",children:e.error}):null,(0,c.jsxs)(le,{children:[(0,c.jsx)(N,{className:"min-h-11",variant:"outline",disabled:e.busy,onClick:()=>s(null),children:"Cancel"}),(0,c.jsx)(N,{className:"min-h-11",variant:"destructive",disabled:e.busy,onClick:()=>{r&&t.remove(r).then(m=>{m&&(l.current=!0,s(null))})},children:e.busy?"Deleting rule\u2026":(0,c.jsx)(c.Fragment,{children:"Delete rule"})})]})]})})]})}var Oe="Sync requested. Waiting for a worker. Sync continues in the background.";function Fe(t,e,r){return t===200?`${e} is already available from ${r}.`:`${e}: ${Oe}`}function He(t){return t.status===202?{ok:!0,status:202,data:void 0}:t}var mt="For proxy sources, packages appear when a client first requests them.";function Tt(t,e){return t.sync?.generation!==e.sync?.generation||t.status!==e.status||t.lastPolledAt!==e.lastPolledAt||t.lastSuccessAt!==e.lastSuccessAt||t.lastError!==e.lastError}function Me(t,e){return e.sync&&(e.sync.listing||e.sync.queued+e.sync.running+(e.sync.retrying??0)>0)?"pending":Tt(t,e)}function ft(t,e=typeof document>"u"?void 0:document){let r=Date.now()+6e5,s=!1,o=0,p=!1,l=2e3,m,w=setTimeout(()=>y(),6e5),y=()=>{s=!0,clearTimeout(m),clearTimeout(w),e?.removeEventListener("visibilitychange",b)},b=()=>{e?.hidden&&y()},n=()=>{if(s||e?.hidden||Date.now()>=r||!p&&o>=15){y();return}m=setTimeout(()=>{if(s||e?.hidden||Date.now()>=r){y();return}o++,t().then(d=>{d==="pending"?(o=0,p=!0,l=Math.min(l*2,3e4)):(p=!1,l=2e3),d===!0?y():n()},y)},l)};return e?.addEventListener("visibilitychange",b),n(),y}var q=U(ee(),1);function ht({source:t,busy:e,fieldError:r,alert:s,onSubmit:o,onClose:p}){return(0,q.jsx)(Y,{open:!0,onOpenChange:l=>{!l&&!e&&p()},children:(0,q.jsxs)(W,{onCancel:l=>{e&&l.preventDefault()},children:[(0,q.jsxs)(re,{children:[(0,q.jsx)(X,{children:"Add package"}),(0,q.jsxs)(J,{children:["Request a package from ",t.name," for this project."]})]}),(0,q.jsxs)("form",{className:"grid gap-3",onSubmit:l=>{l.preventDefault(),e||o(new FormData(l.currentTarget).get("name")?.toString()??"")},children:[(0,q.jsx)(L,{htmlFor:"add-package-name",children:"Package name"}),(0,q.jsx)($,{id:"add-package-name",name:"name",required:!0,maxLength:428,placeholder:t.ecosystem==="composer"?"vendor/package":"@scope/package",disabled:e,"aria-invalid":r?!0:void 0,"aria-describedby":r?"add-package-error":void 0}),r?(0,q.jsx)("p",{id:"add-package-error",role:"alert",children:r}):null,s?(0,q.jsx)("p",{role:"alert",children:s}):null,(0,q.jsxs)(le,{children:[(0,q.jsx)(N,{type:"button",variant:"outline",disabled:e,onClick:p,children:"Cancel"}),(0,q.jsx)(N,{type:"submit",disabled:e,children:e?"Requesting\u2026":"Add package"})]})]})]})})}var O=U(De(),1);var B=U(De(),1);var g=U(ee(),1),bt={github:"GitHub",git:"Git over HTTP(S)",ssh:"Git over SSH"},jt=["github"];function qt(t){return Object.keys(bt).filter(e=>t.includes(e)).map(e=>[e,bt[e]])}var yt={composer:["packagist_proxy","composer_repository","vcs"],npm:["npmjs_proxy","npm_registry","hosted","vcs"]},ze={packagist_proxy:"https://repo.packagist.org",npmjs_proxy:"https://registry.npmjs.org"},Z={packagist_proxy:"Packagist proxy",composer_repository:"Composer repository",vcs:"Git repository",npmjs_proxy:"npmjs proxy",npm_registry:"Private npm registry",hosted:"Hosted repository"},Ot={packagist_proxy:"Fetch public Composer packages on demand.",composer_repository:"Import selected packages from Satis, Private Packagist, or another Composer repository.",vcs:"Import a Composer or npm package from the root of a GitHub or Git repository.",npmjs_proxy:"Fetch public npm packages on demand.",npm_registry:"Fetch packages in selected scopes from another npm registry.",hosted:"Reserve private npm package names and publish packages to this broker."},ie={requirePublishApproval:"Require publish approval",name:"Source name",ecosystem:"Ecosystem",type:"Source type",url:"Repository URL",userAgent:"User-Agent override",pollIntervalSeconds:"Sync interval (seconds)",removalPolicy:"When a package disappears upstream",defaultVisibleToNewProjects:"Visible to new projects",retentionDaysOverride:"Archive retention (days)","config/provider":"Repository provider","config/repository":"GitHub repository","config/installationId":"GitHub App installation ID",githubAuthentication:"GitHub authentication","config/packageName":"Package name (optional)","config/refs/branches":"Branches to import","config/refs/tags":"Import tags","config/selection/packages":"Package names (one per line)","config/selection/patterns":"Package patterns (one per line)","config/selection/expandPatterns":"Expand patterns","config/distHosts":"Additional archive hosts","config/mirrorsFallback":"Try repository mirrors if an archive download fails","config/scopes":"Package scopes (one per line)","config/githubToken":"Use GitHub token"},ce={requirePublishApproval:"Choose whether new publishes require approval.",name:"Enter a source name.",ecosystem:"Choose an ecosystem.",type:"Choose a source type.",url:"Enter a valid HTTP or HTTPS URL without credentials, a query, or a fragment.",userAgent:"Enter a valid User-Agent header without line breaks.",pollIntervalSeconds:"Enter a whole number of seconds greater than 0.",removalPolicy:"Choose what happens when a package disappears upstream.",defaultVisibleToNewProjects:"Choose whether this source is visible to new projects.",retentionDaysOverride:"Enter a whole number of days that does not shorten organization retention.","config/provider":"Choose a repository provider this broker supports.","config/repository":"Enter a valid repository for the selected provider: owner/repository for GitHub, or a clone URL for Git.","config/installationId":"Enter a positive whole-number installation ID.",githubAuthentication:"Choose GitHub App or Personal access token.","config/packageName":"Enter a package name matching the source ecosystem.","config/refs/branches":"Enter valid branch names, one per line, without duplicates.","config/refs/tags":"Choose whether to import tags.","config/selection/packages":"Enter valid Composer package names, one per line, without duplicates.","config/selection/patterns":"Enter valid package patterns, such as acme/*, without duplicates.","config/selection/expandPatterns":"Choose whether to expand patterns.","config/distHosts":"Enter hostnames only, one per line, without schemes, paths, or duplicates.","config/mirrorsFallback":"Choose whether to try repository mirrors.","config/scopes":"Enter at least one scope, such as @acme, one per line without duplicates.","config/githubToken":"Save a bearer credential before enabling the GitHub token option."},$e={requirePublishApproval:"New versions wait for approval before installation. Versions already held remain held when this setting is turned off.",pollIntervalSeconds:"How often to check for upstream changes. 300 seconds = 5 minutes.",retentionDaysOverride:"Leave blank to use the organization setting. An override can only lengthen retention.","config/distHosts":"One hostname per line. Archive downloads may come from these hosts; the source credential is also sent to them.","config/selection/packages":"Packages matching either list are selected. Empty lists select no packages.","config/scopes":"One scope per line, including @. Only these scopes use this registry. Register @scope/* for each scope before enabling the source.","config/packageName":"Leave blank to use the root manifest name (composer.json or package.json). For npm, this must match the name in package.json.","config/refs/branches":"One branch name per line. Leave blank to import no branches.","config/installationId":"Enter the numeric installation ID for the account that owns this repository."},Ft={userAgent:"Use broker default",retentionDaysOverride:"Use organization default","config/selection/packages":"acme/payments","config/selection/patterns":"acme/*","config/scopes":"@acme","config/distHosts":"downloads.example.com","config/packageName":"acme/payments","config/refs/branches":"main","config/installationId":"12345678"};function St(t){let e={};for(let r of t){let s=r.path.replace(/^\/body\//,"").replace(/^\//,""),o=Object.keys(ie).find(p=>s===p||s.startsWith(`${p}/`));o&&(e[o]=ce[o]??"Review this setting.")}return e}function Ht(t,e,r,s=null,o=s?Ce(s):null){let p={},l=y=>String(t.get(y)??"").trim(),m=(y,b)=>{let n=Number(l(y));(!l(y)||!Number.isSafeInteger(n)||n<b)&&(p[y]=ce[y]??"Review this setting.")};!r&&!l("name")&&(p.name=ce.name),(e==="composer_repository"||e==="npm_registry")&&(!r||l("url")!==String(o?.get("url")??""))&&!l("url")&&(p.url=ce.url),m("pollIntervalSeconds",1),l("retentionDaysOverride")&&m("retentionDaysOverride",0);let w=!o||Object.keys(ie).some(y=>(y.startsWith("config/")||e==="vcs"&&y==="githubAuthentication")&&String(t.get(y)??"")!==String(o.get(y)??""));return wt(s,t)&&(w||t.has("replaceConfig"))&&(t.has("config/provider")||t.has("config/scopes")||t.has("config/selection/packages")||!r)&&(e==="composer_repository"&&!l("config/selection/packages")&&!l("config/selection/patterns")&&(p["config/selection/packages"]="Add at least one package name or pattern"),e==="npm_registry"&&!l("config/scopes")&&(p["config/scopes"]=ce["config/scopes"]),e==="vcs"&&!l("config/repository")&&(p["config/repository"]=ce["config/repository"]),e==="vcs"&&l("config/provider")==="github"&&l("githubAuthentication")!=="token"&&m("config/installationId",1)),p}function Be(t,e){let r=Number(t);if(!t.trim()||!Number.isSafeInteger(r)||r<e)throw new Error("Enter valid whole numbers for the numeric fields.");return r}function vt(t,e,r,s=!0){let o=w=>String(t.get(w)??""),p=w=>t.has(w),l=w=>o(w).split(/\r?\n/).map(y=>y.trim()).filter(Boolean),m={pollIntervalSeconds:Be(o("pollIntervalSeconds"),1),removalPolicy:o("removalPolicy")};if(e==="hosted"&&(m.requirePublishApproval=p("requirePublishApproval")),m.defaultVisibleToNewProjects=p("defaultVisibleToNewProjects"),m.retentionDaysOverride=o("retentionDaysOverride").trim()===""?null:Be(o("retentionDaysOverride"),0),m.userAgent=o("userAgent")||null,e!=="vcs"&&(m.url=o("url")||null),s&&(!r||t.has("config/provider")||t.has("config/scopes")||t.has("config/selection/packages")||e==="packagist_proxy"||e==="npmjs_proxy"))switch(e){case"vcs":m.config={provider:o("config/provider"),repository:o("config/repository"),...o("config/provider")==="github"&&o("githubAuthentication")!=="token"?{installationId:Be(o("config/installationId"),1)}:{},...o("config/packageName")?{packageName:o("config/packageName")}:{},refs:{branches:l("config/refs/branches"),tags:p("config/refs/tags")}};break;case"composer_repository":m.config={selection:{packages:l("config/selection/packages"),patterns:l("config/selection/patterns"),expandPatterns:p("config/selection/expandPatterns")},distHosts:l("config/distHosts"),mirrorsFallback:p("config/mirrorsFallback")};break;case"npm_registry":m.config={scopes:l("config/scopes"),distHosts:l("config/distHosts")};break;case"packagist_proxy":m.config={githubToken:r&&p("config/githubToken")};break;case"hosted":case"npmjs_proxy":m.config={};break}return m}function wt(t,e){return t===null||t.config!==void 0&&t.configComplete!==!1||e.has("replaceConfig")}function Mt(t,e,r,s,o=s?Ce(s):null){let p=vt(t,r,s!==null,wt(s,t));if(!s)return{name:String(t.get("name")??""),ecosystem:e,type:r,...p};let l=vt(o??Ce(s),r,!0,s.config!==void 0&&s.configComplete!==!1);return Object.fromEntries(Object.entries(p).filter(([m,w])=>JSON.stringify(w)!==JSON.stringify(l[m])))}function xe(t,e){let r=t?.config;for(let s of e.split("/")){if(typeof r!="object"||r===null)return;r=r[s]}return r}function Ce(t){let e=new FormData;for(let r of Object.keys(ie)){let s=r.startsWith("config/")?xe(t,r.slice(7)):t[r];typeof s=="boolean"?s&&e.set(r,"on"):Array.isArray(s)?e.set(r,s.join(`
2
+ `)):s!=null&&e.set(r,String(s))}return(t.type==="packagist_proxy"||t.type==="npmjs_proxy")&&e.set("url",ze[t.type]),e.set("pollIntervalSeconds",String(t.pollIntervalSeconds)),e.set("removalPolicy",t.removalPolicy),e.set("githubAuthentication",t.githubAuthentication??(xe(t,"installationId")?"app":"token")),e}function Ge(t){return[...new Set(t.split(/\r?\n/).map(e=>e.trim()).filter(e=>/^@[a-z0-9][a-z0-9._~-]*$/.test(e)))].map(e=>`${e}/*`)}function kt(t,e){if(!t)return;let r=Array.from(t.elements).find(o=>(o.getAttribute("name")??"")in e);if(!r)return;let s=r.closest("details");s&&(s.open=!0),r.focus()}function xt({source:t,busy:e,errors:r,alert:s,onSubmit:o,onClose:p,vcsProviders:l=jt,initialType:m,initialProvider:w,organization:y=!0}){let[b,n]=(0,B.useState)(t?.ecosystem??(m==="hosted"?"npm":"composer")),[d,C]=(0,B.useState)(t?.type??m??"packagist_proxy"),S=qt(l),k=S[0]?.[0]??"github",[E,T]=(0,B.useState)(xe(t,"provider")??w??k),V=S.some(([h])=>h===E),z=d==="vcs"&&(S.length===0||!V);(0,B.useEffect)(()=>{!t&&!V&&S.length>0&&T(k)},[t,V,S.length,k]);let[H,i]=(0,B.useState)(t?.githubAuthentication??(t?xe(t,"installationId")?"app":"token":"app")),[f,u]=(0,B.useState)(""),v=t?Ce(t):null,x=t!==null&&(t.configComplete===!1||t.config===void 0),[_,I]=(0,B.useState)(!1),[oe,K]=(0,B.useState)({}),G=(0,B.useRef)(null),D={...r,...oe},F=t!==null,R=d==="packagist_proxy"||d==="npmjs_proxy",ye=!z&&(!x||_);(0,B.useEffect)(()=>{kt(G.current,r)},[r]);function se(h){return[$e[h]&&`source-${h}-help`,D[h]&&`source-${h}-error`].filter(Boolean).join(" ")||void 0}function _e(h){return(0,g.jsxs)(g.Fragment,{children:[$e[h]?(0,g.jsx)("p",{id:`source-${h}-help`,className:"text-sm text-neutral-600",children:$e[h]}):null,D[h]?(0,g.jsx)("p",{id:`source-${h}-error`,className:"text-sm text-red-700",children:D[h]}):null]})}function ue(h,P,j=ie[h]){return(0,g.jsxs)("div",{className:"grid gap-1",children:[(0,g.jsx)(L,{htmlFor:`source-${h}`,children:j}),P,_e(h)]},h)}function M(h,P={}){let j={id:`source-${h}`,name:h,required:P.required,defaultValue:P.value??v?.get(h)?.toString(),onChange:h==="config/scopes"?pe=>u(pe.currentTarget.value):void 0,placeholder:P.placeholder??Ft[h],"aria-invalid":!!D[h],"aria-describedby":se(h)};return ue(h,P.multiline?(0,g.jsx)(rt,{...j,rows:3,className:"w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-base sm:text-sm"}):(0,g.jsx)($,{...j,className:"h-11 text-base sm:text-sm",type:P.number?"number":"text",inputMode:P.number?"numeric":void 0,min:P.minimum,max:P.number?Number.MAX_SAFE_INTEGER:void 0,step:P.number?1:void 0,maxLength:h==="url"?2048:void 0}),`${P.label??ie[h]}${P.required?" (required)":""}`)}function ne(h,P=ie[h],j,pe){return(0,g.jsxs)("div",{className:"grid gap-1",children:[(0,g.jsxs)(L,{className:"flex min-h-11 items-center gap-2",htmlFor:`source-${h}`,children:[(0,g.jsx)("input",{type:"checkbox",id:`source-${h}`,name:h,defaultChecked:t?v?.has(h):pe,onChange:j?Re=>j(Re.currentTarget.checked):void 0,"aria-invalid":!!D[h],"aria-describedby":se(h)}),P]}),_e(h)]},h)}function Pe(h,P,j,pe,Re=!1){return(0,g.jsxs)("fieldset",{className:"grid gap-1","aria-describedby":se(h),"aria-invalid":!!D[h],children:[(0,g.jsx)("legend",{className:"text-sm font-medium",children:ie[h]}),(0,g.jsx)("div",{className:Re?"flex gap-4":"grid gap-1",children:j.map(([ve,Rt,Xe])=>(0,g.jsxs)("label",{className:"flex min-h-11 cursor-pointer items-center gap-2 py-1",children:[(0,g.jsx)("input",{type:"radio",name:h,value:ve,checked:P===ve,onChange:()=>pe(ve),"aria-invalid":!!D[h],"aria-describedby":se(h)}),(0,g.jsxs)("span",{children:[(0,g.jsx)("span",{className:"text-sm font-medium",children:Rt}),Xe?(0,g.jsx)("span",{className:"block text-sm text-neutral-600",children:Xe}):null]})]},ve))}),_e(h)]})}let Pt={packagist_proxy:"Packagist",npmjs_proxy:"npmjs",composer_repository:"Acme Composer",npm_registry:"Acme npm",vcs:"Acme payments",hosted:""}[d];return(0,g.jsx)(Y,{open:!0,onOpenChange:h=>{!h&&!e&&p()},children:(0,g.jsxs)(W,{variant:"source",onCancel:h=>{e&&h.preventDefault()},children:[(0,g.jsxs)(re,{className:"shrink-0 p-6 pr-16",children:[(0,g.jsx)(X,{children:F?"Edit source":"Add source"}),(0,g.jsx)(J,{children:F?`${t.name} \xB7 ${b==="composer"?"Composer":"npm"} \xB7 ${Z[d]}. Name, ecosystem and source type cannot be changed.`:"Add an upstream source for this organization or project."})]}),(0,g.jsxs)("form",{noValidate:!0,ref:G,className:"flex min-h-0 min-w-0 flex-1 flex-col",onSubmit:h=>{if(h.preventDefault(),e)return;let P=new FormData(h.currentTarget),j=Ht(P,d,F,t,v);if(K(j),Object.keys(j).length){kt(G.current,j);return}o(Mt(P,b,d,t,v))},onInvalidCapture:h=>{let j=h.target.closest("details");j&&(j.open=!0)},children:[(0,g.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-6",children:[s||Object.keys(D).length?(0,g.jsx)("p",{role:"alert",className:"mb-4 text-sm text-red-700",children:Object.keys(D).length?"Review the highlighted fields.":s}):null,t?(0,g.jsxs)("dl",{className:"detail-list mb-4","aria-label":"Source identity",children:[(0,g.jsx)("dt",{children:"Source ID"}),(0,g.jsx)("dd",{children:(0,g.jsx)(te,{value:t.id,label:"source ID"})}),(0,g.jsx)("dt",{children:"Source URL"}),(0,g.jsx)("dd",{className:"break-all",children:he(t.url)??"No displayable URL"}),(0,g.jsx)("dt",{children:"Credential"}),(0,g.jsx)("dd",{children:t.hasCredential?"credential set \xB7 write-only":"No credential set"}),"attached"in t?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("dt",{children:"Attached to this project"}),(0,g.jsx)("dd",{children:t.attached?"Yes":"No"})]}):null]}):null,(0,g.jsxs)("fieldset",{disabled:e,className:"grid min-w-0 gap-4",children:[F?(0,g.jsx)(g.Fragment,{children:z?(0,g.jsx)("p",{className:"text-sm",children:`Source type: ${Z[d]}. This broker cannot change its repository settings.`}):null}):(0,g.jsxs)(g.Fragment,{children:[Pe("ecosystem",b,[["composer","Composer"],["npm","npm"]],h=>{let P=h;n(P),C(yt[P][0]),u(""),K({})},!0),Pe("type",d,yt[b].filter(h=>(h!=="vcs"||S.length>0)&&(h!=="hosted"||y)).map(h=>[h,Z[h],Ot[h]]),h=>{C(h),u(""),T(k),i("app"),K({})}),M("name",{required:!0,placeholder:Pt})]}),R?(0,g.jsxs)("p",{className:"break-words text-sm",children:["Upstream URL: ",ze[d]]}):null,R?(0,g.jsx)("input",{type:"hidden",name:"url",value:ze[d]}):null,!R&&d!=="vcs"&&d!=="hosted"?(0,g.jsx)("div",{children:M("url",{required:!F||t.url!==null,value:t?.url??"",label:d==="npm_registry"?"Registry URL":"Repository URL",placeholder:d==="npm_registry"?"https://npm.example.com":"https://composer.example.com"})},`network:${d}`):null,x&&!z?(0,g.jsxs)("div",{className:"grid gap-1",children:[(0,g.jsx)("p",{className:"text-sm text-neutral-600",children:"Some saved settings cannot be displayed. Replace the configuration only if you intend to overwrite all saved type-specific settings."}),ne("replaceConfig","Replace type-specific configuration",I)]}):null,ye?(0,g.jsxs)("div",{className:"grid gap-4",children:[d==="vcs"?(0,g.jsxs)(g.Fragment,{children:[ue("config/provider",(0,g.jsx)(Q,{id:"source-config/provider",name:"config/provider",value:E,className:"h-11 text-base sm:text-sm","aria-invalid":!!D["config/provider"],"aria-describedby":se("config/provider"),onChange:h=>T(h.currentTarget.value),children:S.map(([h,P])=>(0,g.jsx)("option",{value:h,children:P},h))})),(0,g.jsxs)("div",{children:[M("config/repository",{required:!0,label:E==="github"?"GitHub repository":E==="git"?"Git repository URL":"SSH repository",placeholder:E==="github"?"acme/payments":E==="git"?"https://git.example.com/acme/payments.git":"git@git.example.com:acme/payments.git"}),E==="github"?(0,g.jsx)("p",{className:"mt-1 text-sm text-neutral-600",children:"Use owner/repository for GitHub, such as acme/payments."}):null]},E),E==="github"?(0,g.jsxs)(g.Fragment,{children:[F?(0,g.jsxs)(g.Fragment,{children:[ue("githubAuthentication",(0,g.jsx)($,{id:"source-githubAuthentication",name:"githubAuthenticationDisplay",className:"h-11 text-base sm:text-sm",value:H==="app"?"GitHub App":"Personal access token",readOnly:!0})),(0,g.jsx)("input",{type:"hidden",name:"githubAuthentication",value:H})]}):Pe("githubAuthentication",H,[["app","GitHub App","Use an app installation with access to this repository."],["token","Personal access token","Add your token after creating the source."]],h=>i(h)),H==="app"?M("config/installationId",{required:!0,number:!0,minimum:1}):null]}):null]}):null,d==="composer_repository"?(0,g.jsxs)(g.Fragment,{children:[M("config/selection/packages",{multiline:!0}),M("config/selection/patterns",{multiline:!0})]}):null,d==="npm_registry"?(0,g.jsxs)(g.Fragment,{children:[M("config/scopes",{multiline:!0}),F?null:ue("registeredPatterns",(0,g.jsx)("textarea",{id:"source-registeredPatterns",name:"registeredPatterns",rows:3,readOnly:!0,value:Ge(f).join(`
3
+ `)}),"Names to register after adding this source")]}):null]},`primary:${d}`):null,d==="hosted"?(0,g.jsx)("p",{className:"text-sm text-neutral-600",children:"npm publishing is available. Register package names, then enable this source. A claim immediately stops the npmjs proxy from serving that name, even while this source is paused. Use an exact lowercase npm name or @scope/*. A scope claim hides public packages in that scope that are not yet cached."}):null,!F&&d!=="hosted"?(0,g.jsx)("p",{className:"text-sm text-neutral-600",children:R?"No credentials are needed to add this proxy.":d==="vcs"&&E==="github"?H==="app"?"After adding this source, save the GitHub App credentials.":"After adding this source, save your GitHub personal access token as a bearer credential.":d==="vcs"&&E==="ssh"?"After adding this source, save an SSH private key and known hosts.":"After adding this source, save its credentials to finish setup."}):null,d==="hosted"&&b==="npm"?ne("requirePublishApproval"):null,(0,g.jsxs)("details",{className:"min-w-0",children:[(0,g.jsx)("summary",{className:"min-h-11 cursor-pointer py-3 text-sm font-medium",children:"Advanced settings"}),(0,g.jsxs)("div",{className:"grid gap-4 pt-2",children:[(0,g.jsx)("p",{className:"text-sm text-neutral-600",children:"Optional sync, visibility, retention, and connection settings."}),ye?(0,g.jsxs)("div",{className:"grid gap-4",children:[d==="composer_repository"||d==="npm_registry"?M("config/distHosts",{multiline:!0}):null,d==="composer_repository"?(0,g.jsxs)(g.Fragment,{children:[ne("config/mirrorsFallback"),F?ne("config/selection/expandPatterns"):null]}):null,d==="vcs"?(0,g.jsxs)(g.Fragment,{children:[M("config/packageName",{placeholder:b==="npm"?"@acme/payments":"acme/payments"}),M("config/refs/branches",{multiline:!0}),ne("config/refs/tags",void 0,void 0,!0)]}):null,d==="packagist_proxy"&&F?ne("config/githubToken"):null]},`advanced:${d}`):null,d==="packagist_proxy"&&F?(0,g.jsx)("p",{className:"text-sm text-neutral-600",children:"To enable Use GitHub token, save a bearer credential with your GitHub token, then select Use GitHub token and save the source."}):null,M("pollIntervalSeconds",{number:!0,minimum:1,value:t?.pollIntervalSeconds??300}),ue("removalPolicy",(0,g.jsxs)(Q,{id:"source-removalPolicy",name:"removalPolicy",className:"h-11 text-base sm:text-sm","aria-invalid":!!D.removalPolicy,"aria-describedby":se("removalPolicy"),defaultValue:t?.removalPolicy??"flag",children:[(0,g.jsx)("option",{value:"flag",children:"Keep available and mark removed"}),(0,g.jsx)("option",{value:"exclude",children:"Exclude from package resolution"})]})),ne("defaultVisibleToNewProjects"),M("retentionDaysOverride",{number:!0,minimum:0}),M("userAgent")]})]})]})]}),(0,g.jsxs)(le,{className:"shrink-0 border-t border-neutral-200 bg-white px-6 pt-4 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[(0,g.jsx)(N,{className:"min-h-11",type:"button",variant:"outline",disabled:e,onClick:p,children:"Cancel"}),(0,g.jsx)(N,{type:"submit",className:"min-h-11",disabled:e,children:F?"Save source":"Add source"})]})]})]})})}var a=U(ee(),1),We={http_basic:["username","password"],bearer:["token"],header:["name","value"],query:["param","value"],github_app:["appId","privateKeyPem","webhookSecret"],npm_token:["token"],ssh_key:["privateKeyPem","knownHosts"]},_t=Object.keys(We);function Ve(t,{scope:e,github:r,vcsProviders:s}){switch(t){case"packagist_proxy":return["bearer"];case"npmjs_proxy":case"hosted":return[];case"composer_repository":return["http_basic","bearer","header","query","npm_token"];case"npm_registry":return["npm_token","http_basic","bearer","header"];case"vcs":return r?e==="organization"?["bearer","github_app"]:["bearer"]:["bearer","http_basic","header","npm_token",...s?.includes("ssh")?["ssh_key"]:[]]}}function Ke(t,e){return{scope:t.projectId===null?"organization":"project",github:t.githubAuthentication!==void 0,vcsProviders:e}}function Ee(t){return["packagist_proxy","npmjs_proxy","npm_registry"].includes(t.type)&&"attached"in t&&t.attached===!0}function $t(t){if(t.type==="composer_repository")return"http_basic";if(t.type==="npm_registry")return"npm_token";if(t.type==="vcs"){let e=t.config;if(e?.provider==="ssh")return"ssh_key";if(e?.provider==="github"&&e.installationId!==void 0)return"github_app"}return"bearer"}function de(t){return["packagist_proxy","npmjs_proxy"].includes(t.type)}var Ne="An organization admin must enable this source.",Ye="Register package names, then enable the source.";function Bt(t,e){let r=t?.config;return t?.type!=="npm_registry"||!Array.isArray(r?.scopes)?[]:Ge(r.scopes.join(`
4
+ `)).filter(s=>!e.includes(s))}function he(t){if(t===null)return null;try{let e=new URL(t);return["https:","http:","ssh:","git:"].includes(e.protocol)?(e.username="",e.password="",e.search="",e.hash="",e.toString()):null}catch{return null}}function zt(t,e,r=()=>new Date().toISOString()){let{client:s}=t,o={ownership:"organization",editor:null,fieldErrors:{},formError:null,available:[],availableNext:null,availableLoading:!1,availableError:!1,items:[],next:null,loading:!0,listError:!1,settingsVersion:0,vcsProviders:void 0,busy:!1,error:null,notice:null,createdSource:null,credentialSource:null,credentialVersion:0,credentialKind:"bearer",credentialKinds:_t,packageSource:null,packageFieldError:null,packageAlert:null,savedCredential:null,names:null,preview:null,order:[],etag:null,canEnableProjectSource:!1,canWriteSources:!1,enableDenied:[],enableConflicts:[]},p=new Set,l=i=>{o={...o,...i};for(let f of p)f()},m,w=()=>{},y=0,b=0,n=0,d=0,C=0;function S(i,f=!1){return i.ok?!1:(i.code==="reauth_required"?(t.requireReauth(f?{method:i.request.method,path:i.request.path}:i.request,{credential:f,secretFields:[]}),l({enableDenied:[],error:f?"Reauthenticate, then enter the credential again.":"Reauthentication is required."})):i.code==="claim_overlap"?l({error:"Another source already claims this package name or scope."}):i.code==="name_public"?l({error:"This name is already available from a public registry."}):i.code==="name_public_unverified"?l({error:"The public registry could not be checked. Try registering the name again later."}):l({error:"The request could not be saved or loaded. Refresh and try again."}),!0)}async function k(i=!1){if(i&&(o.loading||o.next===null))return;let f=++b,u=i?o.next:null,v=o.etag;++C,l({loading:!0,listError:!1,error:null,etag:null,preview:null,order:[],enableDenied:[],enableConflicts:[],notice:null});let x={limit:"100",...u===null?{}:{after:u}},[_,I]=await Promise.all([e!==null||o.ownership!=="organization"?m??=s.request("get","/_pb/me/permissions").then(R=>(R.ok||(m=void 0),R)):null,e===null?s.request("get","/_pb/sources",{query:{...x,...o.ownership==="organization"?{}:{ownership:o.ownership}}}):s.request("get","/_pb/projects/{project}/sources",{params:{project:e},query:x})]);if(f!==b)return;let oe=!I.ok&&I.code==="reauth_required";if(_&&!_.ok&&!oe&&(_.status!==403||_.code==="reauth_required")&&S(_),S(I)||!I.ok){l({loading:!1,listError:!0});return}l({canEnableProjectSource:_?.ok===!0&&_.data.organization.includes("org:sources:write")});let K=Je(I,"etag")??null;if(e!==null&&i&&K!==v){await k();return}let G=I.data.items.map(R=>({...R,url:he(R.url)})),D=i?[...o.items,...G]:G,F=D.flatMap(R=>"attached"in R&&R.attached===!0&&"precedence"in R&&typeof R.precedence=="number"?[{id:R.id,precedence:R.precedence}]:[]);l({items:D,settingsVersion:o.settingsVersion+1,next:I.data.next,vcsProviders:I.data.vcsProviders,loading:!1,etag:K,order:F.sort((R,ye)=>R.precedence-ye.precedence).map(({id:R})=>R)})}async function E(i=!1){if(e===null||i&&(o.availableLoading||o.availableNext===null))return;let f=++n,u=i?o.availableNext:null;l({availableLoading:!0,availableError:!1});let v=await s.request("get","/_pb/sources",{query:{limit:"100",...u===null?{}:{after:u}}});if(f!==n)return;if(!v.ok){l({available:[],availableNext:null,availableLoading:!1,availableError:!0});return}let x=v.data.items.map(_=>({..._,attached:!1,url:he(_.url)}));l({available:i?[...o.available,...x]:x,availableNext:v.data.next,availableLoading:!1})}async function T(i){for(;!o.items.some(f=>f.id===i)&&o.next!==null&&!o.listError;)await k(!0);return o.items.find(f=>f.id===i)}async function V(i,f){let u=await T(i);if(u&&l({createdSource:i,notice:`Next steps for ${u.name}`}),u&&!de(u)&&u.type!=="hosted"){let v=Ve(u.type,Ke(u,o.vcsProviders)),x=f?$t(f):u.githubAuthentication==="app"?"github_app":v[0];l({credentialSource:i,credentialVersion:o.credentialVersion+1,credentialKinds:v,credentialKind:x!==void 0&&v.includes(x)?x:v[0]})}}async function z(i,f=!1){let u=o.names;if(f||l({credentialSource:null,error:null}),f&&(u?.source!==i||u.next===null))return;let v=++d,x=f?u?.next:null,_=await s.request("get","/_pb/sources/{source}/names",{params:{source:i},query:{limit:"100",...x==null?{}:{after:x}}});v!==d||S(_)||!_.ok||l({names:{..._.data,source:i,items:f?[...u.items,..._.data.items]:_.data.items}})}async function H(i,f,u=()=>!1){if(!o.busy){l({busy:!0,error:null,notice:null});try{let v=await i();!u(v)&&!S(v)&&await f()}finally{l({busy:!1})}}}return{project:e,dispose(){++y,w()},snapshot:()=>o,enableNeedsAdmin(i){return i.projectId!==null&&(!o.canEnableProjectSource||o.enableDenied.includes(i.id))},subscribe(i){return p.add(i),()=>{p.delete(i)}},load:k,async setOwnership(i){e!==null||o.busy||(l({ownership:i,items:[],next:null}),await k())},loadAvailable:E,names:z,openEditor(i=null){o.busy||i&&e!==null&&i.projectId===null||l({editor:i??"create",fieldErrors:{},formError:null,error:null,credentialSource:null,savedCredential:null})},closeEditor(){o.busy||l({editor:null,fieldErrors:{},formError:null})},async saveSource(i){if(o.busy||o.editor===null)return;let f=o.editor;if(f!=="create"&&Object.keys(i).length===0){l({editor:null,fieldErrors:{},formError:null});return}l({busy:!0,error:null,formError:null,fieldErrors:{}});try{let u=f==="create"?e===null?await s.request("post","/_pb/sources",{body:i}):await s.request("post","/_pb/projects/{project}/sources",{params:{project:e},body:i}):e===null?await s.request("patch","/_pb/sources/{source}",{params:{source:f.id},headers:{"If-Match":`"r${f.revision}"`},body:i}):await s.request("patch","/_pb/projects/{project}/sources/{source}",{params:{project:e,source:f.id},headers:{"If-Match":`"r${f.revision}"`},body:i});if(!u.ok){S(u),u.status===412&&l({error:"This source changed while you were editing. Reload the latest settings before saving."}),l({fieldErrors:St(u.details),formError:o.error});return}l({editor:null,fieldErrors:{},formError:null,...f==="create"&&e===null&&o.ownership==="project"?{ownership:"organization"}:{}}),await k(),f==="create"&&u.data&&"id"in u.data&&await V(u.data.id,i)}finally{l({busy:!1})}},attachment(i,f){return e===null?Promise.resolve():H(()=>f?s.request("put","/_pb/projects/{project}/sources/{source}/attachment",{params:{project:e,source:i},body:{}}):s.request("delete","/_pb/projects/{project}/sources/{source}/attachment",{params:{project:e,source:i}}),()=>k())},async replayed(i){if(i.path.startsWith("/_pb/sources/discovery/"))return;let f=e===null?"/_pb/sources":`/_pb/projects/${encodeURIComponent(e)}/sources`,u=/^\/_pb\/sources\/[^/]+\/names(?:\/[^/]+)?$/.test(i.path),v=/^\/_pb\/sources\/([^/]+)\/enable$/.exec(i.path);if(i.path!==f&&!i.path.startsWith(`${f}/`)&&!u&&!v)return;let x=o.names?.source;l({enableDenied:[],enableConflicts:[]}),i.ok&&l({editor:null,fieldErrors:{},formError:null,...i.createdSourceId&&e===null&&o.ownership==="project"?{ownership:"organization"}:{}}),await k(),v&&!i.ok&&(i.status===403&&i.code==="forbidden"&&o.items.some(_=>_.id===v[1]&&_.projectId!==null)?l({enableDenied:[v[1]],notice:Ne}):i.status===409&&i.code==="conflict"?l({enableConflicts:[v[1]],notice:Ye}):l({error:"The request could not be saved or loaded. Refresh and try again."})),i.ok&&i.createdSourceId&&await V(i.createdSourceId),x!==void 0&&await z(x)},moveSource(i,f){if(o.loading||o.busy||o.next!==null)return;let u=[...o.order],v=u.indexOf(i),x=v+f;v<0||x<0||x>=u.length||([u[v],u[x]]=[u[x],u[v]],l({order:u}))},async saveOrder(){if(e===null||o.loading||o.busy||o.next!==null||o.etag===null)return;let i=o.etag,f=[...o.order];l({busy:!0,error:null,preview:null}),++C;try{let u=await s.request("put","/_pb/projects/{project}/sources/order",{params:{project:e},headers:{"If-Match":i},body:{sourceIds:f}});!u.ok&&u.status===412?(await k(),l({error:"Source ordering changed. Review the reloaded list before saving again."})):S(u)||await k()}finally{l({busy:!1})}},closeCredential(){o.busy||l({credentialSource:null})},closeNames(){o.busy||(++d,l({names:null}))},chooseCredential(i){if(o.busy)return;let f=o.items.find(v=>v.id===i),u=f?Ve(f.type,Ke(f,o.vcsProviders)):["bearer"];u.length!==0&&(++d,l({credentialSource:i,names:null,savedCredential:null,credentialVersion:o.credentialVersion+1,credentialKind:f?.githubAuthentication==="app"&&u.includes("github_app")?"github_app":u[0],credentialKinds:u,error:null}))},openPackage(i){o.busy||e===null||!Ee(i)||i.status==="paused"||l({packageSource:i,packageFieldError:null,packageAlert:null,notice:null})},closePackage(){o.busy||l({packageSource:null,packageFieldError:null,packageAlert:null})},async addPackage(i){let f=o.packageSource;if(!(o.busy||e===null||!f||!Ee(f))){if(i=i.trim(),!i||i.length>428){l({packageFieldError:"Enter a package name of 1 to 428 characters."});return}l({busy:!0,packageFieldError:null,packageAlert:null,notice:null});try{let u=await s.request("post","/_pb/projects/{project}/sources/{source}/packages",{params:{project:e,source:f.id},body:{name:i}});u.ok?l({packageSource:null,notice:u.status===202?Fe(202,u.data.name,f.name):Fe(200,u.data.name,f.name)}):u.status===400&&u.code==="invalid_request"?l({packageFieldError:"Enter a valid package name for this source."}):u.code==="package_not_found"?l({packageAlert:"Not found upstream. Check the package name or use another source."}):u.status===400?l({packageFieldError:"This source does not support that package. Check the name or use another source."}):u.code==="forbidden"?l({packageAlert:"You do not have permission to add packages to this project."}):u.status===502?l({packageAlert:"The upstream registry refused or failed the request. Check the source credential or try again later."}):u.status===404?l({packageAlert:"The package or attached source could not be found. Check the name and refresh sources."}):u.status===503?l({packageAlert:"Package requests are temporarily unavailable. Try again shortly."}):u.status===409?l({packageAlert:"This source is paused. Enable it before adding a package."}):(S(u),l({packageAlert:o.error,error:null}))}finally{l({busy:!1})}}},async credential(i,f,u){if(!o.busy){l({busy:!0,error:null,credentialSource:i,credentialVersion:o.credentialVersion+1,savedCredential:null});try{let v=e===null?await s.request("put","/_pb/sources/{source}/credential",{params:{source:i},body:{kind:f,material:u}}):await s.request("put","/_pb/projects/{project}/sources/{source}/credential",{params:{project:e,source:i},body:{kind:f,material:u}});S(v,!0)||l({savedCredential:{source:i,at:r()},notice:"Credential set.",items:o.items.map(x=>x.id===i?{...x,hasCredential:!0}:x)})}finally{l({busy:!1})}}},edit(i,f,u){if(!Number.isSafeInteger(f)||f<=0)return l({error:"Polling interval must be a positive whole number."}),Promise.resolve();let v=o.items.find(I=>I.id===i)?.revision;if(v===void 0)return l({error:"Reload sources before saving."}),Promise.resolve();let x={"If-Match":`"r${v}"`},_={pollIntervalSeconds:f,removalPolicy:u};return H(()=>e===null?s.request("patch","/_pb/sources/{source}",{params:{source:i},body:_,headers:x}):s.request("patch","/_pb/projects/{project}/sources/{source}",{params:{project:e,source:i},body:_,headers:x}),()=>k())},async loadMutationPermissions(){let i=e===null?await s.request("get","/_pb/me/permissions"):await s.request("get","/_pb/projects/{project}/permissions",{params:{project:e}});l({canWriteSources:i.ok&&("organization"in i.data?i.data.organization.includes("org:sources:write"):i.data.project.includes("project:sources:write"))})},syncNow(i){if(o.busy||i.status==="paused"||e!==null&&i.projectId===null)return Promise.resolve();w();let f=++y;return H(()=>e===null?s.request("post","/_pb/sources/{source}/sync",{params:{source:i.id}}).then(He):s.request("post","/_pb/projects/{project}/sources/{source}/sync",{params:{project:e,source:i.id}}).then(He),async()=>{if(f!==y)return;let u=async()=>{let x=b,_=o.ownership,I=null;do{let oe={limit:"100",...I===null?{}:{after:I}},K=e===null?await s.request("get","/_pb/sources",{query:{...oe,..._==="organization"?{}:{ownership:_}}}):await s.request("get","/_pb/projects/{project}/sources",{params:{project:e},query:oe});if(f!==y||x!==b||!K.ok)return!0;let G=K.data.items.find(D=>D.id===i.id);if(G)return l({items:o.items.map(D=>D.id===i.id?{...G,url:he(G.url)}:D)}),Me(i,G);I=K.data.next}while(I!==null);return!0},v;if(o.loading&&o.items.length===0){await k();let x=await T(i.id);v=o.listError||!x||Me(i,x)}else v=await u();f===y&&(l({notice:Oe}),v!==!0&&f===y&&(w=ft(u)))})},async togglePause(i){if(e!==null&&i.projectId===null)return;if(i.status==="paused"&&!de(i)){if(o.busy||i.projectId!==null&&(!o.canEnableProjectSource||o.enableDenied.includes(i.id)))return;l({enableConflicts:o.enableConflicts.filter(u=>u!==i.id)}),await H(()=>s.request("post","/_pb/sources/{source}/enable",{params:{source:i.id}}),()=>k(),u=>i.projectId!==null&&!u.ok&&u.status===403&&u.code==="forbidden"?(l({enableDenied:[...new Set([...o.enableDenied,i.id])],notice:Ne}),!0):!u.ok&&u.status===409&&u.code==="conflict"?(l({enableConflicts:[...new Set([...o.enableConflicts,i.id])],notice:Ye}),!0):!1);return}let f=i.status==="paused"?"resume":"pause";return H(()=>e===null?s.request("post",`/_pb/sources/{source}/${f}`,{params:{source:i.id}}):s.request("post",`/_pb/projects/{project}/sources/{source}/${f}`,{params:{project:e,source:i.id}}),()=>k())},addName(i,f){let u=o.items.find(v=>v.id===i)?.ecosystem==="npm"?214:50;return f.length===0||f.length>u||!/^[a-z0-9._~@!/*-]+$/.test(f)?(l({error:`Enter a registered pattern of 1 to ${u} supported characters.`}),Promise.resolve()):H(()=>s.request("post","/_pb/sources/{source}/names",{params:{source:i},body:{pattern:f}}),()=>z(i))},removeName(i,f){return H(()=>s.request("delete","/_pb/sources/{source}/names/{name}",{params:{source:i,name:f}}),async()=>{await z(i),await k()})},async resolve(i){let f=++C;if(l({preview:null,error:null}),e===null||i.length===0||i.length>214){l({error:`Choose a project and enter a package name of 1 to ${214} characters.`});return}let u=await s.request("get","/_pb/projects/{project}/resolve",{params:{project:e},query:{name:i}});f===C&&!S(u)&&u.ok&&l({preview:u.data})}}}function Gt(t,e,r){let s=r.elements.namedItem("kind")?.value,o=_t.includes(s)?We[s]:null,p=o===null?null:JSON.stringify(Object.fromEntries(o.map(l=>[l,r.elements.namedItem(l)?.value??""])));return r.reset(),p===null?Promise.resolve():t.credential(e,s,p)}function Ut({kind:t,busy:e}){return(0,a.jsx)(a.Fragment,{children:We[t].map(r=>(0,a.jsxs)("div",{children:[(0,a.jsx)(L,{htmlFor:`credential-${r}`,children:r}),(0,a.jsx)($,{id:`credential-${r}`,name:r,type:"password",autoComplete:"off",defaultValue:"",maxLength:16384,required:!0,disabled:e})]},r))})}function Vt({model:t,source:e,busy:r,initialKind:s,kinds:o}){let[p,l]=(0,O.useState)(s);return(0,a.jsxs)("form",{className:"grid gap-3",autoComplete:"off",onSubmit:m=>{m.preventDefault(),!r&&Gt(t,e,m.currentTarget)},children:[(0,a.jsx)(L,{htmlFor:"credential-kind",children:"Credential kind"}),(0,a.jsx)(Q,{id:"credential-kind",name:"kind",value:p,disabled:r,onChange:m=>l(m.currentTarget.value),children:o.map(m=>(0,a.jsx)("option",{value:m,children:m},m))}),(0,a.jsx)(Ut,{kind:p,busy:r},p),(0,a.jsx)(N,{type:"submit",className:"w-fit",disabled:r,children:"Save credential"})]})}function Ct(t,e){return new FormData(t).get(e)?.toString()??""}var Ue={network:"Network failure",timeout:"Sync timed out",http_error:"HTTP error",unauthorized:"Authorization failed",rate_limited:"Rate limited",not_found:"Not found",invalid_response:"Invalid response",tag_limit_exceeded:"Tag limit exceeded",mass_absence:"Mass package absence",too_large:"Response too large",policy_denied:"Policy denied",credential_unavailable:"Credential unavailable",internal:"Internal error",name_mismatch:"Package name differs from configuration",version_mismatch:"Manifest version differs from tag",invalid_manifest:"Invalid package manifest",unsupported_files_pattern:"Unsupported package file pattern",invalid_packlist:"Package files could not be packed",invalid_tarball:"Invalid repository archive",archive_changed:"Repository archive changed during packing"};function Kt({source:t}){let e=t.lastError!==null&&Object.hasOwn(Ue,t.lastError)?Ue[t.lastError]:null;return(0,a.jsxs)("div",{className:"grid gap-1 text-sm",children:[(0,a.jsxs)("p",{children:["Last listing: ",(0,a.jsx)(ge,{value:t.lastSuccessAt,fallback:"Never"})]}),(0,a.jsxs)("p",{children:["Last listing error:"," ",t.lastError===null?"None":(0,a.jsxs)(a.Fragment,{children:[e&&`${e} \xB7 `,(0,a.jsx)("code",{children:t.lastError})]})]}),t.sync&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{children:["Latest sync: ",t.sync.queued," queued \xB7 ",t.sync.running," running \xB7"," ",t.sync.retrying," retrying \xB7 ",t.sync.failed," failed \xB7 ",t.sync.completed," ","completed"]}),t.sync.errors.slice(0,3).map(({code:r,count:s})=>(0,a.jsxs)("p",{children:[Ue[r]," \xB7 ",(0,a.jsx)("code",{children:r}),": ",s]},r))]}),de(t)?(0,a.jsx)("p",{children:mt}):null,(0,a.jsxs)("p",{children:["Next poll: ",(0,a.jsx)(ge,{value:t.nextPollAt,fallback:"None"})]})]})}function Yt({source:t,model:e,busy:r}){let[s,o]=(0,O.useState)(null);(0,O.useEffect)(()=>{s&&(s.id!==t.id||s.status!==t.status)&&o(null)},[s,t.id,t.status]);let p=e.project===null?t.projectId===null:t.projectId!==null,l=e.project===null&&t.projectId!==null,m=(p||l)&&t.status==="paused"&&!de(t)&&e.enableNeedsAdmin(t),w=e.snapshot().enableConflicts.includes(t.id),y=`source-actions-note-${t.id}`,b=!p&&!l?"Manage this organization source in organization scope.":[m&&Ne,w&&Ye].filter(Boolean).join(" "),n=p?[{id:"edit",label:"Edit",disabled:r,onSelect:()=>e.openEditor(t)},...e.snapshot().canWriteSources&&t.type!=="hosted"?[{id:"sync",label:"Sync now",disabled:r||t.status==="paused",...t.status==="paused"?{describedBy:`sync-paused-${t.id}`}:{},onSelect:()=>{e.syncNow(t)}}]:[]]:[],d=[];return p||l?(l&&(t.status!=="paused"||de(t))||d.push(t.status==="paused"?{id:"enable",label:"Enable",disabled:r||m,...m||w?{describedBy:y}:{},onSelect:()=>{e.togglePause(t)}}:{id:"pause",label:"Pause source\u2026",disabled:r,onSelect:()=>o(t)}),p&&Ve(t.type,Ke(t,e.snapshot().vcsProviders)).length>0&&d.push({id:"credential",label:t.type==="packagist_proxy"?"Add GitHub token (optional)":"Set credential",disabled:r,onSelect:()=>e.chooseCredential(t.id)})):d.push({id:"manage",label:"Manage source",disabled:!0,describedBy:y,onSelect:()=>{}}),e.project!==null&&e.snapshot().canWriteSources&&Ee(t)&&d.push({id:"add-package",label:"Add package",disabled:r||t.status==="paused",...t.status==="paused"?{describedBy:`add-package-paused-${t.id}`}:{},onSelect:()=>e.openPackage(t)}),d.push({id:"names",label:"Registered names",disabled:r,onSelect:()=>{e.names(t.id)}}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(we,{entityLabel:t.name,actions:n,overflow:d}),p&&t.status==="paused"?(0,a.jsx)("p",{id:`sync-paused-${t.id}`,children:"Enable before syncing."}):null,e.project!==null&&Ee(t)&&t.status==="paused"?(0,a.jsx)("p",{id:`add-package-paused-${t.id}`,children:"Enable before adding a package."}):null,b?(0,a.jsx)("p",{id:y,children:b}):null,(0,a.jsx)(ke,{action:"Pause",target:`${t.name} (${t.id})`,scope:e.project===null?"Organization":`Project: ${e.project}`,description:"Pausing this source stops it from resolving packages in this scope. You can enable it again later.",disabled:r,open:s?.id===t.id&&s.status===t.status&&t.status!=="paused",onOpenChange:C=>{C||o(null)},hideTrigger:!0,onConfirm:()=>{e.togglePause(t)}})]})}function Wt(t,e){return t.filter(r=>r.name.toLowerCase().includes(e.q.toLowerCase())&&(!e.type||r.type===e.type)&&(!e.scope||(e.scope==="organization"?r.projectId===null:r.projectId!==null)))}function Xt({model:t}){let e=(0,O.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),[r,s]=(0,O.useState)({q:"",type:"",scope:""}),o=!!(r.q||r.type||r.scope),p=e.items.find(n=>n.id===e.createdSource),l=(0,O.useMemo)(()=>{let n=e.names;return n===null?[]:Bt(e.items.find(d=>d.id===n.source),n.items.map(d=>d.pattern))},[e.items,e.names]),m=!e.loading&&!e.listError&&e.next===null,w=e.items.find(n=>n.id===e.credentialSource)?.type==="packagist_proxy",y=[...e.items,...m?e.available.filter(n=>!e.items.some(d=>d.id===n.id)):[]],b=Wt(y,r).sort((n,d)=>{let C=S=>{let k=e.order.indexOf(S);return k<0?1/0:k};return C(n.id)-C(d.id)});return(0,a.jsxs)("section",{"aria-labelledby":"page-heading",className:"grid gap-6",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,a.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-xl font-semibold",children:"Sources"}),(0,a.jsx)(N,{type:"button",disabled:e.busy,onClick:()=>t.openEditor(),children:"Add source"})]}),e.editor!==null?(0,a.jsx)(xt,{organization:t.project===null,source:e.editor==="create"?null:e.editor,busy:e.busy,errors:e.fieldErrors,alert:e.formError,onSubmit:n=>{e.editor==="create"&&s({q:"",type:"",scope:""}),t.saveSource(n)},onClose:()=>t.closeEditor(),vcsProviders:e.vcsProviders,initialType:typeof window<"u"&&new URLSearchParams(window.location.hash.split("?")[1]).get("create")==="vcs"?"vcs":void 0,initialProvider:typeof window<"u"&&new URLSearchParams(window.location.hash.split("?")[1]).get("provider")==="github"?"github":void 0}):null,(0,a.jsx)("p",{className:"text-neutral-600",children:"Upstream registries and private repositories. Attached sources are tried in precedence order."}),t.project===null?(0,a.jsxs)(L,{children:["Ownership",(0,a.jsxs)(Q,{value:e.ownership,disabled:e.busy,onChange:n=>{t.setOwnership(n.target.value)},children:[(0,a.jsx)("option",{value:"organization",children:"Organization"}),(0,a.jsx)("option",{value:"project",children:"Project-owned"}),(0,a.jsx)("option",{value:"all",children:"All"})]})]}):null,(0,a.jsx)(nt,{values:{...r,scope:r.scope==="organization"?"Organization":r.scope==="project"?"Project":"",type:Z[r.type]??""},fields:[{key:"q",label:"Name (loaded sources)"},{key:"type",label:"Type",options:[...new Set(y.map(n=>Z[n.type]))].sort()},...t.project===null?[]:[{key:"scope",label:"Source scope",options:["Organization","Project"]}]],onChange:n=>s({q:n.q??"",scope:t.project===null?"":n.scope==="Organization"?"organization":n.scope==="Project"?"project":"",type:Object.keys(Z).find(d=>Z[d]===n.type)??""})}),(0,a.jsx)("p",{role:"status","aria-live":"polite",children:e.notice}),p?.status==="paused"&&!de(p)?(0,a.jsxs)("p",{children:["Next steps for ",p.name,":"," ",t.enableNeedsAdmin(p)?Ne:e.names?.source===p.id&&e.names.items.length>0?"Enable the source.":"Register names, then Enable the source."]}):null,e.error&&!e.listError?(0,a.jsx)(ae,{kind:"error",title:e.error}):null,e.listError?(0,a.jsxs)(ae,{kind:"error",title:"Sources could not be loaded.",children:[e.error?(0,a.jsx)("p",{children:e.error}):null,(0,a.jsx)(N,{type:"button",className:"w-fit",disabled:e.loading||e.busy,onClick:()=>{t.load()},children:"Retry sources"})]}):null,!e.listError&&!e.availableError?(0,a.jsx)(N,{type:"button",className:"w-fit",variant:"outline",disabled:e.loading||e.busy,onClick:()=>{t.load(),t.loadAvailable()},children:"Refresh sources"}):null,t.project!==null&&!m&&e.available.length>0?(0,a.jsx)("p",{className:"text-sm text-neutral-600",children:"Load all project sources before attaching organization sources."}):null,e.availableLoading?(0,a.jsx)(ae,{kind:"loading",title:"Loading organization sources\u2026"}):null,e.availableError?(0,a.jsx)(ae,{kind:"error",title:"Organization sources could not be loaded.",children:(0,a.jsx)(N,{type:"button",className:"w-fit",disabled:e.availableLoading||e.busy,onClick:()=>{t.loadAvailable()},children:"Retry organization sources"})}):null,e.loading?(0,a.jsx)(ae,{kind:"loading",title:"Loading sources\u2026"}):!e.listError&&b.length===0?(0,a.jsx)(ae,{kind:o?"filtered-empty":"empty",title:o?"No sources match these filters.":"No sources."}):null,!e.loading&&!e.listError&&b.length?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"text-sm text-neutral-600",children:[b.length," sources loaded",o?" matching filters":""]}),(0,a.jsx)(et,{label:"Sources in precedence order",items:b,columns:[{key:"name",label:"Source",value:n=>n.name,render:n=>(0,a.jsxs)("div",{className:"grid gap-1",children:[(0,a.jsx)("strong",{children:n.name}),"projectName"in n&&n.projectName!==null?(0,a.jsx)("span",{children:`Project: ${n.projectName}`}):null,(0,a.jsxs)("span",{className:"text-xs text-neutral-600",children:[n.ecosystem==="composer"?"Composer":"npm"," \xB7"," ",Z[n.type]]}),(0,a.jsx)(tt,{status:n.status})]})},{key:"precedence",label:"Precedence",value:n=>e.order.indexOf(n.id)<0?"\u2014":e.order.indexOf(n.id)+1,render:n=>{let d=e.order.indexOf(n.id);return d<0?"\u2014":(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,a.jsx)("strong",{children:d+1}),(0,a.jsx)(N,{type:"button",size:"sm",variant:"ghost","aria-label":`Move up ${n.name}`,disabled:e.busy||e.next!==null||d===0,onClick:()=>t.moveSource(n.id,-1),children:"Move up"}),(0,a.jsx)(N,{type:"button",size:"sm",variant:"ghost","aria-label":`Move down ${n.name}`,disabled:e.busy||e.next!==null||d===e.order.length-1,onClick:()=>t.moveSource(n.id,1),children:"Move down"})]})}},{key:"scope",label:"Attached to",value:n=>n.projectId===null?"Organization source":"Project source",render:n=>(0,a.jsxs)("div",{className:"grid gap-1",children:[(0,a.jsx)("span",{children:n.projectId===null?"Organization source":"Project source"}),t.project===null&&"attachedProjectCount"in n?(0,a.jsx)(je,{variant:"secondary",children:`Attached to ${n.attachedProjectCount} projects`}):null,"attached"in n?(0,a.jsx)("span",{className:"text-xs text-neutral-600",children:n.attached?"Attached to this project":"Not attached to this project"}):null]})},{key:"credential",label:"Credentials",value:n=>n.hasCredential?"Set \xB7 write-only":"None",render:n=>n.hasCredential?(0,a.jsx)(je,{variant:"outline",children:"Set \xB7 write-only"}):"None"},{key:"sync",label:"Sync status",value:n=>n.lastSuccessAt??"",render:n=>(0,a.jsx)(Kt,{source:n})},{key:"id",label:"Source ID",value:n=>n.id,priority:3,render:n=>(0,a.jsx)(te,{value:n.id,label:"source ID"})},{key:"actions",label:"Actions",value:()=>"",sortable:!1,render:n=>(0,a.jsxs)("div",{className:"flex flex-wrap items-start gap-2",children:[t.project!==null&&"attached"in n?n.attached?(0,a.jsx)(ke,{action:"Detach",target:`${n.name} (${n.id})`,scope:`Project: ${t.project}`,description:"Detaching this source stops this project from resolving packages through it. You can attach it again later.",disabled:e.busy,onConfirm:()=>{t.attachment(n.id,!1)}}):(0,a.jsx)(N,{type:"button",size:"sm",variant:"outline",disabled:e.busy,onClick:()=>{t.attachment(n.id,!0)},children:"Attach"}):null,(0,a.jsx)(Yt,{source:n,model:t,busy:e.busy})]})}]})]}):null,e.next!==null?(0,a.jsx)(N,{type:"button",className:"w-fit",disabled:e.loading||e.busy,onClick:()=>{t.load(!0)},children:"Load more sources"}):null,e.availableNext!==null?(0,a.jsx)(N,{type:"button",className:"w-fit",disabled:e.availableLoading||e.busy,onClick:()=>{t.loadAvailable(!0)},children:"Load more organization sources"}):null,e.packageSource!==null?(0,a.jsx)(ht,{source:e.packageSource,busy:e.busy,fieldError:e.packageFieldError,alert:e.packageAlert,onSubmit:n=>{t.addPackage(n)},onClose:()=>t.closePackage()},e.packageSource.id):null,e.credentialSource!==null?(0,a.jsx)(Y,{open:!0,onOpenChange:n=>{n||t.closeCredential()},children:(0,a.jsxs)(W,{variant:"source",onCancel:n=>{e.busy&&n.preventDefault()},children:[(0,a.jsxs)(re,{className:"shrink-0 p-6 pr-16",children:[(0,a.jsx)(X,{children:w?"Add GitHub token (optional)":"Set credential"}),(0,a.jsxs)(J,{children:["Credentials are write-only. Save a new credential to rotate a secret.",w?" This optional bearer token is used only for GitHub archive downloads and their rate limits. Enable Use GitHub token in Edit after saving it.":""]})]}),(0,a.jsxs)("div",{className:"grid min-h-0 gap-3 overflow-y-auto px-6 pb-6",children:[(0,a.jsx)(te,{value:e.credentialSource,label:"source ID"}),(0,a.jsx)(Vt,{model:t,source:e.credentialSource,initialKind:e.credentialKind,kinds:e.credentialKinds,busy:e.busy},e.credentialVersion),e.error?(0,a.jsx)("p",{role:"alert",children:e.error}):null,e.savedCredential?.source===e.credentialSource?(0,a.jsxs)("p",{children:["credential set \xB7 ",(0,a.jsx)(ge,{value:e.savedCredential.at})]}):null]})]})}):null,e.savedCredential&&e.credentialSource===null?(0,a.jsxs)("p",{children:["credential set \xB7 ",e.savedCredential.source," \xB7"," ",(0,a.jsx)(ge,{value:e.savedCredential.at})]}):null,e.names?(0,a.jsx)(Y,{open:!0,onOpenChange:n=>{n||t.closeNames()},children:(0,a.jsxs)(W,{variant:"source",onCancel:n=>{e.busy&&n.preventDefault()},children:[(0,a.jsxs)(re,{className:"shrink-0 p-6 pr-16",children:[(0,a.jsx)(X,{children:"Registered names"}),(0,a.jsx)(J,{children:"Manage the package patterns registered for this source. For npm, use an exact lowercase name or @scope/*. A scope claim hides public packages in that scope that are not yet cached."})]}),(0,a.jsxs)("div",{className:"grid min-h-0 gap-3 overflow-y-auto px-6 pb-6",children:[e.error?(0,a.jsx)("p",{role:"alert",children:e.error}):null,(0,a.jsx)(te,{value:e.names.source,label:"source ID"}),(0,a.jsx)("ul",{children:e.names.items.map(n=>(0,a.jsxs)("li",{className:"flex items-center gap-3",children:[(0,a.jsx)("span",{children:n.pattern}),(0,a.jsx)(ke,{action:`Remove ${n.pattern}`,target:n.pattern,scope:t.project===null?"Organization":`Project: ${t.project}`,description:"Removing this registered pattern can stop the source from resolving matching packages. Add the pattern again to restore it.",disabled:e.busy,onConfirm:()=>{t.removeName(n.sourceId,n.id)}})]},n.id))}),e.names.next!==null?(0,a.jsx)(N,{type:"button",disabled:e.busy,onClick:()=>{t.names(e.names.source,!0)},children:"Load more names"}):null,(0,a.jsxs)("form",{className:"grid gap-3",onSubmit:n=>{if(n.preventDefault(),e.busy)return;let d=n.currentTarget,C=Ct(d,"pattern");t.addName(e.names.source,C)},children:[(0,a.jsx)(L,{htmlFor:"registered-pattern",children:"Registered pattern"}),(0,a.jsx)($,{id:"registered-pattern",name:"pattern",maxLength:e.items.find(n=>n.id===e.names?.source)?.ecosystem==="npm"?214:50,required:!0,defaultValue:l[0]??""},`${e.names.source}:${e.names.items.map(n=>n.pattern).join(",")}`),l.map(n=>(0,a.jsxs)("p",{className:"text-sm",children:["Register ",n," before enabling this source."]},n)),(0,a.jsx)(N,{type:"submit",className:"w-fit",disabled:e.busy,children:"Add name"})]})]})]})}):null,t.project!==null&&!e.listError&&e.items.some(n=>"attached"in n&&n.attached)?(0,a.jsxs)(Ae,{children:[(0,a.jsx)(Ie,{children:(0,a.jsx)(Le,{children:"Source order"})}),(0,a.jsxs)(Te,{className:"grid gap-3",children:[(0,a.jsx)("p",{children:"Earlier sources take precedence. Only attached sources are ordered."}),e.next!==null?(0,a.jsx)("p",{children:"Load all sources before changing their order."}):null,(0,a.jsx)(N,{type:"button",className:"w-fit",disabled:e.loading||e.busy||e.next!==null||e.etag===null,onClick:()=>{t.saveOrder()},children:"Save source order"})]})]}):null,t.project!==null?(0,a.jsxs)(Ae,{children:[(0,a.jsx)(Ie,{children:(0,a.jsx)(Le,{children:"Who wins"})}),(0,a.jsxs)(Te,{className:"grid gap-3",children:[(0,a.jsxs)("form",{className:"grid gap-3",onSubmit:n=>{n.preventDefault(),!e.busy&&t.resolve(Ct(n.currentTarget,"name"))},children:[(0,a.jsx)(L,{htmlFor:"resolve-name",children:"Package name"}),(0,a.jsx)($,{id:"resolve-name",name:"name",maxLength:214,required:!0}),(0,a.jsx)(N,{type:"submit",className:"w-fit",disabled:e.busy,children:"Preview"})]}),e.preview?(0,a.jsxs)("div",{"aria-live":"polite",children:[(0,a.jsx)("p",{children:e.preview.name}),(0,a.jsxs)("p",{children:["Winning source: ",(0,a.jsx)(te,{value:e.preview.winner,label:"winning source ID"})]}),(0,a.jsx)("ol",{children:e.preview.candidates.map(n=>(0,a.jsxs)("li",{children:[n.sourceName," \xB7"," ",(0,a.jsx)(te,{value:n.sourceId,label:"candidate source ID"})," \xB7"," ",n.eligible?"Eligible":"Ineligible"]},n.sourceId))})]}):null]})]}):null]})}function Et(){if(typeof window>"u")return null;let t=new URLSearchParams(window.location.hash.split("?")[1]??"").get("project");return new URLSearchParams(Qe("sources",{project:t}).split("?")[1]??"").get("project")}function nr(){let t=Ze(),[e,r]=(0,O.useState)(Et);(0,O.useEffect)(()=>{let o=()=>r(Et());return window.addEventListener("hashchange",o),()=>window.removeEventListener("hashchange",o)},[]);let s=(0,O.useMemo)(()=>zt(t,e),[t,e]);return(0,O.useEffect)(()=>(s.load(),s.loadAvailable(),s.loadMutationPermissions().then(()=>{s.snapshot().canWriteSources&&new URLSearchParams(window.location.hash.split("?")[1]).get("create")==="vcs"&&s.openEditor()}),()=>s.dispose()),[s]),(0,O.useEffect)(()=>t.subscribeReplay?.(o=>{s.replayed(o)}),[t,s]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xt,{model:s},e??"organization"),e===null?(0,a.jsx)(gt,{services:t}):null]})}export{at as a,it as b,ot as c,st as d,lt as e,Qt as f,Oe as g,Fe as h,He as i,mt as j,Z as k,Ve as l,$t as m,Bt as n,he as o,zt as p,Gt as q,Ut as r,Ue as s,Yt as t,Wt as u,Xt as v,nr as w};
@@ -1 +1 @@
1
- import{b as h}from"./chunk.8442124f6802.js";import{a as L,c as b}from"./chunk.965b76812604.js";import"./chunk.3fcd6998795a.js";import{a as f}from"./chunk.d813fefb410d.js";import{A,B as w,C as N,D as m,E as C,F as D,K as R,c as g,d as B,g as y,p as d,x as I,y as k,z as x}from"./chunk.fd375c54b526.js";var u=g(B(),1);var e=g(y(),1);function S(a){return{id:a.id,state:a.state,planHash:a.planHash,approvedAt:a.approvedAt,approvedByUserId:a.approvedByUserId,acceptedAt:a.acceptedAt,beforeImageExpiresAt:a.beforeImageExpiresAt}}function v(a,t,s=Date.now()){if(t==="approve")return a.state==="planned"&&!!a.planHash&&a.approvedAt===null;if(t==="apply"){let i=a.approvedAt===null?NaN:Date.parse(a.approvedAt);return a.state==="planned"&&Number.isFinite(i)&&i<=s+6e4}return t==="cancel"?a.state==="planned":["failed","applied","verifying","verified"].includes(a.state)&&(a.beforeImageExpiresAt===null||Date.parse(a.beforeImageExpiresAt)>s)}function H(a){let t={runs:[],next:null,run:null,selectedId:null,loading:!1,detailLoading:!1,busy:!1,dialog:!1,confirmed:!1,error:null,notice:null},s=0,i=0,c=new Set,n=o=>{t={...t,...o};for(let l of c)l()},r={back(){++s,n({run:null,selectedId:null,detailLoading:!1,dialog:!1,confirmed:!1,error:null,notice:null})},snapshot:()=>t,subscribe(o){return c.add(o),()=>{c.delete(o)}},async load(o){let l=++i;n({loading:!0,error:null,cursor:o});let p=await a.client.request("get","/_pb/import-runs",{query:{cursor:o}});l===i&&n(p.ok?{runs:p.data.items.map(S),next:p.data.next,loading:!1}:{runs:[],next:null,loading:!1,error:"Unable to load import runs."})},async select(o){if(t.busy)return;let l=++s;n({run:null,selectedId:o,detailLoading:!0,dialog:!1,confirmed:!1,error:null,notice:null});let p=await a.client.request("get","/_pb/import-runs/{id}",{params:{id:o}});l===s&&n(p.ok?{run:S(p.data),detailLoading:!1}:{detailLoading:!1,error:"Unable to load the import run."})},openApproval(){!t.busy&&t.run?.state==="planned"&&t.run.planHash&&t.run.approvedAt===null&&n({dialog:!0,confirmed:!1})},closeApproval(){t.busy||n({dialog:!1,confirmed:!1})},confirmApproval(o){t.dialog&&!t.busy&&n({confirmed:o})},async action(o){let l=t.run;if(l===null||t.busy||!v(l,o)||o==="approve"&&(!t.dialog||!t.confirmed||!l.planHash||l.state!=="planned"||l.approvedAt!==null))return;n({busy:!0,error:null,notice:null});let p=o==="approve"?await a.client.request("post","/_pb/import-runs/{id}/approve",{params:{id:l.id},body:{planHash:l.planHash}}):await a.client.request("post",`/_pb/import-runs/{id}/${o}`,{params:{id:l.id}});if(n({busy:!1,dialog:!1,confirmed:!1}),!p.ok){p.code==="reauth_required"?a.requireReauth(p.request,{credential:!1,secretFields:[]}):n({error:p.code==="conflict"?"The run changed. Reload it and try again.":"Unable to update the import run."});return}await r.select(l.id),await r.load(t.cursor),n({notice:"Action accepted. Reload to check job progress."})}};return r}function E({state:a,controller:t,onSelect:s,onBack:i,onPage:c}){let n=a.run,[r,o]=(0,u.useState)(Date.now);return(0,u.useEffect)(()=>{let l=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(l)},[]),(0,e.jsxs)("section",{"aria-labelledby":"page-heading",className:"space-y-4",children:[(0,e.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-2xl font-semibold",children:"Import"}),(0,e.jsx)("p",{children:"Upload credentials with the CLI. Import manifests are managed with the CLI."}),a.selectedId&&n===null?(0,e.jsx)(d,{type:"button",variant:"link",className:"px-0",disabled:a.busy,onClick:()=>i?i():t.back(),children:"\u2190 Back to import runs"}):null,a.error===null?null:(0,e.jsx)(b,{kind:"error",title:a.error,children:(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy||a.loading,onClick:()=>{a.selectedId?t.select(a.selectedId):t.load(a.cursor)},children:"Retry"})}),a.notice===null?null:(0,e.jsx)("p",{role:"status",children:a.notice}),(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.loading||a.busy,onClick:()=>{t.load(a.cursor)},children:"Reload runs"}),a.loading?(0,e.jsx)(b,{kind:"loading",title:"Loading import runs\u2026"}):null,a.detailLoading?(0,e.jsx)(b,{kind:"loading",title:"Loading import run\u2026"}):null,n===null&&!a.detailLoading&&!a.loading?a.runs.length?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(L,{label:"Import runs",items:a.runs,columns:[{key:"id",label:"Run",value:l=>l.id,render:l=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,e.jsxs)(d,{type:"button",variant:"link",className:"h-auto p-0 font-mono",disabled:a.busy,onClick:()=>s?s(l.id):void t.select(l.id),children:["Run ",l.id.slice(0,6),"\u2026",l.id.slice(-4)]}),(0,e.jsx)(m,{value:l.id,label:"run ID"})]})},{key:"state",label:"State",value:l=>l.state,render:l=>(0,e.jsx)(h,{status:l.state})},{key:"hash",label:"Plan hash",value:l=>l.planHash??"",render:l=>l.planHash?(0,e.jsx)(m,{value:l.planHash,label:"plan hash"}):"No plan hash"},{key:"approved",label:"Approved",priority:2,value:l=>l.approvedAt??"",render:l=>(0,e.jsx)(f,{value:l.approvedAt,fallback:"Not approved"})},{key:"accepted",label:"Accepted",priority:3,value:l=>l.acceptedAt??"",render:l=>(0,e.jsx)(f,{value:l.acceptedAt,fallback:"Not accepted"})},{key:"expires",label:"Before-image expires",priority:3,value:l=>l.beforeImageExpiresAt??"",render:l=>(0,e.jsx)(f,{value:l.beforeImageExpiresAt,fallback:"Not scheduled"})}]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:!a.cursor||a.busy,onClick:()=>c?c():void t.load(),children:"First page"}),(0,e.jsx)(d,{type:"button",variant:"outline",disabled:!a.next||a.busy,onClick:()=>{a.next&&(c?c(a.next):t.load(a.next))},children:"Next page"})]})]}):a.error?null:(0,e.jsx)(b,{kind:a.cursor?"filtered-empty":"empty",title:a.cursor?"No import runs on this page":"No import runs.",children:"Create an import plan with the CLI to get started."}):null,n===null?null:(0,e.jsxs)("section",{"aria-labelledby":"run-heading",className:"space-y-3",children:[(0,e.jsx)(d,{type:"button",variant:"link",className:"px-0",disabled:a.busy,onClick:()=>i?i():t.back(),children:"\u2190 Back to import runs"}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)("h2",{id:"run-heading",className:"text-lg font-semibold",children:["Run ",(0,e.jsx)(m,{value:n.id,label:"run ID"})]}),(0,e.jsx)(h,{status:n.state})]}),(0,e.jsxs)("div",{className:"detail-grid",children:[(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Plan"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Plan hash"}),(0,e.jsx)("dd",{children:n.planHash?(0,e.jsx)(m,{value:n.planHash,label:"full plan hash",full:!0}):"No plan hash"}),(0,e.jsx)("dt",{children:"Run ID"}),(0,e.jsx)("dd",{children:(0,e.jsx)(m,{value:n.id,label:"run ID"})})]})]}),(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Approval"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Approved at"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.approvedAt,fallback:"Not approved"})}),(0,e.jsx)("dt",{children:"Approved by"}),(0,e.jsx)("dd",{children:(0,e.jsx)(m,{value:n.approvedByUserId,label:"approving user ID"})})]})]}),(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Execution and retention"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Accepted at"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.acceptedAt,fallback:"Not accepted"})}),(0,e.jsx)("dt",{children:"Before-image expires"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.beforeImageExpiresAt,fallback:"Not scheduled"})})]})]})]}),(0,e.jsx)("h3",{className:"font-semibold",children:"Actions"}),(0,e.jsx)("p",{className:"text-sm text-neutral-600",children:"Apply requires an approved plan. Cancel is available for planned runs. Rollback is available after execution while before-images are retained."}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy,onClick:()=>{t.select(n.id)},children:"Reload run"}),(0,e.jsx)(d,{type:"button",disabled:a.busy||!v(n,"approve",r),onClick:()=>t.openApproval(),children:"Review approval"}),["apply","cancel","rollback"].map(l=>(0,e.jsx)(d,{type:"button",variant:l==="apply"?"outline":"ghost",className:l==="apply"?void 0:"text-red-700",disabled:a.busy||!v(n,l,r),title:v(n,l,r)?void 0:"Unavailable in the current state or retention window.",onClick:()=>{t.action(l)},children:l==="apply"?"Apply":l==="cancel"?"Cancel run":"Rollback"},l))]})]}),a.dialog&&n!==null?(0,e.jsx)(I,{open:!0,onOpenChange:l=>{l||t.closeApproval()},children:(0,e.jsx)(k,{onCancel:l=>{a.busy&&l.preventDefault()},children:(0,e.jsxs)("form",{className:"grid gap-4",onSubmit:l=>{l.preventDefault(),!(a.busy||!a.confirmed)&&t.action("approve")},children:[(0,e.jsxs)(x,{children:[(0,e.jsx)(w,{children:"Approve import run"}),(0,e.jsx)(N,{children:"Confirm the full plan hash for the plan you reviewed with the CLI."})]}),(0,e.jsx)("p",{className:"break-all",children:(0,e.jsx)("code",{children:n.planHash})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(C,{id:"confirm-plan",type:"checkbox",className:"h-4 w-4",checked:a.confirmed,disabled:a.busy,onChange:l=>t.confirmApproval(l.currentTarget.checked)}),(0,e.jsx)(D,{htmlFor:"confirm-plan",children:"I confirm this plan hash."})]}),(0,e.jsxs)(A,{children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy,onClick:()=>t.closeApproval(),children:"Back"}),(0,e.jsx)(d,{type:"submit",disabled:!a.confirmed||a.busy,children:"Approve run"})]})]})})}):null]})}function O(){let a=R(),t=(0,u.useMemo)(()=>H(a),[a]),s=(0,u.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),[i,c]=(0,u.useState)(()=>window.location.hash);(0,u.useEffect)(()=>{let r=()=>c(window.location.hash);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]),(0,u.useEffect)(()=>{let r=new URLSearchParams(i.split("?")[1]);t.load(r.get("cursor")??void 0);let o=r.get("run");o?t.select(o):t.back()},[t,i]);let n=(r,o)=>{let l=new URLSearchParams(i.split("?")[1]);o?l.set(r,o):l.delete(r),r==="cursor"&&l.delete("run"),window.location.hash=`#/import${l.size?`?${l}`:""}`};return(0,e.jsx)(E,{state:s,controller:t,onSelect:r=>n("run",r),onBack:()=>n("run"),onPage:r=>n("cursor",r)})}export{O as ImportPage,E as ImportView,H as createImportController,v as importActionAllowed};
1
+ import{b as h}from"./chunk.f0fd799728ef.js";import{a as L,c as b}from"./chunk.56e058d97e0f.js";import"./chunk.75e1357175af.js";import{a as f}from"./chunk.dc41ee9219cf.js";import{A,B as w,C as N,D as m,E as C,F as D,K as R,c as g,d as B,g as y,p as d,x as I,y as k,z as x}from"./chunk.837eb41f53ef.js";var u=g(B(),1);var e=g(y(),1);function S(a){return{id:a.id,state:a.state,planHash:a.planHash,approvedAt:a.approvedAt,approvedByUserId:a.approvedByUserId,acceptedAt:a.acceptedAt,beforeImageExpiresAt:a.beforeImageExpiresAt}}function v(a,t,s=Date.now()){if(t==="approve")return a.state==="planned"&&!!a.planHash&&a.approvedAt===null;if(t==="apply"){let i=a.approvedAt===null?NaN:Date.parse(a.approvedAt);return a.state==="planned"&&Number.isFinite(i)&&i<=s+6e4}return t==="cancel"?a.state==="planned":["failed","applied","verifying","verified"].includes(a.state)&&(a.beforeImageExpiresAt===null||Date.parse(a.beforeImageExpiresAt)>s)}function H(a){let t={runs:[],next:null,run:null,selectedId:null,loading:!1,detailLoading:!1,busy:!1,dialog:!1,confirmed:!1,error:null,notice:null},s=0,i=0,c=new Set,n=o=>{t={...t,...o};for(let l of c)l()},r={back(){++s,n({run:null,selectedId:null,detailLoading:!1,dialog:!1,confirmed:!1,error:null,notice:null})},snapshot:()=>t,subscribe(o){return c.add(o),()=>{c.delete(o)}},async load(o){let l=++i;n({loading:!0,error:null,cursor:o});let p=await a.client.request("get","/_pb/import-runs",{query:{cursor:o}});l===i&&n(p.ok?{runs:p.data.items.map(S),next:p.data.next,loading:!1}:{runs:[],next:null,loading:!1,error:"Unable to load import runs."})},async select(o){if(t.busy)return;let l=++s;n({run:null,selectedId:o,detailLoading:!0,dialog:!1,confirmed:!1,error:null,notice:null});let p=await a.client.request("get","/_pb/import-runs/{id}",{params:{id:o}});l===s&&n(p.ok?{run:S(p.data),detailLoading:!1}:{detailLoading:!1,error:"Unable to load the import run."})},openApproval(){!t.busy&&t.run?.state==="planned"&&t.run.planHash&&t.run.approvedAt===null&&n({dialog:!0,confirmed:!1})},closeApproval(){t.busy||n({dialog:!1,confirmed:!1})},confirmApproval(o){t.dialog&&!t.busy&&n({confirmed:o})},async action(o){let l=t.run;if(l===null||t.busy||!v(l,o)||o==="approve"&&(!t.dialog||!t.confirmed||!l.planHash||l.state!=="planned"||l.approvedAt!==null))return;n({busy:!0,error:null,notice:null});let p=o==="approve"?await a.client.request("post","/_pb/import-runs/{id}/approve",{params:{id:l.id},body:{planHash:l.planHash}}):await a.client.request("post",`/_pb/import-runs/{id}/${o}`,{params:{id:l.id}});if(n({busy:!1,dialog:!1,confirmed:!1}),!p.ok){p.code==="reauth_required"?a.requireReauth(p.request,{credential:!1,secretFields:[]}):n({error:p.code==="conflict"?"The run changed. Reload it and try again.":"Unable to update the import run."});return}await r.select(l.id),await r.load(t.cursor),n({notice:"Action accepted. Reload to check job progress."})}};return r}function E({state:a,controller:t,onSelect:s,onBack:i,onPage:c}){let n=a.run,[r,o]=(0,u.useState)(Date.now);return(0,u.useEffect)(()=>{let l=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(l)},[]),(0,e.jsxs)("section",{"aria-labelledby":"page-heading",className:"space-y-4",children:[(0,e.jsx)("h1",{tabIndex:-1,id:"page-heading",className:"text-2xl font-semibold",children:"Import"}),(0,e.jsx)("p",{children:"Upload credentials with the CLI. Import manifests are managed with the CLI."}),a.selectedId&&n===null?(0,e.jsx)(d,{type:"button",variant:"link",className:"px-0",disabled:a.busy,onClick:()=>i?i():t.back(),children:"\u2190 Back to import runs"}):null,a.error===null?null:(0,e.jsx)(b,{kind:"error",title:a.error,children:(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy||a.loading,onClick:()=>{a.selectedId?t.select(a.selectedId):t.load(a.cursor)},children:"Retry"})}),a.notice===null?null:(0,e.jsx)("p",{role:"status",children:a.notice}),(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.loading||a.busy,onClick:()=>{t.load(a.cursor)},children:"Reload runs"}),a.loading?(0,e.jsx)(b,{kind:"loading",title:"Loading import runs\u2026"}):null,a.detailLoading?(0,e.jsx)(b,{kind:"loading",title:"Loading import run\u2026"}):null,n===null&&!a.detailLoading&&!a.loading?a.runs.length?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(L,{label:"Import runs",items:a.runs,columns:[{key:"id",label:"Run",value:l=>l.id,render:l=>(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,e.jsxs)(d,{type:"button",variant:"link",className:"h-auto p-0 font-mono",disabled:a.busy,onClick:()=>s?s(l.id):void t.select(l.id),children:["Run ",l.id.slice(0,6),"\u2026",l.id.slice(-4)]}),(0,e.jsx)(m,{value:l.id,label:"run ID"})]})},{key:"state",label:"State",value:l=>l.state,render:l=>(0,e.jsx)(h,{status:l.state})},{key:"hash",label:"Plan hash",value:l=>l.planHash??"",render:l=>l.planHash?(0,e.jsx)(m,{value:l.planHash,label:"plan hash"}):"No plan hash"},{key:"approved",label:"Approved",priority:2,value:l=>l.approvedAt??"",render:l=>(0,e.jsx)(f,{value:l.approvedAt,fallback:"Not approved"})},{key:"accepted",label:"Accepted",priority:3,value:l=>l.acceptedAt??"",render:l=>(0,e.jsx)(f,{value:l.acceptedAt,fallback:"Not accepted"})},{key:"expires",label:"Before-image expires",priority:3,value:l=>l.beforeImageExpiresAt??"",render:l=>(0,e.jsx)(f,{value:l.beforeImageExpiresAt,fallback:"Not scheduled"})}]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:!a.cursor||a.busy,onClick:()=>c?c():void t.load(),children:"First page"}),(0,e.jsx)(d,{type:"button",variant:"outline",disabled:!a.next||a.busy,onClick:()=>{a.next&&(c?c(a.next):t.load(a.next))},children:"Next page"})]})]}):a.error?null:(0,e.jsx)(b,{kind:a.cursor?"filtered-empty":"empty",title:a.cursor?"No import runs on this page":"No import runs.",children:"Create an import plan with the CLI to get started."}):null,n===null?null:(0,e.jsxs)("section",{"aria-labelledby":"run-heading",className:"space-y-3",children:[(0,e.jsx)(d,{type:"button",variant:"link",className:"px-0",disabled:a.busy,onClick:()=>i?i():t.back(),children:"\u2190 Back to import runs"}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)("h2",{id:"run-heading",className:"text-lg font-semibold",children:["Run ",(0,e.jsx)(m,{value:n.id,label:"run ID"})]}),(0,e.jsx)(h,{status:n.state})]}),(0,e.jsxs)("div",{className:"detail-grid",children:[(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Plan"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Plan hash"}),(0,e.jsx)("dd",{children:n.planHash?(0,e.jsx)(m,{value:n.planHash,label:"full plan hash",full:!0}):"No plan hash"}),(0,e.jsx)("dt",{children:"Run ID"}),(0,e.jsx)("dd",{children:(0,e.jsx)(m,{value:n.id,label:"run ID"})})]})]}),(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Approval"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Approved at"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.approvedAt,fallback:"Not approved"})}),(0,e.jsx)("dt",{children:"Approved by"}),(0,e.jsx)("dd",{children:(0,e.jsx)(m,{value:n.approvedByUserId,label:"approving user ID"})})]})]}),(0,e.jsxs)("div",{className:"detail-group",children:[(0,e.jsx)("h3",{children:"Execution and retention"}),(0,e.jsxs)("dl",{className:"detail-list",children:[(0,e.jsx)("dt",{children:"Accepted at"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.acceptedAt,fallback:"Not accepted"})}),(0,e.jsx)("dt",{children:"Before-image expires"}),(0,e.jsx)("dd",{children:(0,e.jsx)(f,{value:n.beforeImageExpiresAt,fallback:"Not scheduled"})})]})]})]}),(0,e.jsx)("h3",{className:"font-semibold",children:"Actions"}),(0,e.jsx)("p",{className:"text-sm text-neutral-600",children:"Apply requires an approved plan. Cancel is available for planned runs. Rollback is available after execution while before-images are retained."}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy,onClick:()=>{t.select(n.id)},children:"Reload run"}),(0,e.jsx)(d,{type:"button",disabled:a.busy||!v(n,"approve",r),onClick:()=>t.openApproval(),children:"Review approval"}),["apply","cancel","rollback"].map(l=>(0,e.jsx)(d,{type:"button",variant:l==="apply"?"outline":"ghost",className:l==="apply"?void 0:"text-red-700",disabled:a.busy||!v(n,l,r),title:v(n,l,r)?void 0:"Unavailable in the current state or retention window.",onClick:()=>{t.action(l)},children:l==="apply"?"Apply":l==="cancel"?"Cancel run":"Rollback"},l))]})]}),a.dialog&&n!==null?(0,e.jsx)(I,{open:!0,onOpenChange:l=>{l||t.closeApproval()},children:(0,e.jsx)(k,{onCancel:l=>{a.busy&&l.preventDefault()},children:(0,e.jsxs)("form",{className:"grid gap-4",onSubmit:l=>{l.preventDefault(),!(a.busy||!a.confirmed)&&t.action("approve")},children:[(0,e.jsxs)(x,{children:[(0,e.jsx)(w,{children:"Approve import run"}),(0,e.jsx)(N,{children:"Confirm the full plan hash for the plan you reviewed with the CLI."})]}),(0,e.jsx)("p",{className:"break-all",children:(0,e.jsx)("code",{children:n.planHash})}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(C,{id:"confirm-plan",type:"checkbox",className:"h-4 w-4",checked:a.confirmed,disabled:a.busy,onChange:l=>t.confirmApproval(l.currentTarget.checked)}),(0,e.jsx)(D,{htmlFor:"confirm-plan",children:"I confirm this plan hash."})]}),(0,e.jsxs)(A,{children:[(0,e.jsx)(d,{type:"button",variant:"outline",disabled:a.busy,onClick:()=>t.closeApproval(),children:"Back"}),(0,e.jsx)(d,{type:"submit",disabled:!a.confirmed||a.busy,children:"Approve run"})]})]})})}):null]})}function O(){let a=R(),t=(0,u.useMemo)(()=>H(a),[a]),s=(0,u.useSyncExternalStore)(t.subscribe,t.snapshot,t.snapshot),[i,c]=(0,u.useState)(()=>window.location.hash);(0,u.useEffect)(()=>{let r=()=>c(window.location.hash);return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[]),(0,u.useEffect)(()=>{let r=new URLSearchParams(i.split("?")[1]);t.load(r.get("cursor")??void 0);let o=r.get("run");o?t.select(o):t.back()},[t,i]);let n=(r,o)=>{let l=new URLSearchParams(i.split("?")[1]);o?l.set(r,o):l.delete(r),r==="cursor"&&l.delete("run"),window.location.hash=`#/import${l.size?`?${l}`:""}`};return(0,e.jsx)(E,{state:s,controller:t,onSelect:r=>n("run",r),onBack:()=>n("run"),onPage:r=>n("cursor",r)})}export{O as ImportPage,E as ImportView,H as createImportController,v as importActionAllowed};
@@ -4,15 +4,15 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Package Broker</title>
7
- <link rel="stylesheet" href="app.45b156168495.css" />
7
+ <link rel="stylesheet" href="app.ec678c27ec0a.css" />
8
8
  <link rel="modulepreload" href="chunk.675b635d9462.js" />
9
- <link rel="modulepreload" href="chunk.f54ea1378c8c.js" />
10
- <link rel="modulepreload" href="chunk.fd375c54b526.js" />
9
+ <link rel="modulepreload" href="chunk.ab1a14143dc6.js" />
10
+ <link rel="modulepreload" href="chunk.837eb41f53ef.js" />
11
11
  <link rel="modulepreload" href="chunk.815f9a91c741.js" />
12
- <link rel="modulepreload" href="chunk.d18497920e4d.js" />
13
- <link rel="modulepreload" href="chunk.3fcd6998795a.js" />
14
- <link rel="modulepreload" href="chunk.741aec8d1ff9.js" />
15
- <script type="module" src="app.c064670cdc0d.js"></script>
12
+ <link rel="modulepreload" href="chunk.4721d4544d48.js" />
13
+ <link rel="modulepreload" href="chunk.75e1357175af.js" />
14
+ <link rel="modulepreload" href="chunk.3f077ff17cea.js" />
15
+ <script type="module" src="app.fba0d059b40b.js"></script>
16
16
  </head>
17
17
  <body>
18
18
  <div id="root"></div>
@@ -14,11 +14,11 @@
14
14
  "contentType": "text/javascript",
15
15
  "bytes": 3251
16
16
  },
17
- "chunk.fd375c54b526.js": {
17
+ "chunk.837eb41f53ef.js": {
18
18
  "contentType": "text/javascript",
19
- "bytes": 87869
19
+ "bytes": 88205
20
20
  },
21
- "chunk.f54ea1378c8c.js": {
21
+ "chunk.ab1a14143dc6.js": {
22
22
  "contentType": "text/javascript",
23
23
  "bytes": 242
24
24
  },
@@ -26,101 +26,101 @@
26
26
  "contentType": "text/javascript",
27
27
  "bytes": 1315
28
28
  },
29
- "chunk.3fcd6998795a.js": {
29
+ "chunk.75e1357175af.js": {
30
30
  "contentType": "text/javascript",
31
31
  "bytes": 1694
32
32
  },
33
- "chunk.d18497920e4d.js": {
33
+ "chunk.4721d4544d48.js": {
34
34
  "contentType": "text/javascript",
35
35
  "bytes": 179256
36
36
  },
37
- "chunk.741aec8d1ff9.js": {
37
+ "chunk.3f077ff17cea.js": {
38
38
  "contentType": "text/javascript",
39
39
  "bytes": 379
40
40
  },
41
- "chunk.28a4d8aab337.js": {
41
+ "chunk.53134c7df4e5.js": {
42
42
  "contentType": "text/javascript",
43
43
  "bytes": 2221
44
44
  },
45
- "chunk.965b76812604.js": {
45
+ "chunk.56e058d97e0f.js": {
46
46
  "contentType": "text/javascript",
47
47
  "bytes": 41963
48
48
  },
49
- "chunk.6ea6bdcaa465.js": {
49
+ "chunk.4acf8fa7653f.js": {
50
50
  "contentType": "text/javascript",
51
51
  "bytes": 4075
52
52
  },
53
- "chunk.8442124f6802.js": {
53
+ "chunk.f0fd799728ef.js": {
54
54
  "contentType": "text/javascript",
55
55
  "bytes": 2178
56
56
  },
57
- "chunk.a6d755a9789f.js": {
57
+ "chunk.304a2b5d1663.js": {
58
58
  "contentType": "text/javascript",
59
59
  "bytes": 1120
60
60
  },
61
- "projects.927fe18c785c.js": {
61
+ "projects.44006a838c67.js": {
62
62
  "contentType": "text/javascript",
63
63
  "bytes": 19234
64
64
  },
65
- "chunk.d813fefb410d.js": {
65
+ "chunk.dc41ee9219cf.js": {
66
66
  "contentType": "text/javascript",
67
67
  "bytes": 457
68
68
  },
69
- "access.62e9484517a0.js": {
69
+ "access.def9a17dc4a8.js": {
70
70
  "contentType": "text/javascript",
71
71
  "bytes": 26648
72
72
  },
73
- "chunk.56d473a1587d.js": {
73
+ "chunk.2c3648a5bad1.js": {
74
74
  "contentType": "text/javascript",
75
75
  "bytes": 1645
76
76
  },
77
- "chunk.51497edc7697.js": {
77
+ "chunk.fac952720b72.js": {
78
78
  "contentType": "text/javascript",
79
- "bytes": 58133
79
+ "bytes": 79737
80
80
  },
81
81
  "chunk.e3b0c44298fc.js": {
82
82
  "contentType": "text/javascript",
83
83
  "bytes": 0
84
84
  },
85
- "sources.ae50f239f80f.js": {
85
+ "sources.d95aabfbec73.js": {
86
86
  "contentType": "text/javascript",
87
- "bytes": 774
87
+ "bytes": 806
88
88
  },
89
- "packages.ab5ab25b1c75.js": {
89
+ "packages.bdd474bcfc11.js": {
90
90
  "contentType": "text/javascript",
91
- "bytes": 57395
91
+ "bytes": 70261
92
92
  },
93
- "npm-login.e059678af13d.js": {
93
+ "npm-login.d8b60e11fe87.js": {
94
94
  "contentType": "text/javascript",
95
95
  "bytes": 3728
96
96
  },
97
- "tokens.6b86d8d97e07.js": {
97
+ "tokens.4ee13a722abb.js": {
98
98
  "contentType": "text/javascript",
99
99
  "bytes": 63356
100
100
  },
101
- "notifications.19225fe12044.js": {
101
+ "notifications.bd7d4c3f9882.js": {
102
102
  "contentType": "text/javascript",
103
103
  "bytes": 30808
104
104
  },
105
- "audit.b7c40b9dc998.js": {
105
+ "audit.453367b59daf.js": {
106
106
  "contentType": "text/javascript",
107
107
  "bytes": 6127
108
108
  },
109
- "import.e7a1e5834631.js": {
109
+ "import.4275bbce08ac.js": {
110
110
  "contentType": "text/javascript",
111
111
  "bytes": 10472
112
112
  },
113
- "app.c064670cdc0d.js": {
113
+ "app.fba0d059b40b.js": {
114
114
  "contentType": "text/javascript",
115
115
  "bytes": 217905
116
116
  },
117
- "setup.8e977608d413.js": {
117
+ "setup.7bc86366227c.js": {
118
118
  "contentType": "text/javascript",
119
119
  "bytes": 17028
120
120
  },
121
- "app.45b156168495.css": {
121
+ "app.ec678c27ec0a.css": {
122
122
  "contentType": "text/css",
123
- "bytes": 32112
123
+ "bytes": 32217
124
124
  }
125
125
  }
126
126
  }