@pb33f/cowboy-components 0.7.0 → 0.7.1
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.
|
@@ -381,7 +381,6 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
381
381
|
this.bus.mapChannelToBrokerDestination(QueuePrefix + SpecStreamChannel, SpecStreamChannel);
|
|
382
382
|
this.bus.mapChannelToBrokerDestination(QueuePrefix + CreditStreamChannel, CreditStreamChannel);
|
|
383
383
|
this.boostrap();
|
|
384
|
-
this.loadingOverlay.hide();
|
|
385
384
|
}
|
|
386
385
|
specStreamHandler() {
|
|
387
386
|
return (msg) => {
|
|
@@ -2032,6 +2031,7 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
2032
2031
|
return;
|
|
2033
2032
|
}
|
|
2034
2033
|
setTimeout(() => {
|
|
2034
|
+
this.loadingOverlay.hide();
|
|
2035
2035
|
// check for a history
|
|
2036
2036
|
this.timeVortex.doctor = this;
|
|
2037
2037
|
this.timeVortex.checkHistory();
|
|
@@ -22,7 +22,6 @@ export declare class TardisControl extends Colorful {
|
|
|
22
22
|
timelineView: TimelineView;
|
|
23
23
|
constructor();
|
|
24
24
|
explorerNodeClicked(evt: CustomEvent<NodeClickedEvent>): void;
|
|
25
|
-
firstUpdated(): void;
|
|
26
25
|
fetchHistory(): void;
|
|
27
26
|
renderSummaryForMultiChange(): TemplateResult;
|
|
28
27
|
render(): TemplateResult<1>;
|
|
@@ -53,10 +53,10 @@ let TardisControl = class TardisControl extends Colorful {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
firstUpdated() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
56
|
+
// firstUpdated() {
|
|
57
|
+
// super.firstUpdated()
|
|
58
|
+
// this.fetchHistory()
|
|
59
|
+
// }
|
|
60
60
|
fetchHistory() {
|
|
61
61
|
TimelineService.fetchHistory().then((history) => {
|
|
62
62
|
this.history = history;
|
|
@@ -11893,7 +11893,7 @@ ${Sxt(h)}`}}))}render(){var L,A,I,N,O;let h=E.html``,c=E.html``,l=E.html``,d=E.h
|
|
|
11893
11893
|
<div class="col breaking-col">${this.renderBreaking(h.breaking)}</div>
|
|
11894
11894
|
<div class="col context">${c}</div>
|
|
11895
11895
|
`})}
|
|
11896
|
-
</div>`}};rz.styles=[_It,xte],X7e([V.property()],rz.prototype,"changes",2),rz=X7e([V.customElement("pb33f-change-list")],rz);var FIt=Object.defineProperty,zIt=Object.getOwnPropertyDescriptor,N8=(h,c,l,d)=>{for(var p=d>1?void 0:d?zIt(c,l):c,m=h.length-1,v;m>=0;m--)(v=h[m])&&(p=(d?v(c,l,p):v(p))||p);return d&&p&&FIt(c,l,p),p};let rw=class extends xF{constructor(){super(),this.explorer=new pg,this.explorer.renderEqualizer=!1,this.explorer.equalizer.renderEqualizer=!1,this.timelineView=new su,this.addEventListener(mB,this.explorerNodeClicked.bind(this))}explorerNodeClicked(h){h.stopPropagation(),this.changeReport&&this.changeReport.nodesRendered.forEach(c=>{c.id==h.detail.nodeId&&(this.dispatchEvent(new CustomEvent(fxe,{bubbles:!0,composed:!0,detail:{renderedNode:c}})),this.explorer.activeNode=c,this.explorer.buildLayout())})}
|
|
11896
|
+
</div>`}};rz.styles=[_It,xte],X7e([V.property()],rz.prototype,"changes",2),rz=X7e([V.customElement("pb33f-change-list")],rz);var FIt=Object.defineProperty,zIt=Object.getOwnPropertyDescriptor,N8=(h,c,l,d)=>{for(var p=d>1?void 0:d?zIt(c,l):c,m=h.length-1,v;m>=0;m--)(v=h[m])&&(p=(d?v(c,l,p):v(p))||p);return d&&p&&FIt(c,l,p),p};let rw=class extends xF{constructor(){super(),this.explorer=new pg,this.explorer.renderEqualizer=!1,this.explorer.equalizer.renderEqualizer=!1,this.timelineView=new su,this.addEventListener(mB,this.explorerNodeClicked.bind(this))}explorerNodeClicked(h){h.stopPropagation(),this.changeReport&&this.changeReport.nodesRendered.forEach(c=>{c.id==h.detail.nodeId&&(this.dispatchEvent(new CustomEvent(fxe,{bubbles:!0,composed:!0,detail:{renderedNode:c}})),this.explorer.activeNode=c,this.explorer.buildLayout())})}fetchHistory(){dM.fetchHistory().then(h=>{var c,l,d,p,m,v;this.history=h,h.changeData&&(this.timelineView.changeDatasets=(c=h.changeData)==null?void 0:c.datasets,this.timelineView.changeLabels=(l=h.changeData)==null?void 0:l.labels),h!=null&&h.violationData&&(this.timelineView.violationDatasets=(d=h.violationData)==null?void 0:d.datasets,this.timelineView.violationLabels=(p=h.violationData)==null?void 0:p.labels),h.qualityData&&(this.timelineView.qualityDatasets=(m=h.qualityData)==null?void 0:m.datasets,this.timelineView.qualityLabels=(v=h.qualityData)==null?void 0:v.labels),this.timelineView.requestUpdate(),this.requestUpdate()}).catch(h=>{this.dispatchEvent(new CustomEvent(W2,{bubbles:!0,composed:!0,detail:{toast:{type:Rc.ERROR,id:"timeline-error",body:h.detail,title:"timeline error"}}}))})}renderSummaryForMultiChange(){var v,C,L,A,I,N,O;if(((v=this.specSummary)==null?void 0:v.totalChanges)<=1)return E.html``;const h=["Modified","Added","Removed"],c=["Breaking","Non-Breaking"],l=[{labels:h,data:[(C=this.specSummary)==null?void 0:C.modifications,(L=this.specSummary)==null?void 0:L.additions,(A=this.specSummary)==null?void 0:A.removals]}],d=[{labels:c,data:[(I=this.specSummary)==null?void 0:I.breakingChanges,(N=this.specSummary)==null?void 0:N.totalChanges]}];let p=E.html``;((O=this.specSummary)==null?void 0:O.totalChanges)>1&&(p=E.html`
|
|
11897
11897
|
<pb33f-doughnut-chart id="breaking-doughnut" showLegend breakingChanges width=290 height=130
|
|
11898
11898
|
.datasets=${d} .labels=${c}
|
|
11899
11899
|
style="padding-left: 10px; padding-top: 10px"></pb33f-doughnut-chart>`);const m=new w8;return this.specSummary&&(m.specSummary=this.specSummary,m.large=!0),E.html`
|
|
@@ -12030,7 +12030,7 @@ ${Sxt(h)}`}}))}render(){var L,A,I,N,O;let h=E.html``,c=E.html``,l=E.html``,d=E.h
|
|
|
12030
12030
|
</div>
|
|
12031
12031
|
</div>
|
|
12032
12032
|
<sl-button slot="footer" variant="primary" @click="${this.close}">Close</sl-button>
|
|
12033
|
-
</sl-dialog>`}};yM.styles=[qIt,PP,Od],bne([V.query("sl-dialog")],yM.prototype,"dialog",2),bne([V.state()],yM.prototype,"settings",2),yM=bne([V.customElement("pb33f-doctor-settings")],yM);var WIt=Object.defineProperty,VIt=Object.getOwnPropertyDescriptor,xo=(h,c,l,d)=>{for(var p=d>1?void 0:d?VIt(c,l):c,m=h.length-1,v;m>=0;m--)(v=h[m])&&(p=(d?v(c,l,p):v(p))||p);return d&&p&&WIt(c,l,p),p};const sz="pb33f-doctor-graph",lm="pb33f-doctor-panel-state",mne="pb33f-doctor-rolodex-response",ME="pb33f-doctor-rolodex-files",sw="pb33f-doctor-rolodex-state",oz="pb33f-doctor-reference-map",YIt="pb33f-doctor-editor",ZIt="pb33f-doctor-howtofix",XIt="pb33f-doctor-funcdocs",Q7e="pb33f-doctor-doc-expiration",QIt="pb33f-doctor-ruledocs",wne="pb33f-doctor-diagnostic",vne="pb33f-doctor-default-ruleset",yne="pb33f-doctor-owasp-ruleset",xne="pb33f-doctor-all-ruleset",LE="pb33f-doctor-functions",SE="pb33f-doctor-function-schema",IE="pb33f-doctor-custom-ruleset",xM="pb33f-doctor-rule-configuration",cz="pb33f-doctor-session-rulesetmap",AE="pb33f-doctor-settings",kM="pb33f-doctor-document",lz="pb33f-doctor-problems",JIt="doctor-endpoint";let no=class extends E.LitElement{constructor(h="https://doctor.pb33f.io"){super(),this.debounceTime=1e3,this.debounceTimeRuleset=900,this.bounceId=0,this.useTLS=!1,this.rolodexDividerPosition=40,this._firstRun=!0;const c=sessionStorage.getItem(JIt);c?this.doctorEndpoint=c:this.doctorEndpoint=h,n8.doctorEndpoint=this.doctorEndpoint,SB.doctorEndpoint=this.doctorEndpoint,Yf.doctorEndpoint=this.doctorEndpoint,Vf.doctorEndpoint=this.doctorEndpoint,dP.doctorEndpoint=this.doctorEndpoint,dM.doctorEndpoint=this.doctorEndpoint,this.timeVortex=new CE,this.bus=i7t(),this.doctorServiceChannel=this.bus.createChannel(vF),this.specStreamChannel=this.bus.createChannel(mte),this.creditStreamChannel=this.bus.createChannel(wte),this.bus.mapChannelToBrokerDestination(vte+vF,vF),this.doctorChannelSubscription=this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.bagManager=Vxe(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new Gp,this.uploadArchive=new O1,this.nukeWorkspace=new hM,this.rulesetEditor=new Gp("ruleset-editor"),this.problemList=new CP,this.detailsDrawer=new XC,this.problemsOverview=new w4,this.errorBanner=new i8,this.statusBar=new r8,this.ruleDocsWorker=new mxt,this.unavailable=!1,this.feedback=new v4,this.activitySpinner=new IB,this.manageRuleset=new Wp,this.toastManager=new EB,this.creditTicker=new I4,this.settingsComponent=new yM,this.editorMap=new Map,this.editorMap.set("spec",this.editor),this.editorMap.set("ruleset-editor",this.rulesetEditor),this.selectedEditorTab="spec",this.sidebarClosed=!1,this.explorerVisible=!1,this.explorerBooted=!1,this.rolodexNeedsReset=!1,this.rolodexProblemMap=new Map,this.rolodexRootHash="",this.rolodexRootPath="",this.importDisabled=!1,this.pendingLine=0,this.autoDiagnose=!0,this.skipTimeline=!1,this.nodeMap=new Map,this.nodeIdMap=new Map,this.nodeIdHashMap=new Map,this.renderedNodeMap=new Map,this.filteredNodes=new Map,this.modelTree=new fg(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexTree=new fg(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexActiveHash="",this.explorer=new pg,this.renderedNode=new uM,this.references=[],this.minimapVisible=!0,this.minimapIconVisible=!0,this.showDiagnosisButton=!1,this.nodeLimit=150,this.randomTicker=0;const l=p=>{p.creditsRemaining?this.creditTicker.credits=p.creditsRemaining:this.creditTicker.credits=p.creditsRemaining,this.creditTicker.visible=!0,this.connectToBroker()};this.authController=new vxe(this,l,!0),this.addEventListener(Aee,this.specChanged),this.addEventListener(H6e,this.specClicked),this.addEventListener(gB,this.problemClicked),this.addEventListener(Wf,this.ruleDocsClicked),this.addEventListener(Y6e,this.ruleGroupClicked),this.addEventListener(Pee,this.customRulesetEnabled),this.addEventListener(Eee,this.rulesetSaved),this.addEventListener(W2,this.addToastEvent),this.addEventListener(exe,this.exportRuleset),this.addEventListener(J6e,this.ruleClicked),this.addEventListener(bB,this.builtInRulesetSelected),this.addEventListener(X3,this.modelTreeNodeClicked),this.addEventListener(fP,this.rolodexTreeNodeClicked),this.addEventListener(nxe,this.rolodexRootFileSelected),this.addEventListener($ee,this.explorerReferenceClicked),this.addEventListener(mB,this.explorerNodeClicked.bind(this)),this.addEventListener(hxe,this.fetchUrl.bind(this)),this.addEventListener(Oee,this.documentReferenceClicked.bind(this)),this.explorer.equalizer.addEventListener(Dee,this.filterTreeModel.bind(this)),this.explorer.equalizer.addEventListener(Tee,this.filterTreeModel.bind(this)),this.nukeWorkspace.addEventListener(dxe,this.nukeWorkspaceHandler.bind(this)),this.timeVortex.historyPicker.addEventListener(wxe,this.openSettings.bind(this)),this.addEventListener(fxe,this.loadRenderedNodeIntoInspector.bind(this)),this.busPort=sessionStorage.getItem("pb33f-doctor-port"),this.busHost=sessionStorage.getItem("pb33f-doctor-host"),this.busPort||(this.busPort="443"),this.busHost||(this.busHost="doctor.pb33f.io");const d=sessionStorage.getItem("pb33f-doctor-tls");d&&d=="true"&&(this.useTLS=!0),window.addEventListener("popstate",p=>{const m=p.state;m&&(m.activeNode&&this.modelTreeNodeClicked(new CustomEvent(mB,{detail:{nodeHashId:m.activeNode,noState:!0}})),m.ref&&this.documentReferenceClicked(new CustomEvent(Oee,{detail:{jsonPath:m.ref,noState:!0}})))})}openSettings(){this.settingsComponent.open()}settingsChanged(h,c){var l;if(c){if(this.autoDiagnose=c.autoDiagnose,this.skipTimeline=c.skipTimeline,this.showDiagnosisButton=!c.autoDiagnose,this.timeVortex.historyPicker.skipChanges=c.skipTimeline,c.applicationVersion==this.currentVersion)return;this.currentVersion&&this.currentVersion!="bootstrap"&&c.applicationVersion&&c.applicationVersion!="bootstrap"&&this.currentVersion!=c.applicationVersion?(console.warn("version changed, reloading",this.currentVersion,c.applicationVersion),this.nukeWorkspaceHandler()):(c.applicationVersion=this.currentVersion,(l=this.settingsBag)==null||l.set(AE,c))}}loadRenderedNodeIntoInspector(h){const c=new uM;c.node=h.detail.renderedNode,this.renderedNode=c,this.requestUpdate(),this.viewerPanel.click()}tickRandomly(){this.randomTicker=Math.floor(Math.random()*9999999)}nukeWorkspaceHandler(){this.bagManager.resetBags(),localStorage.removeItem("pb33f-doctor-version"),Vf.resetWorkspace().then(()=>{window.location.reload()})}minimapToggled(){this.minimapVisible=!this.minimapVisible,this.editor.toggleMinimap(),this.rulesetEditor.toggleMinimap()}firstUpdated(){this.editor=this.querySelector("pb33f-editor#spec-editor"),this.rulesetEditor=this.querySelector("pb33f-editor#ruleset-editor")}whoAmI(){this.bus.publish({destination:"/p/q/"+vF,body:JSON.stringify({request:P8e.WhoAmI})})}connectToBroker(){let h="ws://";this.useTLS&&(h="wss://");const c={brokerURL:h+this.busHost+":"+this.busPort+"/ranch",heartbeatIncoming:0,heartbeatOutgoing:0,onConnect:()=>{console.log("💊 Connected to the %cOpenAPI Doctor%c, we are ready to communicate.","background: #0d1117; color: #62C4FFFF; font-weight: bold","color: default"),this.bus.mapChannels(),this.whoAmI()}};this.bus.connectToBroker(c)}addClickTrack(h){history.pushState({activeNode:h.idHash},"",`?view=explore&node=${h.idHash}`)}addRefTrack(h){history.pushState({ref:h},"",`?view=spec&ref=${h}`)}doctorServiceHandler(){return h=>{var c;((c=h.payload)==null?void 0:c.payload)!=null&&Z7t(h.payload.payload)&&(this.brokerConnectionId=h.payload.payload.broker,this.authController.associateBroker(this.brokerConnectionId).then(()=>{const l=h.payload.payload.version;l!==""&&(this.currentVersion=l);const d=localStorage.getItem("pb33f-doctor-version");if(d){if(this.currentVersion!=d){this.nukeWorkspaceHandler();return}}else localStorage.setItem("pb33f-doctor-version",this.currentVersion);console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you. [v"+l+"]","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor()}))}}startTheDoctor(){this.specChannelSubscription=this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditChannelSubscription=this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bus.mapChannelToBrokerDestination(vte+mte,mte),this.bus.mapChannelToBrokerDestination(vte+wte,wte),this.boostrap(),this.loadingOverlay.hide()}specStreamHandler(){return h=>{var c,l;if(((c=h.payload)==null?void 0:c.payload)!=null){const d=atob(h.payload.payload);this.docBag&&this.docBag.set(kM,d),(l=this.editor)==null||l.setValue(d,!0),this.requestUpdate()}}}creditStreamHandler(){return h=>{var c;((c=h.payload)==null?void 0:c.payload)!=null&&(this.creditTicker.credits=parseInt(h.payload.payload))}}filterTreeModel(h){this.filteredNodes=new Map,h.detail.graph.nodes.forEach(c=>{this.filteredNodes.set(c.id,c)}),this.modelTree.filteredNodes=this.filteredNodes,this.modelTree.renderedNodes=this.renderedNodeMap}documentReferenceClicked(h){var L,A;let c="",l,d=1,p=h.detail.jsonPath,m="",v="",C="";if(h.detail.jsonPath.includes("||")&&(c=h.detail.jsonPath.split("||")[1],p=h.detail.jsonPath.split("||")[0],l=parseInt(c.split(":")[0]),d=parseInt(c.split(":")[1]),m=h.detail.jsonPath.split("||")[2],m!=""&&(v=m.split("#")[0]),C=h.detail.jsonPath.split("||")[3]),(L=this.editor.editor)==null||L.setPosition({lineNumber:l,column:d}),(A=this.editor.editor)==null||A.revealLineInCenter(l),this.nodeIdMap.has(p)){const I=this.nodeIdMap.get(p);if(I){if(this.nodeIdHashMap.has(I.idHash)){const N=this.renderedNodeMap.get(I.id);N&&(this.renderedNode.node=N,this.modelTree.explorerClicked(I.id),h.detail.noState||this.addRefTrack(h.detail.jsonPath))}}else this.toastManager.addToastManually({id:crypto.randomUUID(),type:Rc.INFO,title:"Reference not found",body:`Something went wrong, '${p}' not found`})}else this.rolodexActivePath!=null&&this.rolodexActivePath!=v&&Vf.queryRolodex(C,v).then(I=>{var N,O;if(this.editor.showBreadcrumb=!0,this.rolodexActivePath=v,this.editor.clearDecorations(),this.editor.setValue(I.rolodexRoot.instance,!0),(N=this.editor.editor)==null||N.setPosition({lineNumber:l,column:1}),(O=this.editor.editor)==null||O.revealLineInCenter(l),this.rolodexTree.explorerClicked(C),this.editor.setCurrentPath(v),this.fetchRefMap(v),this.rolodexProblemMap.has(this.rolodexActivePath)){const j=this.rolodexProblemMap.get(this.rolodexActivePath);j&&this.editor.setMarkers(j)}}).catch(I=>{console.error("rolodex query failed",I)})}explorerReferenceClicked(h){let c="";if(this.explorer.nodeComponents.forEach(l=>{var d,p;if(l.body.node.nodePath===h.detail.nodePath){const m=this.renderedNodeMap.get(l.body.node.id);m&&((d=this.editor.editor)==null||d.setPosition({lineNumber:m.keyLine,column:0}),(p=this.editor.editor)==null||p.revealLineInCenter(m.keyLine),this.renderedNode.node=m,c=l.body.node.id,this.explorer.moveToNode(l.body.node),this.activeNode=l.body.node,this.explorer.activeNode=l.body.node,this.explorer.equalizer.activeNode=l.body.node),l.body.active=!0}else l.body.active=!1}),c&&(this.modelTree.explorerClicked(c),this.explorer.requestUpdate(),this.viewerPanel.click()),h.detail.nodePath){let l=h.detail.nodePath;!l.startsWith("/")&&!l.includes("#")&&(l=this.rolodexRootPath.substring(0,this.rolodexRootPath.lastIndexOf("/")+1)+l),l.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{path:l}}))}}rolodexTreeNodeClicked(h){var d;const c=(d=this.rolodexFilesBag)==null?void 0:d.get(ME),l=p=>{var N,O,j,q,ne,ie,re;this.rolodexActivePath=h.detail.path,this.rolodexActiveHash=h.detail.nodeHashId,this.editor.setValue(p.instance,!0),this.editor.setCurrentPath(this.rolodexActivePath),this.fetchRefMap(this.rolodexActivePath);const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m);let v="yaml";const C=(O=(N=h.detail)==null?void 0:N.path)==null?void 0:O.split(".").pop();if(C)switch(C){case Ne.JSON:v=Ne.JSON;break;case Ne.GO:v=Ne.GO;break;case Ne.PY:v="python";break;case Ne.JS:v="javascript";break;case Ne.TS:v="typescript";break;case Ne.PHP:v=Ne.PHP;break;case Ne.XML:v=Ne.XML;break;case Ne.JAVA:v=Ne.JAVA;break;case Ne.RB:v="ruby";break;case Ne.RS:v="rust";break;case Ne.C:v=Ne.C;break;case Ne.CPP:v=Ne.CPP;break;case Ne.CS:v="csharp";break;case Ne.MD:v="markdown";break}const L=(j=this.rolodexStateBag)==null?void 0:j.get(sw);if(L)L.activePath=h.detail.path,L.activeHash=h.detail.nodeHashId,L.activeLanguage=v,L.activeNode=p,L.rootPath=this.rolodexRootPath,(q=this.rolodexStateBag)==null||q.set(sw,L);else{const te={activePath:h.detail.path,activeHash:h.detail.nodeHashId,activeLanguage:v,activeNode:p,rootHash:this.rolodexRootHash,rootPath:this.rolodexRootPath};(ne=this.rolodexStateBag)==null||ne.set(sw,te)}this.editor.switchLanguage(v);let A=1,I=0;return h.detail.line&&(A=h.detail.line),h.detail.column&&(I=h.detail.column),(ie=this.editor.editor)==null||ie.setPosition({lineNumber:A,column:I}),(re=this.editor.editor)==null||re.revealLineInCenter(A,I),h.detail.path&&this.rolodexTree.openNodeByPath(h.detail.path),v};Vf.queryRolodex(h.detail.nodeHashId,h.detail.path).then(p=>{var m,v,C;if(this.editor.showBreadcrumb=!0,(m=this.referenceMapBag)==null||m.reset(),l(p.rolodexRoot),h.detail.path&&(c&&!c.files[h.detail.path]&&(c.files[h.detail.path]=p.rolodexRoot,(v=this.rolodexFilesBag)==null||v.set(ME,c)),!c)){const L={files:{[h.detail.path]:p.rolodexRoot}};(C=this.rolodexFilesBag)==null||C.set(ME,L)}})}rolodexRootFileSelected(h){var l,d,p;this.rolodexActivePath=h.detail.path,this.rolodexActiveHash=h.detail.nodeHashId,this.rolodexRootPath=h.detail.path,this.importDisabled=!0;const c=(l=this.rolodexStateBag)==null?void 0:l.get(sw);if(c)c.activePath=h.detail.path,c.activeHash=h.detail.nodeHashId,c.rootPath=h.detail.path,c.rootHash=h.detail.nodeHashId,(d=this.rolodexStateBag)==null||d.set(sw,c);else{const m={activePath:h.detail.path,activeHash:h.detail.nodeHashId,rootPath:h.detail.path,rootHash:h.detail.nodeHashId};(p=this.rolodexStateBag)==null||p.set(sw,m)}h.detail.nodeHashId&&(this.rolodexRootHash=h.detail.nodeHashId),h.detail.content&&(this.rolodexNeedsReset=!0,this.editor.setValue(h.detail.content,!0),this.lintSpec(h.detail.content))}modelTreeNodeClicked(h){var l,d,p;let c=this.nodeIdMap.get(h.detail.nodeId);if(c||(c=this.nodeIdHashMap.get(h.detail.nodeId)),c){if(c.origin&&c.origin!=this.rolodexActivePath&&c.origin!="/root.yaml"&&c.origin!="root.yaml"){let v="";const C=(l=this.rolodexFilesBag)==null?void 0:l.get(ME);C&&C.files[c.origin]&&(v=C.files[c.origin].idHash),this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{nodeHashId:v,path:c.origin}}));return}c.idHash!=="root"&&((d=this.editor.editor)==null||d.setPosition({lineNumber:c.keyLine,column:0}),(p=this.editor.editor)==null||p.revealLineInCenter(c.keyLine)),this.explorerVisible&&this.explorer.moveToNode(c,h.detail.first),this.activeNode=c,h.detail.changes&&(c.timeline=h.detail.changes),this.explorer.activeNode=c,this.explorer.equalizer.activeNode=c;const m=structuredClone(this.renderedNodeMap.get(c.id));m?(h.detail.changes&&(m.timeline=h.detail.changes),this.renderedNode.node=m):alert("no id found"),h.detail.noState||(this.addClickTrack(c),h.detail.noState=!0),this.explorerNodeClicked(h,!1),this._firstRun?this._firstRun=!1:this.viewerPanel.click()}else this.sendToast({id:crypto.randomUUID(),title:"Unable to load change model",type:Rc.WARNING,body:"There is no-longer a model with the path `"+h.detail.nodeId+"` in the document"}),console.error("cannot navigate to node, path not found",h.detail.nodeId)}explorerNodeClicked(h,c=!0){let l=!1,d;if(this.explorer.nodeComponents.forEach(p=>{if(p.id===h.detail.nodeId){let m;c&&(m=this.renderedNodeMap.get(p.id),m&&!this._firstRun&&(this.renderedNode.node=m)),this.selectedNodeHashId=p.body.node.idHash,p.body.active=!0,this.activeNode=p.body.node,this.explorer.activeNode=p.body.node,l=!0,c&&(d=m),h.detail.noState||this.addClickTrack(p.body.node)}else p.body.active=!1}),!l){const p=this.nodeIdMap.get(h.detail.nodeId);p&&(this.selectedNodeHashId=p.idHash,this.activeNode=p,this.explorer.activeNode=p,this.explorer.equalizer.activeNode=p)}d&&(this.pendingLine=d.keyLine),this.modelTree.explorerClicked(h.detail.nodeId),this._firstRun||this.viewerPanel.click(),this.explorer.requestUpdate()}exportRuleset(){this.exportRulesetDialog.show()}addToastEvent(h){this.sendToast(h.detail.toast)}sendToast(h){this.toastManager.addToastManually(h)}ruleGroupClicked(h){this.problemsPanel.focus();const c=new CustomEvent(W6e,{bubbles:!0,composed:!0,detail:{rule:h.detail.rule}});this.problemsPanel.focus(),this.problemList.dispatchEvent(c),history.pushState({rule:h.detail.rule},"",`/${Ou.Problems}?rule=${h.detail.rule}`),this.controlTabGroup.show(Ou.Problems)}ruleDocsClicked(h){var l,d,p;const c=h.detail.rule;if(c)switch(h.detail.type){case iu.RULE_DOCS:const m=(l=this.ruleDocsBag)==null?void 0:l.get(c);m?(h.detail.body=m.body,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"Rule documentation unavailable",body:`Documentation for '${c}' not available`});break;case iu.HOW_TO_FIX:const v=(d=this.howToFixBag)==null?void 0:d.get(c);v?(h.detail.body=v.howToFix,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"How to fix unavailable",body:`Information on how to fix '${c}' not available`});break;case iu.FUNCTION_DOCS:const C=(p=this.functionDocsBag)==null?void 0:p.get(c);C?(h.detail.body=C.body,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"Function documentation unavailable",body:`Documentation for '${c}' not available`});break}else switch(h.detail.type){case iu.RENDERED_EXAMPLE:case iu.MARKDOWN:this.detailsDrawer.open(h.detail)}}rulesetSaved(h){var c,l,d;if(this.docBag){const p=this.docBag.get(kM),m=(c=this.ruleConfigBag)==null?void 0:c.get(xM);if(h.detail.rules){if((l=this.customRulesetBag)==null||l.set(IE,h.detail.rules),m){const v=h.detail.config;v&&this.ruleConfigBag&&(v.returnedRuleset=h.detail.returnedRules,(d=this.ruleConfigBag)==null||d.set(xM,v))}Yf.getSessionRulesetAsYAML().then(v=>{this.selectedEditorTab=="spec"&&(this.rulesetPulse=!0),this.rulesetEditor.setValue(v,!0),this.fetchRulesetMap()}),this.lintSpec(p,"")}}}buildRolodexResultMap(h){return this.rolodexProblemMap.clear(),h.forEach(c=>{if((c.sourceLocation==="/root.yaml"||c.sourceLocation==="root.yaml")&&(c.sourceLocation="root"),this.rolodexProblemMap.has(c.sourceLocation)){const l=this.rolodexProblemMap.get(c.sourceLocation);l&&(l.push(c),c.sourceLocation?this.rolodexProblemMap.set(c.sourceLocation,l):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,l):this.rolodexProblemMap.set("root",l))}else if(c.sourceLocation)this.rolodexProblemMap.set(c.sourceLocation,[c]);else if(this.rolodexRootPath){const l=this.rolodexProblemMap.get(this.rolodexRootPath);l?(l.push(c),this.rolodexProblemMap.set(this.rolodexRootPath,l)):this.rolodexProblemMap.set(this.rolodexRootPath,[c])}else{const l=this.rolodexProblemMap.get("root");l?(l.push(c),this.rolodexProblemMap.set("root",l)):this.rolodexProblemMap.set("root",[c])}}),this.rolodexProblemMap}fetchRefMap(h=""){Vf.fetchReferenceMap().then(c=>{this.editor.clearDecorations(),this.references=c,this.editor.links=c,this.editor.applyLinkDecorations(),this.updateRefmapBag(h,c)}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.toastManager.addToastManually({id:crypto.randomUUID(),type:Rc.INFO,title:"File not analyzed",body:"This file is not a JSON or YAML file, it has not been analyzed."})})}lintSpec(h,c){var m;this.activitySpinner.show(),this.editor.breadcumb.isInvalid=!1,c?c==="root"?c="":(this.urlProblem.style.display="none",this.urlOverlay.style.display="block",this.urlSpinner.style.display="block",(m=this.referenceMapBag)==null||m.reset()):(this.urlProblem.style.display="none",this.urlOverlay.style.display="none",this.urlSpinner.style.display="none");let l=!1,d=this.rolodexActivePath;if((this.rolodexActivePath===this.rolodexRootPath||this.rolodexActivePath==="root")&&(l=!0,d="",this.editor.showBreadcrumb=!1),c&&c!="")try{const v=new URL(c);v&&(d=v.pathname,this.rolodexActivePath=d,this.rolodexRootPath=d,l=!0)}catch{}let p=!0;n8.lintFile(h,this.brokerConnectionId,c,d,this.skipTimeline).then(v=>{var L,A;this.activitySpinner.hide(),this.buildRolodexResultMap(v),c&&(this.urlOverlay.style.display="none",this.urlSpinner.style.display="none",this.urlProblem.style.display="none");let C=this.rolodexProblemMap.get("root");if(this.rolodexRoot||(C=[]),v&&!Array.isArray(v)){const I=[v];if(this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const N=this.rolodexProblemMap.get(this.rolodexActivePath);N?(C&&N.push(...C),this.editor.setMarkers(N)):(C&&I.push(...C),this.editor.setMarkers(I))}else C&&I.push(...C),this.editor.setMarkers(I);(L=this.problemBag)==null||L.set(lz,I),this.problemList.problems=I,this.problems=I,this.problemsOverview.problems=this.problemList.problemItems}if(v&&Array.isArray(v)){if(v.length==0&&(this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!1,this.editor.showBreadcrumb=!1,p=!0,this.problemList.isInvalid=!1),v.length==1&&v[0].message.startsWith("unable to parse")&&(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.setMarkers(v),this.editor.breadcumb.isInvalid=!0,this.editor.showBreadcrumb=!0,this.editor.dead(),this.problemList.isInvalid=!0,p=!1),p&&this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const I=this.rolodexProblemMap.get(this.rolodexActivePath);I?(C&&I.push(...C),this.editor.setMarkers(I)):(C&&v.push(...C),this.editor.setMarkers(v))}else if(l)this.editor.setMarkers(v);else{this.fetchRefMap(d);return}(A=this.problemBag)==null||A.set(lz,v),this.problemList.problems=v,this.problems=v,this.problemsOverview.problems=this.problemList.problemItems,this.problemsOverview.statistics&&v.length==1&&(this.problemsOverview.statistics.statistics.totalErrors=1,this.problemsOverview.statistics.statistics.overallScore=0,this.problemsOverview.statistics.evaluation="Useless",this.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+v[0].message)}if(p)this.editor.revive();else return;(this.rolodexRootPath==this.rolodexActivePath||this.rolodexActivePath=="root"||c)&&Vf.fetchLatestGraph().then(I=>{this.extractGraph(I)}),this.rolodexNeedsReset?Vf.queryRolodex().then(I=>{var O,j,q;if(this.fetchRefMap(d),this.importDisabled=!0,this.editor.showBreadcrumb=!0,this.rolodexNeedsReset=!1,I.rolodexRoot.treeExpanded=!0,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=I.rolodexRoot,this.rolodexRoot=I.rolodexRoot,this.rolodexActiveHash&&(this.rolodexTree.pendingNavigationHash=this.rolodexActiveHash),this.rolodexActivePath&&(this.rolodexTree.pendingNavigationPath=this.rolodexActivePath),(O=this.rolodexResponseBag)==null||O.set(mne,I),!((j=this.rolodexStateBag)==null?void 0:j.get(sw))){const ne={activePath:this.rolodexActivePath,rootPath:this.rolodexRootPath};(q=this.rolodexStateBag)==null||q.set(sw,ne)}this.requestUpdate()}):(this.fetchRefMap(d),this.timeVortex.tardisControl.fetchHistory()),n8.fetchStatistics().then(I=>{var N;this.problemsOverview.statistics&&this.problemsOverview.statistics.statistics.overallScore,(N=this.diagnosticBag)==null||N.set(wne,I),this.activitySpinner.hide(),(I==null?void 0:I.remainingCredit)<=10&&(this.statusBar.callsRemaining=I.remainingCredit,this.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+I.remainingCredit+" credits remaining.")),this.problemsOverview.statistics=I,this.tickRandomly()}).catch(I=>{console.error("statistics service is down",I),this.platformUnavailable(I)}),this.explorerBooted||(this.explorer.equalizer.initializeEqualizer(),this.explorerBooted=!0)}).catch(v=>{this.activitySpinner.hide(),c?this.showUrlError(v):(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),v&&(console.error(v.detail),v.instance==="https://pb33f.io/errors/no-credit-remaining"?(this.statusBar.callsRemaining=0,this.statusBar.visible=!0,this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:"Run out of credit, please authenticate for more or wait 24 hours.",title:"Credit exhausted!"})):this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:v.detail,title:"Platform Error"})))})}updateInspectorDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.inspectorPanel=this.splitPanelInspector.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{inspectorPanel:this.splitPanelInspector.position})}updateExplorerDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.explorerPanel=this.splitPanelExplorer.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{explorerPanel:this.splitPanelExplorer.position})}updateRolodexDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.rolodexPanel=this.splitPanelRolodex.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{rolodexPanel:this.splitPanelRolodex.position}),this.rolodexDividerPosition=this.splitPanelRolodex.position}updateRefmapBag(h,c){var p,m;let l=(p=this.referenceMapBag)==null?void 0:p.get(oz),d=h;l?l.references[d]=c:l={references:{[d]:c}},(m=this.referenceMapBag)==null||m.set(oz,l)}platformUnavailable(h){this.unavailable||(this.loadingOverlay.hide(),this.activitySpinner.hide(),this.errorBanner.errorTitle="The doctor is out.",h?this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because "+h.detail:this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because there is no response from the platform.",this.errorBanner.visible=!0,this.unavailable=!0,this.problemsOverview.unavailable=!0,this.controlTabGroup.show(Ou.Overview))}specClicked(h){var c,l,d;if(this.detailsDrawer.close(),this.selectedEditorTab=="spec"){let p=!1;for(let v=0;v<((c=this.problems)==null?void 0:c.length);v++)if(this.problems[v].startLineNumber===h.detail.line){this.problemList.lineClicked(h.detail.line,!0),this.controlTabGroup.show(Ou.Problems),this.sidebarClosed&&this.toggleSidebar(),p=!0;break}const m=(l=this.graphBag)==null?void 0:l.get(sz);if(m&&m.graphMap&&h.detail.line){const v=m.graphMap[h.detail.line];if(v){this.modelTree.explorerClicked(v);const C=this.renderedNodeMap.get(v);C&&(this.renderedNode.node=C),p||this.viewerPanel.click();const L=this.nodeIdHashMap.get(v);L&&(this.explorer.activeNode=L,this.explorer.equalizer.activeNode=L)}}}if(this.selectedEditorTab==Ou.Ruleset){const p=(d=this.sessionRulesetMapBag)==null?void 0:d.get(cz);if(p!=null&&p.rulesMap){for(let m=0;m<p.rulesMap.length;m++)if(p.rulesMap[m].line===h.detail.line){this.controlTabGroup.show(Ou.Ruleset),this.sidebarClosed&&this.toggleSidebar();break}}}}problemClicked(h){var d,p;this.selectedEditorTab!="spec"&&(this.editorTabGroup.show("spec"),this.selectedEditorTab="spec");let c=h.detail.problem.problemObject.sourceLocation;(c==""||c==null||c=="root")&&(c=this.rolodexRootPath);const l=Jxe(this.rolodexRoot,c);if(l){this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{nodeHashId:l.idHash,path:c,line:h.detail.problem.problemObject.startLineNumber,column:h.detail.problem.problemObject.startColumn}})),this.detailsDrawer.close(),this.rolodexTree.openNodeByPath(c);return}this.controlTabGroup.show(Ou.Problems),(d=this.editor.editor)==null||d.revealLineInCenter(h.detail.problem.line),(p=this.editor.editor)==null||p.setPosition({lineNumber:h.detail.problem.line,column:h.detail.problem.column}),this.detailsDrawer.close(),h.detail.launchedFromProblems||this.problemList.lineClicked(h.detail.problem.problemObject.startLineNumber)}loadState(){var d;if(this.graphBag=this.bagManager.getBag(sz),this.docBag=this.bagManager.getBag(YIt),this.rolodexResponseBag=this.bagManager.getBag(mne),this.rolodexFilesBag=this.bagManager.getBag(ME),this.rolodexStateBag=this.bagManager.getBag(sw),this.referenceMapBag=this.bagManager.getBag(oz),this.docExpirationBag=this.bagManager.getBag(Q7e),this.panelStateBag=this.bagManager.getBag(lm),this.settingsBag=this.bagManager.getBag(AE),(d=this.settingsBag)==null||d.onAllChanges(this.settingsChanged.bind(this)),this.settingsComponent.settingsBag=this.settingsBag,this.settingsBag&&this.settingsChanged("",this.settingsBag.get(AE)),this.settingsComponent.bootstrap(),this.rolodexResponseBag){const p=this.rolodexResponseBag.get(mne);p&&(this.rolodexRoot=p.rolodexRoot,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=p.rolodexRoot,p.rolodexRoot.treeExpanded=!0,this.requestUpdate())}let h=!1;const c=p=>{var v;let m=(v=this.referenceMapBag)==null?void 0:v.get(oz);m?setTimeout(()=>{let C=m==null?void 0:m.references[p];C||(C=m==null?void 0:m.references[""]),C&&(this.references=C,this.editor.links=C,this.editor.applyLinkDecorations())},5):Vf.fetchReferenceMap().then(C=>{this.references=C,this.editor.links=C,this.editor.applyLinkDecorations()}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers()})};if(this.rolodexStateBag){const p=this.rolodexStateBag.get(sw);p?(this.rolodexActivePath=p.activePath,this.rolodexActiveHash=p.activeHash,p.rootHash&&(this.rolodexTree.pendingNavigationHash=p.rootHash),p.rootPath&&(this.rolodexRootPath=p.rootPath,p.activePath&&c(p.activePath),Vf.selectRootPath(p.rootPath).then(()=>{}).catch(m=>{console.error("could not select the root path on boot bro",m)})),p.rootHash&&(this.rolodexRootHash=p.rootHash),p.activePath&&(this.rolodexTree.pendingNavigationPath=p.activePath,this.rolodexTree.requestUpdate()),p.activeNode&&(p.activeLanguage&&this.editor.switchLanguage(p.activeLanguage),this.editor.setValue(p.activeNode.instance,!0),h=!0)):(this.rolodexActivePath="root",c(this.rolodexActivePath))}if(this.docBag&&!h){const p=this.docBag.get(kM);p&&this.editor.setValue(p,!0)}if(this.problemBag=this.bagManager.getBag(lz),this.problemBag){const p=this.problemBag.get(lz);if(p){this.problems=p;for(let m=0;m<p.length;m++)p[m]=V2.reconstruct(p[m]);if(this.buildRolodexResultMap(p),this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m)}this.problemList.problems=p,this.problemsOverview.problems=this.problemList.problemItems}}if(this.howToFixBag=this.bagManager.getBag(ZIt),this.diagnosticBag=this.bagManager.getBag(wne),this.diagnosticBag){const p=this.diagnosticBag.get(wne);p&&(this.problemsOverview.statistics=p)}if(this.graphBag){const p=this.graphBag.get(sz);p&&this.extractGraph(p)}if(this.panelStateBag){const p=this.panelStateBag.get(lm);p&&p.explorerPanel&&(this.splitPanelExplorer.position=p.explorerPanel),p&&p.rolodexPanel&&(this.splitPanelRolodex&&(this.splitPanelRolodex.position=p.rolodexPanel),this.rolodexDividerPosition=p.rolodexPanel),p&&p.inspectorPanel&&(this.splitPanelInspector.position=p.inspectorPanel)}this.rolodexRoot?this.importDisabled=!0:this.importDisabled=!1;const l=[];if(this.defaultRulesetBag=this.bagManager.getBag(vne),this.defaultRulesetBag){const p=this.defaultRulesetBag.get(vne);p?this.defaultRuleset=p:l.push(this.fetchDefaultRuleset())}if(this.OWASPRulesetBag=this.bagManager.getBag(yne),this.OWASPRulesetBag){const p=this.OWASPRulesetBag.get(yne);p?this.OWASPRuleset=p:l.push(this.fetchOWASPRuleset())}if(this.allRulesetBag=this.bagManager.getBag(xne),this.allRulesetBag){const p=this.allRulesetBag.get(xne);p?this.allRuleset=p:l.push(this.fetchAllRuleset())}if(this.functionsBag=this.bagManager.getBag(LE),this.functionSchemaBag=this.bagManager.getBag(SE),this.functionsBag){const p=this.functionsBag.get(LE);p?this.functions=p:l.push(this.fetchFunctions())}if(this.customRulesetBag=this.bagManager.getBag(IE),this.customRulesetBag){const p=this.customRulesetBag.get(IE);p&&(this.customRuleset=p)}this.ruleConfigBag=this.bagManager.getBag(xM),this.sessionRulesetMapBag=this.bagManager.getBag(cz),Promise.all(l).then(()=>{var m;this.manageRuleset.defaultRuleset=this.defaultRuleset,this.manageRuleset.owaspRuleset=this.OWASPRuleset,this.manageRuleset.allRuleset=this.allRuleset,this.manageRuleset.functions=this.functions;const p=(m=this.ruleConfigBag)==null?void 0:m.get(xM);p?this.manageRuleset.rulesetConfig=p:this.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.manageRuleset.buildRulesets(),this.customRuleset&&this.customRuleset.rules.size>0&&(this.manageRuleset.customRuleset=this.customRuleset),this.fetchSessionRulesetAsYaml().then(v=>{var C;(C=this.rulesetEditor)==null||C.setValue(v,!0),this.fetchRulesetMap()}).catch(v=>{this.platformUnavailable(v)})},50)}),this.fetchDocs()}extractGraph(h){var l,d,p,m;h.stripped?(this.explorer.nodeLimitExceeded=!0,this.modelTree.nodeLimitExceeded=!0,h.strippedCount&&(this.explorer.nodeLimit=h.strippedCount,this.modelTree.nodeLimit=h.strippedCount)):(this.explorer.nodeLimitExceeded=!1,this.modelTree.nodeLimitExceeded=!1),this.explorer.renderedNodeMap.clear(),this.nodeMap.clear(),this.nodeIdMap.clear(),this.nodeIdHashMap.clear();const c=new Map;(l=h==null?void 0:h.nodesRendered)==null||l.forEach(v=>{this.explorer.renderedNodeMap.set(v.id,v),c.set(v.id,v)});for(let v=0;v<((d=h==null?void 0:h.nodesRendered)==null?void 0:d.length);v++)this.renderedNodeMap.set(h.nodesRendered[v].id,h.nodesRendered[v]);(p=h==null?void 0:h.nodes)==null||p.forEach(v=>{var L;this.nodeMap.set(v.id,v),v.idHash.includes("root")?(this.nodeIdMap.set("root",v),this.nodeIdHashMap.set(v.id,v)):(this.nodeIdMap.set(v.id,v),this.nodeIdHashMap.set(v.idHash,v)),v.filtered&&this.filteredNodes.set(v.id,v);const C=this.renderedNodeMap.get(v.id);((L=this.activeNode)==null?void 0:L.id)===v.id&&this.renderedNodeMap.get(v.id)&&this.renderedNode&&C&&(this.renderedNode.node=C)}),(m=this.graphBag)==null||m.set(sz,h),this.explorer.updateGraphResponse(h),h&&h.nodes&&(this.modelTree.node=h==null?void 0:h.nodesRendered[0]),this.explorer.equalizer.isInitialized()?this.explorer.equalizer.runEQ(!0):this.explorer.equalizer.initializeEqualizer(),this.timeVortex.checkHistory()}customRulesetEnabled(h){var l,d,p;const c={rules:new Map};c.id=crypto.randomUUID(),c.owner=this.authController.session.sessionId,h.detail.rules.forEach(m=>{m.rule.id!=m.ruleId&&(m.rule.id=m.ruleId),c.rules.set(m.ruleId,m.rule)}),(l=this.customRulesetBag)==null||l.set(IE,c),h.detail.ruleConfig?(d=this.ruleConfigBag)==null||d.set(xM,h.detail.ruleConfig):((p=this.ruleConfigBag)==null||p.reset(),Yf.resetSessionRuleset(h.detail.rulesetReset).then(()=>{if(this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.docBag){const m=this.docBag.get(kM);this.rolodexActivePath,this.lintSpec(m,this.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(m=>{var v;(v=this.rulesetEditor)==null||v.setValue(m,!0)})}).catch(m=>{this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:m.detail,title:"Cannot reset ruleset"})}))}async fetchSessionRulesetAsYaml(){return new Promise(async(h,c)=>{Yf.getSessionRulesetAsYAML().then(l=>{h(l)}).catch(l=>{console.error("cannot fetch session ruleset: ",l.title),c(l)})})}async fetchFunctions(){return new Promise(async h=>{Yf.getFunctions().then(c=>{var d;this.functions=c,(d=this.functionsBag)==null||d.set(LE,c);const l=[];c.forEach(p=>{l.push(this.fetchFunctionSchema(p))}),Promise.all(l).then(()=>{h(c)})})})}async fetchFunctionSchema(h){return new Promise(async c=>{Yf.getFunctionSchema(h).then(l=>{var p,m;let d=(p=this.functionSchemaBag)==null?void 0:p.get(SE);d||(d=new Map),d.set(h,l),(m=this.functionSchemaBag)==null||m.set(SE,d),c(l)})})}async fetchDefaultRuleset(){return new Promise(async h=>{Yf.getDefaultRuleset().then(c=>{var l;this.defaultRuleset=c,(l=this.defaultRulesetBag)==null||l.set(vne,c),h(c)})})}async fetchOWASPRuleset(){return new Promise(async h=>{Yf.getOWASPRuleset().then(c=>{var l;this.OWASPRuleset=c,(l=this.OWASPRulesetBag)==null||l.set(yne,c),h(c)})})}async fetchAllRuleset(){return new Promise(async h=>{Yf.getAllRuleset().then(c=>{var l;this.allRuleset=c,(l=this.allRulesetBag)==null||l.set(xne,c),h(c)})})}fetchDocs(){this.activitySpinner.show();const c=new URL(window.location.href).searchParams.get("url");c&&(this.activeURL=c,this.lintSpec("",c)),n8.fetchAllHowToFix().then(d=>{d&&d.forEach(p=>{var m;(m=this.howToFixBag)==null||m.set(p.ruleId,p)})}).catch(d=>{this.platformUnavailable(d),console.error("documentation service is down")}),this.ruleDocsBag=this.bagManager.getBag(QIt),this.functionDocsBag=this.bagManager.getBag(XIt),this.ruleDocsWorker.addEventListener("message",d=>{const p=d.data;p&&(p.forEach(m=>{var v,C;m.ruleId&&((v=this.ruleDocsBag)==null||v.set(m.ruleId,m)),m.functionId&&((C=this.functionDocsBag)==null||C.set(m.functionId,m))}),this.activitySpinner.hide())});const l=()=>{this.ruleDocsWorker.postMessage({start:!0,endpoint:this.doctorEndpoint,existingRules:[],existingFunctions:[]})};if(this.docExpirationBag){const d=this.docExpirationBag.get(Q7e);d&&(new Date().getTime(),new Date(d).getTime()),l()}else l()}fetchRulesetMap(){Yf.getSessionRulesetMap().then(h=>{var c;(c=this.sessionRulesetMapBag)==null||c.set(cz,h)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.sendToast({id:crypto.randomUUID(),type:Rc.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}ruleClicked(h){var l,d,p;const c=(l=this.sessionRulesetMapBag)==null?void 0:l.get(cz);if(c){const m=c.rulesMap.find(v=>v.ruleId===h.detail.ruleId);m&&(this.selectedEditorTab="ruleset",this.editorTabGroup.show(Ou.Ruleset),(d=this.rulesetEditor.editor)==null||d.setPosition({lineNumber:m.line,column:m.start}),(p=this.rulesetEditor.editor)==null||p.revealLineInCenter(m.line))}}builtInRulesetSelected(){}rulesetManuallyChanged(){clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{var c;const h=(c=this.rulesetEditor.editor)==null?void 0:c.getValue();Yf.validateRuleset(h).then(l=>{var p;this.manageRuleset.clearRuleProblems();let d={rules:new Map};d.id=crypto.randomUUID(),d.owner=this.authController.session.sessionId,d.rules=new Map(Object.entries(l.rules)),d.rules.forEach((m,v)=>{m.id=v}),(p=this.customRulesetBag)==null||p.set(IE,d),this.customRuleset=d,d.rules.size>0&&(this.manageRuleset.customRulesetManual=d),this.selectedEditorTab=Ou.Ruleset,this.controlTabGroup.show(Ou.Ruleset),this.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(l=>{this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:l.detail,title:l.title}),console.error("unable to validate ruleset",l);const d=l.body,p=[];d==null||d.forEach(m=>{p.push({severity:f4.MarkerSeverity.Error,message:m.ruleError,startLineNumber:m.line,startColumn:m.startCol,endLineNumber:m.line,endColumn:m.endCol})}),Yf.convertToJSON(h).then(m=>{let v={rules:new Map};v.id=crypto.randomUUID(),v.owner=this.authController.session.sessionId,v.rules=new Map(Object.entries(m.rules)),v.rules.forEach((C,L)=>{C.id!=L&&(C.id=L)}),this.customRuleset=v,v.rules.size>0&&(this.manageRuleset.customRulesetManual=v),this.rulesetEditor.setMarkers([]),this.manageRuleset.clearRuleProblems(),this.rulesetEditor.setMarkers(p),this.manageRuleset.processBadRules(d),this.controlTabGroup.show(Ou.Ruleset)}).catch(m=>{console.error("unable to convert ruleset to JSON",m)})})},this.debounceTimeRuleset)}specChanged(h){if(this.editorMap.get(h.detail.id)&&h.detail.id==="ruleset-editor"){this.rulesetManuallyChanged();return}this.docBag&&this.docBag.set(kM,h.detail.content),this.autoDiagnose&&(clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{this.lintSpec(h.detail.content)},this.debounceTime))}runDiagnostics(){this.autoDiagnose||this.lintSpec(this.editor.getValue())}boostrap(){const c=new URL(window.location.href).searchParams.get("url");if(c){this.activeURL=c,this.lintSpec("",c);return}setTimeout(()=>{var d;this.timeVortex.doctor=this,this.timeVortex.checkHistory(),((d=this.docBag)==null?void 0:d.get(kM))||n8.bootstrapEditor().then(p=>{this.editor.setValue(p,!0),this.rolodexActivePath="",this.specChanged(new CustomEvent(Aee,{detail:{content:p,id:"spec"}}))})},200)}exportJSON(){let h;if(this.ruleConfigBag){const c=this.ruleConfigBag.get(xM);c&&c.returnedRuleset&&(h=c.returnedRuleset)}if(h){let c="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(h,null,2));this.downloadRulesetLink.download="ruleset.json",this.downloadRulesetLink.href=c,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()}}exportYAML(){Yf.getSessionRulesetAsYAML().then(h=>{let c="data:text/yaml;charset=utf-8,"+encodeURIComponent(h);this.downloadRulesetLink.download="ruleset.yaml",this.downloadRulesetLink.href=c,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()})}confirmExport(){switch(this.exportSelection.value){case"json":this.exportJSON();break;case"yaml":this.exportYAML();break}}closeWelcome(){this.welcomeBox.hide(),localStorage.setItem("pb33f-doctor-welcome","closed")}selectEditorTab(h){switch(this.selectedEditorTab=h.detail.name,h.detail.name){case Ou.Ruleset:this.rulesetPulse&&(this.rulesetPulse=!1),this.controlTabGroup.show(Ou.Ruleset);break}}selectControlTab(h){switch(h.detail.name){case Ou.Problems:case Ou.Overview:break;case Ou.Ruleset:this.selectedEditorTab!=Ou.Ruleset&&(this.editorTabGroup.show(Ou.Ruleset),this.selectedEditorTab=Ou.Ruleset);break}}toggleSidebar(){var c;const h=(c=this.shadowRoot)==null?void 0:c.querySelector("sl-split-panel.split-panel");this.sidebarClosed?h&&(this.collapseButton.name="chevron-bar-right",h.style.setProperty("--min","600px"),h.style.setProperty("--max","calc(100vw - 600px)"),h.position=60,h.disabled=!1,this.problemsDataDiv.style.display="block",this.splitDivider.style.display="block",this.activitySpinner.classList.remove("spinner-draw-closed")):h&&(this.collapseButton.name="chevron-bar-left",this.problemsDataDiv.style.display="none",h.style.setProperty("--min","40px"),h.style.setProperty("--max","calc(100vw - 40px)"),h.position=99,h.disabled=!0,this.splitDivider.style.display="none",this.activitySpinner.classList.add("spinner-draw-closed")),this.sidebarClosed=!this.sidebarClosed}showHistory(){this.closeExplorer(),this.hideMinimapIcon(),this.requestUpdate()}toggleExplorer(){this.explorerVisible=!this.explorerVisible,this.explorerVisible&&this.activeNode&&this.explorer.moveToNode(this.activeNode),this.hideMinimapIcon(),this.showDiagnosisButton=!1,this.explorerBooted=!0,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&this.sendToast({id:crypto.randomUUID(),type:Rc.WARNING,body:"Safari is not supported by the explorer. Please use Chrome, Firefox or Edge. As you can see the icons are all messed up.",title:"Safari Warning"})}hideMinimapIcon(){this.minimapIconVisible=!1}hideDiagnosisButton(){this.showDiagnosisButton=!1}enableDiagnosisButton(){this.autoDiagnose||(this.showDiagnosisButton=!0)}showMinimapIcon(){this.minimapIconVisible=!0}closeExplorer(){this.explorerVisible=!1,this.showMinimapIcon(),this.showDiagnosisButton=!0,setTimeout(()=>{var h,c;this.pendingLine>0&&((h=this.editor.editor)==null||h.setPosition({lineNumber:this.pendingLine,column:1}),(c=this.editor.editor)==null||c.revealLineInCenter(this.pendingLine),this.pendingLine=0)},20)}render(){var v;let h=E.html``;this.unavailable&&(h=E.html`
|
|
12033
|
+
</sl-dialog>`}};yM.styles=[qIt,PP,Od],bne([V.query("sl-dialog")],yM.prototype,"dialog",2),bne([V.state()],yM.prototype,"settings",2),yM=bne([V.customElement("pb33f-doctor-settings")],yM);var WIt=Object.defineProperty,VIt=Object.getOwnPropertyDescriptor,xo=(h,c,l,d)=>{for(var p=d>1?void 0:d?VIt(c,l):c,m=h.length-1,v;m>=0;m--)(v=h[m])&&(p=(d?v(c,l,p):v(p))||p);return d&&p&&WIt(c,l,p),p};const sz="pb33f-doctor-graph",lm="pb33f-doctor-panel-state",mne="pb33f-doctor-rolodex-response",ME="pb33f-doctor-rolodex-files",sw="pb33f-doctor-rolodex-state",oz="pb33f-doctor-reference-map",YIt="pb33f-doctor-editor",ZIt="pb33f-doctor-howtofix",XIt="pb33f-doctor-funcdocs",Q7e="pb33f-doctor-doc-expiration",QIt="pb33f-doctor-ruledocs",wne="pb33f-doctor-diagnostic",vne="pb33f-doctor-default-ruleset",yne="pb33f-doctor-owasp-ruleset",xne="pb33f-doctor-all-ruleset",LE="pb33f-doctor-functions",SE="pb33f-doctor-function-schema",IE="pb33f-doctor-custom-ruleset",xM="pb33f-doctor-rule-configuration",cz="pb33f-doctor-session-rulesetmap",AE="pb33f-doctor-settings",kM="pb33f-doctor-document",lz="pb33f-doctor-problems",JIt="doctor-endpoint";let no=class extends E.LitElement{constructor(h="https://doctor.pb33f.io"){super(),this.debounceTime=1e3,this.debounceTimeRuleset=900,this.bounceId=0,this.useTLS=!1,this.rolodexDividerPosition=40,this._firstRun=!0;const c=sessionStorage.getItem(JIt);c?this.doctorEndpoint=c:this.doctorEndpoint=h,n8.doctorEndpoint=this.doctorEndpoint,SB.doctorEndpoint=this.doctorEndpoint,Yf.doctorEndpoint=this.doctorEndpoint,Vf.doctorEndpoint=this.doctorEndpoint,dP.doctorEndpoint=this.doctorEndpoint,dM.doctorEndpoint=this.doctorEndpoint,this.timeVortex=new CE,this.bus=i7t(),this.doctorServiceChannel=this.bus.createChannel(vF),this.specStreamChannel=this.bus.createChannel(mte),this.creditStreamChannel=this.bus.createChannel(wte),this.bus.mapChannelToBrokerDestination(vte+vF,vF),this.doctorChannelSubscription=this.doctorServiceChannel.subscribe(this.doctorServiceHandler()),this.bagManager=Vxe(!0),this.bagManager.loadStatefulBags().then(this.loadState.bind(this)),this.editor=new Gp,this.uploadArchive=new O1,this.nukeWorkspace=new hM,this.rulesetEditor=new Gp("ruleset-editor"),this.problemList=new CP,this.detailsDrawer=new XC,this.problemsOverview=new w4,this.errorBanner=new i8,this.statusBar=new r8,this.ruleDocsWorker=new mxt,this.unavailable=!1,this.feedback=new v4,this.activitySpinner=new IB,this.manageRuleset=new Wp,this.toastManager=new EB,this.creditTicker=new I4,this.settingsComponent=new yM,this.editorMap=new Map,this.editorMap.set("spec",this.editor),this.editorMap.set("ruleset-editor",this.rulesetEditor),this.selectedEditorTab="spec",this.sidebarClosed=!1,this.explorerVisible=!1,this.explorerBooted=!1,this.rolodexNeedsReset=!1,this.rolodexProblemMap=new Map,this.rolodexRootHash="",this.rolodexRootPath="",this.importDisabled=!1,this.pendingLine=0,this.autoDiagnose=!0,this.skipTimeline=!1,this.nodeMap=new Map,this.nodeIdMap=new Map,this.nodeIdHashMap=new Map,this.renderedNodeMap=new Map,this.filteredNodes=new Map,this.modelTree=new fg(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexTree=new fg(this.nodeMap,this.nodeIdMap,this.nodeIdHashMap),this.rolodexActiveHash="",this.explorer=new pg,this.renderedNode=new uM,this.references=[],this.minimapVisible=!0,this.minimapIconVisible=!0,this.showDiagnosisButton=!1,this.nodeLimit=150,this.randomTicker=0;const l=p=>{p.creditsRemaining?this.creditTicker.credits=p.creditsRemaining:this.creditTicker.credits=p.creditsRemaining,this.creditTicker.visible=!0,this.connectToBroker()};this.authController=new vxe(this,l,!0),this.addEventListener(Aee,this.specChanged),this.addEventListener(H6e,this.specClicked),this.addEventListener(gB,this.problemClicked),this.addEventListener(Wf,this.ruleDocsClicked),this.addEventListener(Y6e,this.ruleGroupClicked),this.addEventListener(Pee,this.customRulesetEnabled),this.addEventListener(Eee,this.rulesetSaved),this.addEventListener(W2,this.addToastEvent),this.addEventListener(exe,this.exportRuleset),this.addEventListener(J6e,this.ruleClicked),this.addEventListener(bB,this.builtInRulesetSelected),this.addEventListener(X3,this.modelTreeNodeClicked),this.addEventListener(fP,this.rolodexTreeNodeClicked),this.addEventListener(nxe,this.rolodexRootFileSelected),this.addEventListener($ee,this.explorerReferenceClicked),this.addEventListener(mB,this.explorerNodeClicked.bind(this)),this.addEventListener(hxe,this.fetchUrl.bind(this)),this.addEventListener(Oee,this.documentReferenceClicked.bind(this)),this.explorer.equalizer.addEventListener(Dee,this.filterTreeModel.bind(this)),this.explorer.equalizer.addEventListener(Tee,this.filterTreeModel.bind(this)),this.nukeWorkspace.addEventListener(dxe,this.nukeWorkspaceHandler.bind(this)),this.timeVortex.historyPicker.addEventListener(wxe,this.openSettings.bind(this)),this.addEventListener(fxe,this.loadRenderedNodeIntoInspector.bind(this)),this.busPort=sessionStorage.getItem("pb33f-doctor-port"),this.busHost=sessionStorage.getItem("pb33f-doctor-host"),this.busPort||(this.busPort="443"),this.busHost||(this.busHost="doctor.pb33f.io");const d=sessionStorage.getItem("pb33f-doctor-tls");d&&d=="true"&&(this.useTLS=!0),window.addEventListener("popstate",p=>{const m=p.state;m&&(m.activeNode&&this.modelTreeNodeClicked(new CustomEvent(mB,{detail:{nodeHashId:m.activeNode,noState:!0}})),m.ref&&this.documentReferenceClicked(new CustomEvent(Oee,{detail:{jsonPath:m.ref,noState:!0}})))})}openSettings(){this.settingsComponent.open()}settingsChanged(h,c){var l;if(c){if(this.autoDiagnose=c.autoDiagnose,this.skipTimeline=c.skipTimeline,this.showDiagnosisButton=!c.autoDiagnose,this.timeVortex.historyPicker.skipChanges=c.skipTimeline,c.applicationVersion==this.currentVersion)return;this.currentVersion&&this.currentVersion!="bootstrap"&&c.applicationVersion&&c.applicationVersion!="bootstrap"&&this.currentVersion!=c.applicationVersion?(console.warn("version changed, reloading",this.currentVersion,c.applicationVersion),this.nukeWorkspaceHandler()):(c.applicationVersion=this.currentVersion,(l=this.settingsBag)==null||l.set(AE,c))}}loadRenderedNodeIntoInspector(h){const c=new uM;c.node=h.detail.renderedNode,this.renderedNode=c,this.requestUpdate(),this.viewerPanel.click()}tickRandomly(){this.randomTicker=Math.floor(Math.random()*9999999)}nukeWorkspaceHandler(){this.bagManager.resetBags(),localStorage.removeItem("pb33f-doctor-version"),Vf.resetWorkspace().then(()=>{window.location.reload()})}minimapToggled(){this.minimapVisible=!this.minimapVisible,this.editor.toggleMinimap(),this.rulesetEditor.toggleMinimap()}firstUpdated(){this.editor=this.querySelector("pb33f-editor#spec-editor"),this.rulesetEditor=this.querySelector("pb33f-editor#ruleset-editor")}whoAmI(){this.bus.publish({destination:"/p/q/"+vF,body:JSON.stringify({request:P8e.WhoAmI})})}connectToBroker(){let h="ws://";this.useTLS&&(h="wss://");const c={brokerURL:h+this.busHost+":"+this.busPort+"/ranch",heartbeatIncoming:0,heartbeatOutgoing:0,onConnect:()=>{console.log("💊 Connected to the %cOpenAPI Doctor%c, we are ready to communicate.","background: #0d1117; color: #62C4FFFF; font-weight: bold","color: default"),this.bus.mapChannels(),this.whoAmI()}};this.bus.connectToBroker(c)}addClickTrack(h){history.pushState({activeNode:h.idHash},"",`?view=explore&node=${h.idHash}`)}addRefTrack(h){history.pushState({ref:h},"",`?view=spec&ref=${h}`)}doctorServiceHandler(){return h=>{var c;((c=h.payload)==null?void 0:c.payload)!=null&&Z7t(h.payload.payload)&&(this.brokerConnectionId=h.payload.payload.broker,this.authController.associateBroker(this.brokerConnectionId).then(()=>{const l=h.payload.payload.version;l!==""&&(this.currentVersion=l);const d=localStorage.getItem("pb33f-doctor-version");if(d){if(this.currentVersion!=d){this.nukeWorkspaceHandler();return}}else localStorage.setItem("pb33f-doctor-version",this.currentVersion);console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you. [v"+l+"]","color: #62C4FFFF; font-weight: bold","color: default"),this.startTheDoctor()}))}}startTheDoctor(){this.specChannelSubscription=this.specStreamChannel.subscribe(this.specStreamHandler()),this.creditChannelSubscription=this.creditStreamChannel.subscribe(this.creditStreamHandler()),this.bus.mapChannelToBrokerDestination(vte+mte,mte),this.bus.mapChannelToBrokerDestination(vte+wte,wte),this.boostrap()}specStreamHandler(){return h=>{var c,l;if(((c=h.payload)==null?void 0:c.payload)!=null){const d=atob(h.payload.payload);this.docBag&&this.docBag.set(kM,d),(l=this.editor)==null||l.setValue(d,!0),this.requestUpdate()}}}creditStreamHandler(){return h=>{var c;((c=h.payload)==null?void 0:c.payload)!=null&&(this.creditTicker.credits=parseInt(h.payload.payload))}}filterTreeModel(h){this.filteredNodes=new Map,h.detail.graph.nodes.forEach(c=>{this.filteredNodes.set(c.id,c)}),this.modelTree.filteredNodes=this.filteredNodes,this.modelTree.renderedNodes=this.renderedNodeMap}documentReferenceClicked(h){var L,A;let c="",l,d=1,p=h.detail.jsonPath,m="",v="",C="";if(h.detail.jsonPath.includes("||")&&(c=h.detail.jsonPath.split("||")[1],p=h.detail.jsonPath.split("||")[0],l=parseInt(c.split(":")[0]),d=parseInt(c.split(":")[1]),m=h.detail.jsonPath.split("||")[2],m!=""&&(v=m.split("#")[0]),C=h.detail.jsonPath.split("||")[3]),(L=this.editor.editor)==null||L.setPosition({lineNumber:l,column:d}),(A=this.editor.editor)==null||A.revealLineInCenter(l),this.nodeIdMap.has(p)){const I=this.nodeIdMap.get(p);if(I){if(this.nodeIdHashMap.has(I.idHash)){const N=this.renderedNodeMap.get(I.id);N&&(this.renderedNode.node=N,this.modelTree.explorerClicked(I.id),h.detail.noState||this.addRefTrack(h.detail.jsonPath))}}else this.toastManager.addToastManually({id:crypto.randomUUID(),type:Rc.INFO,title:"Reference not found",body:`Something went wrong, '${p}' not found`})}else this.rolodexActivePath!=null&&this.rolodexActivePath!=v&&Vf.queryRolodex(C,v).then(I=>{var N,O;if(this.editor.showBreadcrumb=!0,this.rolodexActivePath=v,this.editor.clearDecorations(),this.editor.setValue(I.rolodexRoot.instance,!0),(N=this.editor.editor)==null||N.setPosition({lineNumber:l,column:1}),(O=this.editor.editor)==null||O.revealLineInCenter(l),this.rolodexTree.explorerClicked(C),this.editor.setCurrentPath(v),this.fetchRefMap(v),this.rolodexProblemMap.has(this.rolodexActivePath)){const j=this.rolodexProblemMap.get(this.rolodexActivePath);j&&this.editor.setMarkers(j)}}).catch(I=>{console.error("rolodex query failed",I)})}explorerReferenceClicked(h){let c="";if(this.explorer.nodeComponents.forEach(l=>{var d,p;if(l.body.node.nodePath===h.detail.nodePath){const m=this.renderedNodeMap.get(l.body.node.id);m&&((d=this.editor.editor)==null||d.setPosition({lineNumber:m.keyLine,column:0}),(p=this.editor.editor)==null||p.revealLineInCenter(m.keyLine),this.renderedNode.node=m,c=l.body.node.id,this.explorer.moveToNode(l.body.node),this.activeNode=l.body.node,this.explorer.activeNode=l.body.node,this.explorer.equalizer.activeNode=l.body.node),l.body.active=!0}else l.body.active=!1}),c&&(this.modelTree.explorerClicked(c),this.explorer.requestUpdate(),this.viewerPanel.click()),h.detail.nodePath){let l=h.detail.nodePath;!l.startsWith("/")&&!l.includes("#")&&(l=this.rolodexRootPath.substring(0,this.rolodexRootPath.lastIndexOf("/")+1)+l),l.startsWith("#/")||this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{path:l}}))}}rolodexTreeNodeClicked(h){var d;const c=(d=this.rolodexFilesBag)==null?void 0:d.get(ME),l=p=>{var N,O,j,q,ne,ie,re;this.rolodexActivePath=h.detail.path,this.rolodexActiveHash=h.detail.nodeHashId,this.editor.setValue(p.instance,!0),this.editor.setCurrentPath(this.rolodexActivePath),this.fetchRefMap(this.rolodexActivePath);const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m);let v="yaml";const C=(O=(N=h.detail)==null?void 0:N.path)==null?void 0:O.split(".").pop();if(C)switch(C){case Ne.JSON:v=Ne.JSON;break;case Ne.GO:v=Ne.GO;break;case Ne.PY:v="python";break;case Ne.JS:v="javascript";break;case Ne.TS:v="typescript";break;case Ne.PHP:v=Ne.PHP;break;case Ne.XML:v=Ne.XML;break;case Ne.JAVA:v=Ne.JAVA;break;case Ne.RB:v="ruby";break;case Ne.RS:v="rust";break;case Ne.C:v=Ne.C;break;case Ne.CPP:v=Ne.CPP;break;case Ne.CS:v="csharp";break;case Ne.MD:v="markdown";break}const L=(j=this.rolodexStateBag)==null?void 0:j.get(sw);if(L)L.activePath=h.detail.path,L.activeHash=h.detail.nodeHashId,L.activeLanguage=v,L.activeNode=p,L.rootPath=this.rolodexRootPath,(q=this.rolodexStateBag)==null||q.set(sw,L);else{const te={activePath:h.detail.path,activeHash:h.detail.nodeHashId,activeLanguage:v,activeNode:p,rootHash:this.rolodexRootHash,rootPath:this.rolodexRootPath};(ne=this.rolodexStateBag)==null||ne.set(sw,te)}this.editor.switchLanguage(v);let A=1,I=0;return h.detail.line&&(A=h.detail.line),h.detail.column&&(I=h.detail.column),(ie=this.editor.editor)==null||ie.setPosition({lineNumber:A,column:I}),(re=this.editor.editor)==null||re.revealLineInCenter(A,I),h.detail.path&&this.rolodexTree.openNodeByPath(h.detail.path),v};Vf.queryRolodex(h.detail.nodeHashId,h.detail.path).then(p=>{var m,v,C;if(this.editor.showBreadcrumb=!0,(m=this.referenceMapBag)==null||m.reset(),l(p.rolodexRoot),h.detail.path&&(c&&!c.files[h.detail.path]&&(c.files[h.detail.path]=p.rolodexRoot,(v=this.rolodexFilesBag)==null||v.set(ME,c)),!c)){const L={files:{[h.detail.path]:p.rolodexRoot}};(C=this.rolodexFilesBag)==null||C.set(ME,L)}})}rolodexRootFileSelected(h){var l,d,p;this.rolodexActivePath=h.detail.path,this.rolodexActiveHash=h.detail.nodeHashId,this.rolodexRootPath=h.detail.path,this.importDisabled=!0;const c=(l=this.rolodexStateBag)==null?void 0:l.get(sw);if(c)c.activePath=h.detail.path,c.activeHash=h.detail.nodeHashId,c.rootPath=h.detail.path,c.rootHash=h.detail.nodeHashId,(d=this.rolodexStateBag)==null||d.set(sw,c);else{const m={activePath:h.detail.path,activeHash:h.detail.nodeHashId,rootPath:h.detail.path,rootHash:h.detail.nodeHashId};(p=this.rolodexStateBag)==null||p.set(sw,m)}h.detail.nodeHashId&&(this.rolodexRootHash=h.detail.nodeHashId),h.detail.content&&(this.rolodexNeedsReset=!0,this.editor.setValue(h.detail.content,!0),this.lintSpec(h.detail.content))}modelTreeNodeClicked(h){var l,d,p;let c=this.nodeIdMap.get(h.detail.nodeId);if(c||(c=this.nodeIdHashMap.get(h.detail.nodeId)),c){if(c.origin&&c.origin!=this.rolodexActivePath&&c.origin!="/root.yaml"&&c.origin!="root.yaml"){let v="";const C=(l=this.rolodexFilesBag)==null?void 0:l.get(ME);C&&C.files[c.origin]&&(v=C.files[c.origin].idHash),this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{nodeHashId:v,path:c.origin}}));return}c.idHash!=="root"&&((d=this.editor.editor)==null||d.setPosition({lineNumber:c.keyLine,column:0}),(p=this.editor.editor)==null||p.revealLineInCenter(c.keyLine)),this.explorerVisible&&this.explorer.moveToNode(c,h.detail.first),this.activeNode=c,h.detail.changes&&(c.timeline=h.detail.changes),this.explorer.activeNode=c,this.explorer.equalizer.activeNode=c;const m=structuredClone(this.renderedNodeMap.get(c.id));m?(h.detail.changes&&(m.timeline=h.detail.changes),this.renderedNode.node=m):alert("no id found"),h.detail.noState||(this.addClickTrack(c),h.detail.noState=!0),this.explorerNodeClicked(h,!1),this._firstRun?this._firstRun=!1:this.viewerPanel.click()}else this.sendToast({id:crypto.randomUUID(),title:"Unable to load change model",type:Rc.WARNING,body:"There is no-longer a model with the path `"+h.detail.nodeId+"` in the document"}),console.error("cannot navigate to node, path not found",h.detail.nodeId)}explorerNodeClicked(h,c=!0){let l=!1,d;if(this.explorer.nodeComponents.forEach(p=>{if(p.id===h.detail.nodeId){let m;c&&(m=this.renderedNodeMap.get(p.id),m&&!this._firstRun&&(this.renderedNode.node=m)),this.selectedNodeHashId=p.body.node.idHash,p.body.active=!0,this.activeNode=p.body.node,this.explorer.activeNode=p.body.node,l=!0,c&&(d=m),h.detail.noState||this.addClickTrack(p.body.node)}else p.body.active=!1}),!l){const p=this.nodeIdMap.get(h.detail.nodeId);p&&(this.selectedNodeHashId=p.idHash,this.activeNode=p,this.explorer.activeNode=p,this.explorer.equalizer.activeNode=p)}d&&(this.pendingLine=d.keyLine),this.modelTree.explorerClicked(h.detail.nodeId),this._firstRun||this.viewerPanel.click(),this.explorer.requestUpdate()}exportRuleset(){this.exportRulesetDialog.show()}addToastEvent(h){this.sendToast(h.detail.toast)}sendToast(h){this.toastManager.addToastManually(h)}ruleGroupClicked(h){this.problemsPanel.focus();const c=new CustomEvent(W6e,{bubbles:!0,composed:!0,detail:{rule:h.detail.rule}});this.problemsPanel.focus(),this.problemList.dispatchEvent(c),history.pushState({rule:h.detail.rule},"",`/${Ou.Problems}?rule=${h.detail.rule}`),this.controlTabGroup.show(Ou.Problems)}ruleDocsClicked(h){var l,d,p;const c=h.detail.rule;if(c)switch(h.detail.type){case iu.RULE_DOCS:const m=(l=this.ruleDocsBag)==null?void 0:l.get(c);m?(h.detail.body=m.body,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"Rule documentation unavailable",body:`Documentation for '${c}' not available`});break;case iu.HOW_TO_FIX:const v=(d=this.howToFixBag)==null?void 0:d.get(c);v?(h.detail.body=v.howToFix,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"How to fix unavailable",body:`Information on how to fix '${c}' not available`});break;case iu.FUNCTION_DOCS:const C=(p=this.functionDocsBag)==null?void 0:p.get(c);C?(h.detail.body=C.body,this.detailsDrawer.open(h.detail)):this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,title:"Function documentation unavailable",body:`Documentation for '${c}' not available`});break}else switch(h.detail.type){case iu.RENDERED_EXAMPLE:case iu.MARKDOWN:this.detailsDrawer.open(h.detail)}}rulesetSaved(h){var c,l,d;if(this.docBag){const p=this.docBag.get(kM),m=(c=this.ruleConfigBag)==null?void 0:c.get(xM);if(h.detail.rules){if((l=this.customRulesetBag)==null||l.set(IE,h.detail.rules),m){const v=h.detail.config;v&&this.ruleConfigBag&&(v.returnedRuleset=h.detail.returnedRules,(d=this.ruleConfigBag)==null||d.set(xM,v))}Yf.getSessionRulesetAsYAML().then(v=>{this.selectedEditorTab=="spec"&&(this.rulesetPulse=!0),this.rulesetEditor.setValue(v,!0),this.fetchRulesetMap()}),this.lintSpec(p,"")}}}buildRolodexResultMap(h){return this.rolodexProblemMap.clear(),h.forEach(c=>{if((c.sourceLocation==="/root.yaml"||c.sourceLocation==="root.yaml")&&(c.sourceLocation="root"),this.rolodexProblemMap.has(c.sourceLocation)){const l=this.rolodexProblemMap.get(c.sourceLocation);l&&(l.push(c),c.sourceLocation?this.rolodexProblemMap.set(c.sourceLocation,l):this.rolodexRootPath?this.rolodexProblemMap.set(this.rolodexRootPath,l):this.rolodexProblemMap.set("root",l))}else if(c.sourceLocation)this.rolodexProblemMap.set(c.sourceLocation,[c]);else if(this.rolodexRootPath){const l=this.rolodexProblemMap.get(this.rolodexRootPath);l?(l.push(c),this.rolodexProblemMap.set(this.rolodexRootPath,l)):this.rolodexProblemMap.set(this.rolodexRootPath,[c])}else{const l=this.rolodexProblemMap.get("root");l?(l.push(c),this.rolodexProblemMap.set("root",l)):this.rolodexProblemMap.set("root",[c])}}),this.rolodexProblemMap}fetchRefMap(h=""){Vf.fetchReferenceMap().then(c=>{this.editor.clearDecorations(),this.references=c,this.editor.links=c,this.editor.applyLinkDecorations(),this.updateRefmapBag(h,c)}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.toastManager.addToastManually({id:crypto.randomUUID(),type:Rc.INFO,title:"File not analyzed",body:"This file is not a JSON or YAML file, it has not been analyzed."})})}lintSpec(h,c){var m;this.activitySpinner.show(),this.editor.breadcumb.isInvalid=!1,c?c==="root"?c="":(this.urlProblem.style.display="none",this.urlOverlay.style.display="block",this.urlSpinner.style.display="block",(m=this.referenceMapBag)==null||m.reset()):(this.urlProblem.style.display="none",this.urlOverlay.style.display="none",this.urlSpinner.style.display="none");let l=!1,d=this.rolodexActivePath;if((this.rolodexActivePath===this.rolodexRootPath||this.rolodexActivePath==="root")&&(l=!0,d="",this.editor.showBreadcrumb=!1),c&&c!="")try{const v=new URL(c);v&&(d=v.pathname,this.rolodexActivePath=d,this.rolodexRootPath=d,l=!0)}catch{}let p=!0;n8.lintFile(h,this.brokerConnectionId,c,d,this.skipTimeline).then(v=>{var L,A;this.activitySpinner.hide(),this.buildRolodexResultMap(v),c&&(this.urlOverlay.style.display="none",this.urlSpinner.style.display="none",this.urlProblem.style.display="none");let C=this.rolodexProblemMap.get("root");if(this.rolodexRoot||(C=[]),v&&!Array.isArray(v)){const I=[v];if(this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const N=this.rolodexProblemMap.get(this.rolodexActivePath);N?(C&&N.push(...C),this.editor.setMarkers(N)):(C&&I.push(...C),this.editor.setMarkers(I))}else C&&I.push(...C),this.editor.setMarkers(I);(L=this.problemBag)==null||L.set(lz,I),this.problemList.problems=I,this.problems=I,this.problemsOverview.problems=this.problemList.problemItems}if(v&&Array.isArray(v)){if(v.length==0&&(this.editor.clearAllMarkers(),this.editor.breadcumb.isInvalid=!1,this.editor.showBreadcrumb=!1,p=!0,this.problemList.isInvalid=!1),v.length==1&&v[0].message.startsWith("unable to parse")&&(this.editor.clearDecorations(),this.editor.clearAllMarkers(),this.editor.setMarkers(v),this.editor.breadcumb.isInvalid=!0,this.editor.showBreadcrumb=!0,this.editor.dead(),this.problemList.isInvalid=!0,p=!1),p&&this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const I=this.rolodexProblemMap.get(this.rolodexActivePath);I?(C&&I.push(...C),this.editor.setMarkers(I)):(C&&v.push(...C),this.editor.setMarkers(v))}else if(l)this.editor.setMarkers(v);else{this.fetchRefMap(d);return}(A=this.problemBag)==null||A.set(lz,v),this.problemList.problems=v,this.problems=v,this.problemsOverview.problems=this.problemList.problemItems,this.problemsOverview.statistics&&v.length==1&&(this.problemsOverview.statistics.statistics.totalErrors=1,this.problemsOverview.statistics.statistics.overallScore=0,this.problemsOverview.statistics.evaluation="Useless",this.problemsOverview.statistics.diagnosis="<strong>Specification cannot be used</strong>: <br/><br/>"+v[0].message)}if(p)this.editor.revive();else return;(this.rolodexRootPath==this.rolodexActivePath||this.rolodexActivePath=="root"||c)&&Vf.fetchLatestGraph().then(I=>{this.extractGraph(I)}),this.rolodexNeedsReset?Vf.queryRolodex().then(I=>{var O,j,q;if(this.fetchRefMap(d),this.importDisabled=!0,this.editor.showBreadcrumb=!0,this.rolodexNeedsReset=!1,I.rolodexRoot.treeExpanded=!0,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=I.rolodexRoot,this.rolodexRoot=I.rolodexRoot,this.rolodexActiveHash&&(this.rolodexTree.pendingNavigationHash=this.rolodexActiveHash),this.rolodexActivePath&&(this.rolodexTree.pendingNavigationPath=this.rolodexActivePath),(O=this.rolodexResponseBag)==null||O.set(mne,I),!((j=this.rolodexStateBag)==null?void 0:j.get(sw))){const ne={activePath:this.rolodexActivePath,rootPath:this.rolodexRootPath};(q=this.rolodexStateBag)==null||q.set(sw,ne)}this.requestUpdate()}):(this.fetchRefMap(d),this.timeVortex.tardisControl.fetchHistory()),n8.fetchStatistics().then(I=>{var N;this.problemsOverview.statistics&&this.problemsOverview.statistics.statistics.overallScore,(N=this.diagnosticBag)==null||N.set(wne,I),this.activitySpinner.hide(),(I==null?void 0:I.remainingCredit)<=10&&(this.statusBar.callsRemaining=I.remainingCredit,this.statusBar.visible=!0,console.warn("You are running low on credit, you will need to authenticate soon. "+I.remainingCredit+" credits remaining.")),this.problemsOverview.statistics=I,this.tickRandomly()}).catch(I=>{console.error("statistics service is down",I),this.platformUnavailable(I)}),this.explorerBooted||(this.explorer.equalizer.initializeEqualizer(),this.explorerBooted=!0)}).catch(v=>{this.activitySpinner.hide(),c?this.showUrlError(v):(console.error("so sorry, the doctor cannot see you right now, the clinic is closed."),v&&(console.error(v.detail),v.instance==="https://pb33f.io/errors/no-credit-remaining"?(this.statusBar.callsRemaining=0,this.statusBar.visible=!0,this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:"Run out of credit, please authenticate for more or wait 24 hours.",title:"Credit exhausted!"})):this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:v.detail,title:"Platform Error"})))})}updateInspectorDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.inspectorPanel=this.splitPanelInspector.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{inspectorPanel:this.splitPanelInspector.position})}updateExplorerDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.explorerPanel=this.splitPanelExplorer.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{explorerPanel:this.splitPanelExplorer.position})}updateRolodexDivider(){var c,l,d;const h=(c=this.panelStateBag)==null?void 0:c.get(lm);h?(h.rolodexPanel=this.splitPanelRolodex.position,(l=this.panelStateBag)==null||l.set(lm,h)):(d=this.panelStateBag)==null||d.set(lm,{rolodexPanel:this.splitPanelRolodex.position}),this.rolodexDividerPosition=this.splitPanelRolodex.position}updateRefmapBag(h,c){var p,m;let l=(p=this.referenceMapBag)==null?void 0:p.get(oz),d=h;l?l.references[d]=c:l={references:{[d]:c}},(m=this.referenceMapBag)==null||m.set(oz,l)}platformUnavailable(h){this.unavailable||(this.loadingOverlay.hide(),this.activitySpinner.hide(),this.errorBanner.errorTitle="The doctor is out.",h?this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because "+h.detail:this.errorBanner.errorMessage="The clinic is <strong>closed!</strong> The doctor is currently unavailable because there is no response from the platform.",this.errorBanner.visible=!0,this.unavailable=!0,this.problemsOverview.unavailable=!0,this.controlTabGroup.show(Ou.Overview))}specClicked(h){var c,l,d;if(this.detailsDrawer.close(),this.selectedEditorTab=="spec"){let p=!1;for(let v=0;v<((c=this.problems)==null?void 0:c.length);v++)if(this.problems[v].startLineNumber===h.detail.line){this.problemList.lineClicked(h.detail.line,!0),this.controlTabGroup.show(Ou.Problems),this.sidebarClosed&&this.toggleSidebar(),p=!0;break}const m=(l=this.graphBag)==null?void 0:l.get(sz);if(m&&m.graphMap&&h.detail.line){const v=m.graphMap[h.detail.line];if(v){this.modelTree.explorerClicked(v);const C=this.renderedNodeMap.get(v);C&&(this.renderedNode.node=C),p||this.viewerPanel.click();const L=this.nodeIdHashMap.get(v);L&&(this.explorer.activeNode=L,this.explorer.equalizer.activeNode=L)}}}if(this.selectedEditorTab==Ou.Ruleset){const p=(d=this.sessionRulesetMapBag)==null?void 0:d.get(cz);if(p!=null&&p.rulesMap){for(let m=0;m<p.rulesMap.length;m++)if(p.rulesMap[m].line===h.detail.line){this.controlTabGroup.show(Ou.Ruleset),this.sidebarClosed&&this.toggleSidebar();break}}}}problemClicked(h){var d,p;this.selectedEditorTab!="spec"&&(this.editorTabGroup.show("spec"),this.selectedEditorTab="spec");let c=h.detail.problem.problemObject.sourceLocation;(c==""||c==null||c=="root")&&(c=this.rolodexRootPath);const l=Jxe(this.rolodexRoot,c);if(l){this.rolodexTreeNodeClicked(new CustomEvent(fP,{detail:{nodeHashId:l.idHash,path:c,line:h.detail.problem.problemObject.startLineNumber,column:h.detail.problem.problemObject.startColumn}})),this.detailsDrawer.close(),this.rolodexTree.openNodeByPath(c);return}this.controlTabGroup.show(Ou.Problems),(d=this.editor.editor)==null||d.revealLineInCenter(h.detail.problem.line),(p=this.editor.editor)==null||p.setPosition({lineNumber:h.detail.problem.line,column:h.detail.problem.column}),this.detailsDrawer.close(),h.detail.launchedFromProblems||this.problemList.lineClicked(h.detail.problem.problemObject.startLineNumber)}loadState(){var d;if(this.graphBag=this.bagManager.getBag(sz),this.docBag=this.bagManager.getBag(YIt),this.rolodexResponseBag=this.bagManager.getBag(mne),this.rolodexFilesBag=this.bagManager.getBag(ME),this.rolodexStateBag=this.bagManager.getBag(sw),this.referenceMapBag=this.bagManager.getBag(oz),this.docExpirationBag=this.bagManager.getBag(Q7e),this.panelStateBag=this.bagManager.getBag(lm),this.settingsBag=this.bagManager.getBag(AE),(d=this.settingsBag)==null||d.onAllChanges(this.settingsChanged.bind(this)),this.settingsComponent.settingsBag=this.settingsBag,this.settingsBag&&this.settingsChanged("",this.settingsBag.get(AE)),this.settingsComponent.bootstrap(),this.rolodexResponseBag){const p=this.rolodexResponseBag.get(mne);p&&(this.rolodexRoot=p.rolodexRoot,this.rolodexTree.isRolodex=!0,this.rolodexTree.node=p.rolodexRoot,p.rolodexRoot.treeExpanded=!0,this.requestUpdate())}let h=!1;const c=p=>{var v;let m=(v=this.referenceMapBag)==null?void 0:v.get(oz);m?setTimeout(()=>{let C=m==null?void 0:m.references[p];C||(C=m==null?void 0:m.references[""]),C&&(this.references=C,this.editor.links=C,this.editor.applyLinkDecorations())},5):Vf.fetchReferenceMap().then(C=>{this.references=C,this.editor.links=C,this.editor.applyLinkDecorations()}).catch(()=>{this.editor.clearDecorations(),this.editor.clearAllMarkers()})};if(this.rolodexStateBag){const p=this.rolodexStateBag.get(sw);p?(this.rolodexActivePath=p.activePath,this.rolodexActiveHash=p.activeHash,p.rootHash&&(this.rolodexTree.pendingNavigationHash=p.rootHash),p.rootPath&&(this.rolodexRootPath=p.rootPath,p.activePath&&c(p.activePath),Vf.selectRootPath(p.rootPath).then(()=>{}).catch(m=>{console.error("could not select the root path on boot bro",m)})),p.rootHash&&(this.rolodexRootHash=p.rootHash),p.activePath&&(this.rolodexTree.pendingNavigationPath=p.activePath,this.rolodexTree.requestUpdate()),p.activeNode&&(p.activeLanguage&&this.editor.switchLanguage(p.activeLanguage),this.editor.setValue(p.activeNode.instance,!0),h=!0)):(this.rolodexActivePath="root",c(this.rolodexActivePath))}if(this.docBag&&!h){const p=this.docBag.get(kM);p&&this.editor.setValue(p,!0)}if(this.problemBag=this.bagManager.getBag(lz),this.problemBag){const p=this.problemBag.get(lz);if(p){this.problems=p;for(let m=0;m<p.length;m++)p[m]=V2.reconstruct(p[m]);if(this.buildRolodexResultMap(p),this.rolodexProblemMap.size>0&&this.rolodexProblemMap.has(this.rolodexActivePath)){const m=this.rolodexProblemMap.get(this.rolodexActivePath);m&&this.editor.setMarkers(m)}this.problemList.problems=p,this.problemsOverview.problems=this.problemList.problemItems}}if(this.howToFixBag=this.bagManager.getBag(ZIt),this.diagnosticBag=this.bagManager.getBag(wne),this.diagnosticBag){const p=this.diagnosticBag.get(wne);p&&(this.problemsOverview.statistics=p)}if(this.graphBag){const p=this.graphBag.get(sz);p&&this.extractGraph(p)}if(this.panelStateBag){const p=this.panelStateBag.get(lm);p&&p.explorerPanel&&(this.splitPanelExplorer.position=p.explorerPanel),p&&p.rolodexPanel&&(this.splitPanelRolodex&&(this.splitPanelRolodex.position=p.rolodexPanel),this.rolodexDividerPosition=p.rolodexPanel),p&&p.inspectorPanel&&(this.splitPanelInspector.position=p.inspectorPanel)}this.rolodexRoot?this.importDisabled=!0:this.importDisabled=!1;const l=[];if(this.defaultRulesetBag=this.bagManager.getBag(vne),this.defaultRulesetBag){const p=this.defaultRulesetBag.get(vne);p?this.defaultRuleset=p:l.push(this.fetchDefaultRuleset())}if(this.OWASPRulesetBag=this.bagManager.getBag(yne),this.OWASPRulesetBag){const p=this.OWASPRulesetBag.get(yne);p?this.OWASPRuleset=p:l.push(this.fetchOWASPRuleset())}if(this.allRulesetBag=this.bagManager.getBag(xne),this.allRulesetBag){const p=this.allRulesetBag.get(xne);p?this.allRuleset=p:l.push(this.fetchAllRuleset())}if(this.functionsBag=this.bagManager.getBag(LE),this.functionSchemaBag=this.bagManager.getBag(SE),this.functionsBag){const p=this.functionsBag.get(LE);p?this.functions=p:l.push(this.fetchFunctions())}if(this.customRulesetBag=this.bagManager.getBag(IE),this.customRulesetBag){const p=this.customRulesetBag.get(IE);p&&(this.customRuleset=p)}this.ruleConfigBag=this.bagManager.getBag(xM),this.sessionRulesetMapBag=this.bagManager.getBag(cz),Promise.all(l).then(()=>{var m;this.manageRuleset.defaultRuleset=this.defaultRuleset,this.manageRuleset.owaspRuleset=this.OWASPRuleset,this.manageRuleset.allRuleset=this.allRuleset,this.manageRuleset.functions=this.functions;const p=(m=this.ruleConfigBag)==null?void 0:m.get(xM);p?this.manageRuleset.rulesetConfig=p:this.manageRuleset.rulesetConfig={ruleMapping:new Map,allRulesSwitch:!0},setTimeout(()=>{this.manageRuleset.buildRulesets(),this.customRuleset&&this.customRuleset.rules.size>0&&(this.manageRuleset.customRuleset=this.customRuleset),this.fetchSessionRulesetAsYaml().then(v=>{var C;(C=this.rulesetEditor)==null||C.setValue(v,!0),this.fetchRulesetMap()}).catch(v=>{this.platformUnavailable(v)})},50)}),this.fetchDocs()}extractGraph(h){var l,d,p,m;h.stripped?(this.explorer.nodeLimitExceeded=!0,this.modelTree.nodeLimitExceeded=!0,h.strippedCount&&(this.explorer.nodeLimit=h.strippedCount,this.modelTree.nodeLimit=h.strippedCount)):(this.explorer.nodeLimitExceeded=!1,this.modelTree.nodeLimitExceeded=!1),this.explorer.renderedNodeMap.clear(),this.nodeMap.clear(),this.nodeIdMap.clear(),this.nodeIdHashMap.clear();const c=new Map;(l=h==null?void 0:h.nodesRendered)==null||l.forEach(v=>{this.explorer.renderedNodeMap.set(v.id,v),c.set(v.id,v)});for(let v=0;v<((d=h==null?void 0:h.nodesRendered)==null?void 0:d.length);v++)this.renderedNodeMap.set(h.nodesRendered[v].id,h.nodesRendered[v]);(p=h==null?void 0:h.nodes)==null||p.forEach(v=>{var L;this.nodeMap.set(v.id,v),v.idHash.includes("root")?(this.nodeIdMap.set("root",v),this.nodeIdHashMap.set(v.id,v)):(this.nodeIdMap.set(v.id,v),this.nodeIdHashMap.set(v.idHash,v)),v.filtered&&this.filteredNodes.set(v.id,v);const C=this.renderedNodeMap.get(v.id);((L=this.activeNode)==null?void 0:L.id)===v.id&&this.renderedNodeMap.get(v.id)&&this.renderedNode&&C&&(this.renderedNode.node=C)}),(m=this.graphBag)==null||m.set(sz,h),this.explorer.updateGraphResponse(h),h&&h.nodes&&(this.modelTree.node=h==null?void 0:h.nodesRendered[0]),this.explorer.equalizer.isInitialized()?this.explorer.equalizer.runEQ(!0):this.explorer.equalizer.initializeEqualizer(),this.timeVortex.checkHistory()}customRulesetEnabled(h){var l,d,p;const c={rules:new Map};c.id=crypto.randomUUID(),c.owner=this.authController.session.sessionId,h.detail.rules.forEach(m=>{m.rule.id!=m.ruleId&&(m.rule.id=m.ruleId),c.rules.set(m.ruleId,m.rule)}),(l=this.customRulesetBag)==null||l.set(IE,c),h.detail.ruleConfig?(d=this.ruleConfigBag)==null||d.set(xM,h.detail.ruleConfig):((p=this.ruleConfigBag)==null||p.reset(),Yf.resetSessionRuleset(h.detail.rulesetReset).then(()=>{if(this.sendToast({id:crypto.randomUUID(),type:Rc.INFO,body:"Ruleset has been reset to the default",title:"Ruleset reset"}),this.docBag){const m=this.docBag.get(kM);this.rolodexActivePath,this.lintSpec(m,this.rolodexActivePath)}this.fetchSessionRulesetAsYaml().then(m=>{var v;(v=this.rulesetEditor)==null||v.setValue(m,!0)})}).catch(m=>{this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:m.detail,title:"Cannot reset ruleset"})}))}async fetchSessionRulesetAsYaml(){return new Promise(async(h,c)=>{Yf.getSessionRulesetAsYAML().then(l=>{h(l)}).catch(l=>{console.error("cannot fetch session ruleset: ",l.title),c(l)})})}async fetchFunctions(){return new Promise(async h=>{Yf.getFunctions().then(c=>{var d;this.functions=c,(d=this.functionsBag)==null||d.set(LE,c);const l=[];c.forEach(p=>{l.push(this.fetchFunctionSchema(p))}),Promise.all(l).then(()=>{h(c)})})})}async fetchFunctionSchema(h){return new Promise(async c=>{Yf.getFunctionSchema(h).then(l=>{var p,m;let d=(p=this.functionSchemaBag)==null?void 0:p.get(SE);d||(d=new Map),d.set(h,l),(m=this.functionSchemaBag)==null||m.set(SE,d),c(l)})})}async fetchDefaultRuleset(){return new Promise(async h=>{Yf.getDefaultRuleset().then(c=>{var l;this.defaultRuleset=c,(l=this.defaultRulesetBag)==null||l.set(vne,c),h(c)})})}async fetchOWASPRuleset(){return new Promise(async h=>{Yf.getOWASPRuleset().then(c=>{var l;this.OWASPRuleset=c,(l=this.OWASPRulesetBag)==null||l.set(yne,c),h(c)})})}async fetchAllRuleset(){return new Promise(async h=>{Yf.getAllRuleset().then(c=>{var l;this.allRuleset=c,(l=this.allRulesetBag)==null||l.set(xne,c),h(c)})})}fetchDocs(){this.activitySpinner.show();const c=new URL(window.location.href).searchParams.get("url");c&&(this.activeURL=c,this.lintSpec("",c)),n8.fetchAllHowToFix().then(d=>{d&&d.forEach(p=>{var m;(m=this.howToFixBag)==null||m.set(p.ruleId,p)})}).catch(d=>{this.platformUnavailable(d),console.error("documentation service is down")}),this.ruleDocsBag=this.bagManager.getBag(QIt),this.functionDocsBag=this.bagManager.getBag(XIt),this.ruleDocsWorker.addEventListener("message",d=>{const p=d.data;p&&(p.forEach(m=>{var v,C;m.ruleId&&((v=this.ruleDocsBag)==null||v.set(m.ruleId,m)),m.functionId&&((C=this.functionDocsBag)==null||C.set(m.functionId,m))}),this.activitySpinner.hide())});const l=()=>{this.ruleDocsWorker.postMessage({start:!0,endpoint:this.doctorEndpoint,existingRules:[],existingFunctions:[]})};if(this.docExpirationBag){const d=this.docExpirationBag.get(Q7e);d&&(new Date().getTime(),new Date(d).getTime()),l()}else l()}fetchRulesetMap(){Yf.getSessionRulesetMap().then(h=>{var c;(c=this.sessionRulesetMapBag)==null||c.set(cz,h)}).catch(()=>{console.warn("map is empty, or unavailable, Did you submit an empty ruleset?"),this.sendToast({id:crypto.randomUUID(),type:Rc.WARNING,body:"map is empty, or unavailable, Did you submit an empty ruleset?",title:"Issue fetching ruleset map"})})}ruleClicked(h){var l,d,p;const c=(l=this.sessionRulesetMapBag)==null?void 0:l.get(cz);if(c){const m=c.rulesMap.find(v=>v.ruleId===h.detail.ruleId);m&&(this.selectedEditorTab="ruleset",this.editorTabGroup.show(Ou.Ruleset),(d=this.rulesetEditor.editor)==null||d.setPosition({lineNumber:m.line,column:m.start}),(p=this.rulesetEditor.editor)==null||p.revealLineInCenter(m.line))}}builtInRulesetSelected(){}rulesetManuallyChanged(){clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{var c;const h=(c=this.rulesetEditor.editor)==null?void 0:c.getValue();Yf.validateRuleset(h).then(l=>{var p;this.manageRuleset.clearRuleProblems();let d={rules:new Map};d.id=crypto.randomUUID(),d.owner=this.authController.session.sessionId,d.rules=new Map(Object.entries(l.rules)),d.rules.forEach((m,v)=>{m.id=v}),(p=this.customRulesetBag)==null||p.set(IE,d),this.customRuleset=d,d.rules.size>0&&(this.manageRuleset.customRulesetManual=d),this.selectedEditorTab=Ou.Ruleset,this.controlTabGroup.show(Ou.Ruleset),this.rulesetEditor.setMarkers([]),this.fetchRulesetMap()}).catch(l=>{this.sendToast({id:crypto.randomUUID(),type:Rc.ERROR,body:l.detail,title:l.title}),console.error("unable to validate ruleset",l);const d=l.body,p=[];d==null||d.forEach(m=>{p.push({severity:f4.MarkerSeverity.Error,message:m.ruleError,startLineNumber:m.line,startColumn:m.startCol,endLineNumber:m.line,endColumn:m.endCol})}),Yf.convertToJSON(h).then(m=>{let v={rules:new Map};v.id=crypto.randomUUID(),v.owner=this.authController.session.sessionId,v.rules=new Map(Object.entries(m.rules)),v.rules.forEach((C,L)=>{C.id!=L&&(C.id=L)}),this.customRuleset=v,v.rules.size>0&&(this.manageRuleset.customRulesetManual=v),this.rulesetEditor.setMarkers([]),this.manageRuleset.clearRuleProblems(),this.rulesetEditor.setMarkers(p),this.manageRuleset.processBadRules(d),this.controlTabGroup.show(Ou.Ruleset)}).catch(m=>{console.error("unable to convert ruleset to JSON",m)})})},this.debounceTimeRuleset)}specChanged(h){if(this.editorMap.get(h.detail.id)&&h.detail.id==="ruleset-editor"){this.rulesetManuallyChanged();return}this.docBag&&this.docBag.set(kM,h.detail.content),this.autoDiagnose&&(clearTimeout(this.bounceId),this.bounceId=window.setTimeout(()=>{this.lintSpec(h.detail.content)},this.debounceTime))}runDiagnostics(){this.autoDiagnose||this.lintSpec(this.editor.getValue())}boostrap(){const c=new URL(window.location.href).searchParams.get("url");if(c){this.activeURL=c,this.lintSpec("",c);return}setTimeout(()=>{var d;this.loadingOverlay.hide(),this.timeVortex.doctor=this,this.timeVortex.checkHistory(),((d=this.docBag)==null?void 0:d.get(kM))||n8.bootstrapEditor().then(p=>{this.editor.setValue(p,!0),this.rolodexActivePath="",this.specChanged(new CustomEvent(Aee,{detail:{content:p,id:"spec"}}))})},200)}exportJSON(){let h;if(this.ruleConfigBag){const c=this.ruleConfigBag.get(xM);c&&c.returnedRuleset&&(h=c.returnedRuleset)}if(h){let c="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(h,null,2));this.downloadRulesetLink.download="ruleset.json",this.downloadRulesetLink.href=c,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()}}exportYAML(){Yf.getSessionRulesetAsYAML().then(h=>{let c="data:text/yaml;charset=utf-8,"+encodeURIComponent(h);this.downloadRulesetLink.download="ruleset.yaml",this.downloadRulesetLink.href=c,this.downloadRulesetLink.click(),this.exportRulesetDialog.hide()})}confirmExport(){switch(this.exportSelection.value){case"json":this.exportJSON();break;case"yaml":this.exportYAML();break}}closeWelcome(){this.welcomeBox.hide(),localStorage.setItem("pb33f-doctor-welcome","closed")}selectEditorTab(h){switch(this.selectedEditorTab=h.detail.name,h.detail.name){case Ou.Ruleset:this.rulesetPulse&&(this.rulesetPulse=!1),this.controlTabGroup.show(Ou.Ruleset);break}}selectControlTab(h){switch(h.detail.name){case Ou.Problems:case Ou.Overview:break;case Ou.Ruleset:this.selectedEditorTab!=Ou.Ruleset&&(this.editorTabGroup.show(Ou.Ruleset),this.selectedEditorTab=Ou.Ruleset);break}}toggleSidebar(){var c;const h=(c=this.shadowRoot)==null?void 0:c.querySelector("sl-split-panel.split-panel");this.sidebarClosed?h&&(this.collapseButton.name="chevron-bar-right",h.style.setProperty("--min","600px"),h.style.setProperty("--max","calc(100vw - 600px)"),h.position=60,h.disabled=!1,this.problemsDataDiv.style.display="block",this.splitDivider.style.display="block",this.activitySpinner.classList.remove("spinner-draw-closed")):h&&(this.collapseButton.name="chevron-bar-left",this.problemsDataDiv.style.display="none",h.style.setProperty("--min","40px"),h.style.setProperty("--max","calc(100vw - 40px)"),h.position=99,h.disabled=!0,this.splitDivider.style.display="none",this.activitySpinner.classList.add("spinner-draw-closed")),this.sidebarClosed=!this.sidebarClosed}showHistory(){this.closeExplorer(),this.hideMinimapIcon(),this.requestUpdate()}toggleExplorer(){this.explorerVisible=!this.explorerVisible,this.explorerVisible&&this.activeNode&&this.explorer.moveToNode(this.activeNode),this.hideMinimapIcon(),this.showDiagnosisButton=!1,this.explorerBooted=!0,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&this.sendToast({id:crypto.randomUUID(),type:Rc.WARNING,body:"Safari is not supported by the explorer. Please use Chrome, Firefox or Edge. As you can see the icons are all messed up.",title:"Safari Warning"})}hideMinimapIcon(){this.minimapIconVisible=!1}hideDiagnosisButton(){this.showDiagnosisButton=!1}enableDiagnosisButton(){this.autoDiagnose||(this.showDiagnosisButton=!0)}showMinimapIcon(){this.minimapIconVisible=!0}closeExplorer(){this.explorerVisible=!1,this.showMinimapIcon(),this.showDiagnosisButton=!0,setTimeout(()=>{var h,c;this.pendingLine>0&&((h=this.editor.editor)==null||h.setPosition({lineNumber:this.pendingLine,column:1}),(c=this.editor.editor)==null||c.revealLineInCenter(this.pendingLine),this.pendingLine=0)},20)}render(){var v;let h=E.html``;this.unavailable&&(h=E.html`
|
|
12034
12034
|
<div class="overlay" @click="return false"></div>`);let c=E.html`
|
|
12035
12035
|
<pb33f-attention-box id="welcome" type="success"
|
|
12036
12036
|
headerText="Welcome to the clinic, I am the OpenAPI doctor." closeable>
|
package/package.json
CHANGED