orbitchat 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bin/orbitchat.js +8 -2
  2. package/dist/assets/api-BALsORF3.js +2 -0
  3. package/dist/assets/api-Co0BVmRJ.js +2 -0
  4. package/dist/assets/arc-CvECY7sY-Vr1TQguo.js +1 -0
  5. package/dist/assets/{blockDiagram-c4efeb88-BF2cqC5E-C5ugV9-s.js → blockDiagram-c4efeb88-NvaZhZFT-dWMoZUAg.js} +8 -8
  6. package/dist/assets/{c4Diagram-c83219d4-D9AJbzWz-BWb1Tk8y.js → c4Diagram-c83219d4-gPr1eF38-Dm2gBVFn.js} +3 -3
  7. package/dist/assets/channel-6PI3wNcc-xC-uPvXz.js +1 -0
  8. package/dist/assets/classDiagram-beda092f-B8axaKGu-9rbEMdqe.js +2 -0
  9. package/dist/assets/classDiagram-v2-2358418a-DPdf2DxR-35t2Ulv3.js +2 -0
  10. package/dist/assets/clone-D01vUIhD-BmKLNBjy.js +1 -0
  11. package/dist/assets/{createText-1719965b-D5GExXUl-CSo0puOR.js → createText-1719965b-D9Y3vUMn-eo4dwQ-N.js} +1 -1
  12. package/dist/assets/edges-96097737-Zc6U9nQz-Bwo4-Nya.js +4 -0
  13. package/dist/assets/{erDiagram-0228fc6a-DNX6_tUA-CBfeRoEX.js → erDiagram-0228fc6a-BLw8FsIp-DsFgy0ky.js} +4 -4
  14. package/dist/assets/{flowDb-c6c81e3f-DFROkPpA-DoF7w60g.js → flowDb-c6c81e3f-DXVkMlSE-d-bmpRIJ.js} +3 -3
  15. package/dist/assets/{flowDiagram-50d868cf-Cmwizbui-DAWL0Ten.js → flowDiagram-50d868cf-mkkB0hFd-DQynJrQP.js} +3 -3
  16. package/dist/assets/flowDiagram-v2-4f6560a1-BRIhxQ3y-_eh8suKY.js +1 -0
  17. package/dist/assets/{flowchart-elk-definition-6af322e1-CNwLXR6A-Bz6YKMuz.js → flowchart-elk-definition-6af322e1-D9IbjnSJ-CH_ATI7G.js} +1 -1
  18. package/dist/assets/{ganttDiagram-a2739b55-7uphPAFV-BFKc01uq.js → ganttDiagram-a2739b55-Cqs5_Zht-B6ML9yDB.js} +3 -3
  19. package/dist/assets/{gitGraphDiagram-82fe8481-DRDypp_x-Cc3_bbqa.js → gitGraphDiagram-82fe8481-txBzFn40-DUSli1LH.js} +12 -12
  20. package/dist/assets/{graph-CvRY9YIM-BVZjlKfa.js → graph-BZahQKIN-Dz7VTHix.js} +1 -1
  21. package/dist/assets/{index-5325376f-D7k5u-pg-D5Cux9AW.js → index-5325376f-DsNDppci-DrwAihmx.js} +1 -1
  22. package/dist/assets/index-CVXt7K8o.css +1 -0
  23. package/dist/assets/index-DQigKykq.js +1006 -0
  24. package/dist/assets/{infoDiagram-8eee0895-BcQBWTwp-Cuo1RYtb.js → infoDiagram-8eee0895-SbmhgTjv-ZwwTvmHZ.js} +3 -3
  25. package/dist/assets/{journeyDiagram-c64418c1-CN5eh0M6-CFlv0ZW_.js → journeyDiagram-c64418c1-C7AiwbKr-Bw7dGrje.js} +4 -4
  26. package/dist/assets/layout-j-hMNqAM-CmCuPxH9.js +1 -0
  27. package/dist/assets/{mindmap-definition-8da855dc-BIK1yn9--2Uavet_P.js → mindmap-definition-8da855dc-B1WjnfxE-BOPG_kjQ.js} +13 -13
  28. package/dist/assets/{pieDiagram-a8764435-ikNRxsHY-J8pKwIba.js → pieDiagram-a8764435-zrkaw4r--RAXG0v3L.js} +5 -5
  29. package/dist/assets/{quadrantDiagram-1e28029f-jvSP5gnQ-IfKQkanh.js → quadrantDiagram-1e28029f-C2Wa5n16-9o-booOC.js} +5 -5
  30. package/dist/assets/{requirementDiagram-08caed73-FO_Z83qK-vBJAFnIP.js → requirementDiagram-08caed73-BtHxx079-DQorVNsC.js} +4 -4
  31. package/dist/assets/{sankeyDiagram-a04cb91d-DN0iWjES-CD7wN8jh.js → sankeyDiagram-a04cb91d-DXlmqTKB-5aKuzwPH.js} +5 -5
  32. package/dist/assets/{sequenceDiagram-c5b8d532-CGsjpH84-C-ZWXP1Q.js → sequenceDiagram-c5b8d532-BVQF3vcA-yrjkg_KG.js} +1 -1
  33. package/dist/assets/{stateDiagram-1ecb1508-zuhKSs9y-BTHnrZrL.js → stateDiagram-1ecb1508-Dybc3i2m-C9YgXB_l.js} +1 -1
  34. package/dist/assets/stateDiagram-v2-c2b004d7-Bp8rRkv2-BdiRYE7p.js +1 -0
  35. package/dist/assets/{styles-b4e223ce-BOk_k5Y1-PKPDqdqx.js → styles-b4e223ce-BSiU4oYL-DANqzF8x.js} +3 -3
  36. package/dist/assets/{styles-ca3715f6-g0iC1zjD-CPChcZri.js → styles-ca3715f6-DU7x0doE-DHImZVjW.js} +4 -4
  37. package/dist/assets/{styles-d45a18b0-VfGWd52Q-D7qD0x-3.js → styles-d45a18b0-B_CU21kM-CsfZzKcT.js} +3 -3
  38. package/dist/assets/{svgDrawCommon-b86b1483-BnVJ45aa-CErmScK_.js → svgDrawCommon-b86b1483-sbEe2n2v-C7sWJ9J5.js} +1 -1
  39. package/dist/assets/threadService-B9Db3n0J.js +1 -0
  40. package/dist/assets/{timeline-definition-faaaa080-BpDBXry4-8Fh7Xq3v.js → timeline-definition-faaaa080-b82QCnJ9-DubraCW2.js} +5 -5
  41. package/dist/assets/{xychartDiagram-f5964ef8-CvN7DIQW-_wuj7Zir.js → xychartDiagram-f5964ef8-BtRcO0uy-BpoCAy-b.js} +4 -4
  42. package/dist/index.html +3 -6
  43. package/package.json +3 -3
  44. package/dist/assets/api-BHF9IxKN.js +0 -1
  45. package/dist/assets/api-DvBZwzfV.js +0 -2
  46. package/dist/assets/arc-CVHSP1cu-Bj3hxGRV.js +0 -1
  47. package/dist/assets/channel-BYhLgIow-BPTRMgNI.js +0 -1
  48. package/dist/assets/classDiagram-beda092f-B88VjdUG-BWR-XkYO.js +0 -2
  49. package/dist/assets/classDiagram-v2-2358418a-BPyGCNOs-CnRIvvFY.js +0 -2
  50. package/dist/assets/clone-C0MdfhAf-_B1M49Tw.js +0 -1
  51. package/dist/assets/edges-96097737-BnGLzlID--RpsQPpU.js +0 -4
  52. package/dist/assets/flowDiagram-v2-4f6560a1-LfQOA08G-ByM7AhyC.js +0 -1
  53. package/dist/assets/index-CV3ovvq1.js +0 -983
  54. package/dist/assets/index-CfrvHiM_.css +0 -1
  55. package/dist/assets/layout-DSZZaifl-B9Eg6v4O.js +0 -1
  56. package/dist/assets/stateDiagram-v2-c2b004d7-CNnNRi3z-DT3KwZcD.js +0 -1
package/bin/orbitchat.js CHANGED
@@ -26,6 +26,7 @@ const DEFAULT_CONFIG = {
26
26
  localApiPath: undefined,
27
27
  consoleDebug: false,
28
28
  enableUploadButton: false,
29
+ enableAudioOutput: false,
29
30
  enableFeedbackButtons: false,
30
31
  maxFilesPerConversation: 5,
31
32
  maxFileSizeMB: 50,
@@ -72,6 +73,9 @@ function parseArgs() {
72
73
  case '--enable-upload-button':
73
74
  config.enableUploadButton = args[++i] === 'true';
74
75
  break;
76
+ case '--enable-audio':
77
+ config.enableAudioOutput = args[++i] === 'true';
78
+ break;
75
79
  case '--enable-feedback-buttons':
76
80
  config.enableFeedbackButtons = args[++i] === 'true';
77
81
  break;
@@ -157,6 +161,7 @@ function loadConfigFromEnv() {
157
161
  VITE_LOCAL_API_PATH: 'localApiPath',
158
162
  VITE_CONSOLE_DEBUG: 'consoleDebug',
159
163
  VITE_ENABLE_UPLOAD_BUTTON: 'enableUploadButton',
164
+ VITE_ENABLE_AUDIO_OUTPUT: 'enableAudioOutput',
160
165
  VITE_ENABLE_FEEDBACK_BUTTONS: 'enableFeedbackButtons',
161
166
  VITE_MAX_FILES_PER_CONVERSATION: 'maxFilesPerConversation',
162
167
  VITE_MAX_FILE_SIZE_MB: 'maxFileSizeMB',
@@ -171,7 +176,8 @@ function loadConfigFromEnv() {
171
176
  const value = process.env[envKey];
172
177
  if (value !== undefined) {
173
178
  if (configKey === 'useLocalApi' || configKey === 'consoleDebug' ||
174
- configKey === 'enableUploadButton' || configKey === 'enableFeedbackButtons') {
179
+ configKey === 'enableUploadButton' || configKey === 'enableAudioOutput' ||
180
+ configKey === 'enableFeedbackButtons') {
175
181
  envConfig[configKey] = value === 'true';
176
182
  } else if (configKey.includes('max') && configKey !== 'maxFileSizeMB') {
177
183
  const parsed = parseInt(value, 10);
@@ -368,6 +374,7 @@ Options:
368
374
  --local-api-path PATH Path to local API
369
375
  --console-debug BOOLEAN Enable console debug (default: false)
370
376
  --enable-upload-button BOOLEAN Enable upload button (default: false)
377
+ --enable-audio BOOLEAN Enable audio button (default: false)
371
378
  --enable-feedback-buttons BOOLEAN Enable feedback buttons (default: false)
372
379
  --max-files-per-conversation N Max files per conversation (default: 5)
373
380
  --max-file-size-mb N Max file size in MB (default: 50)
@@ -464,4 +471,3 @@ if (isMainModule) {
464
471
  }
465
472
 
466
473
  export { main, parseArgs, mergeConfig };
467
-
@@ -0,0 +1,2 @@
1
+ import{_ as K}from"./index-DQigKykq.js";var j=Object.defineProperty,q=(l,i,e)=>i in l?j(l,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[i]=e,I=(l,i,e)=>q(l,typeof i!="symbol"?i+"":i,e);let F=null,$=null;typeof window>"u"&&Promise.all([K(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]).catch(()=>null),K(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]).catch(()=>null)]).then(([l,i])=>{var e,t;(e=l==null?void 0:l.default)!=null&&e.Agent?F=new l.default.Agent({keepAlive:!0}):l!=null&&l.Agent&&(F=new l.Agent({keepAlive:!0})),(t=i==null?void 0:i.default)!=null&&t.Agent?$=new i.default.Agent({keepAlive:!0}):i!=null&&i.Agent&&($=new i.Agent({keepAlive:!0}))}).catch(l=>{console.warn("Failed to initialize HTTP agents:",l.message)});class D{constructor(i){if(I(this,"apiUrl"),I(this,"apiKey"),I(this,"sessionId"),!i.apiUrl||typeof i.apiUrl!="string")throw new Error("API URL must be a valid string");if(i.apiKey!==void 0&&i.apiKey!==null&&typeof i.apiKey!="string")throw new Error("API key must be a valid string or null");if(i.sessionId!==void 0&&i.sessionId!==null&&typeof i.sessionId!="string")throw new Error("Session ID must be a valid string or null");this.apiUrl=i.apiUrl,this.apiKey=i.apiKey??null,this.sessionId=i.sessionId??null}setSessionId(i){if(i!==null&&typeof i!="string")throw new Error("Session ID must be a valid string or null");this.sessionId=i}getSessionId(){return this.sessionId}async validateApiKey(){var i;if(!this.apiKey)throw new Error("API key is required for validation");try{const e=await fetch(`${this.apiUrl}/admin/api-keys/${this.apiKey}/status`,{...this.getFetchOptions({method:"GET"})}).catch(r=>{throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r});if(!e.ok){let r="";try{r=await e.text()}catch{r=`HTTP ${e.status}`}let s,o;try{const a=JSON.parse(r);s=a.detail||a.message||r}catch{s=r||`HTTP ${e.status}`}switch(e.status){case 401:o="API key is invalid or expired";break;case 403:o="Access denied: API key does not have required permissions";break;case 404:o="API key not found";break;case 503:o="API key management is not available in inference-only mode";break;default:o=`Failed to validate API key: ${s}`;break}throw new Error(o)}const t=await e.json();if(!t.exists){const r="API key does not exist";throw new Error(r)}if(!t.active){const r="API key is inactive";throw new Error(r)}return t}catch(e){let t;throw e instanceof Error&&e.message?e.message.includes("API key")||e.message.includes("Access denied")||e.message.includes("invalid")||e.message.includes("expired")||e.message.includes("inactive")||e.message.includes("not found")||e.message.includes("Could not connect")?t=e.message:t=`API key validation failed: ${e.message}`:e.name==="TypeError"&&(i=e.message)!=null&&i.includes("Failed to fetch")?t="Could not connect to the server. Please check if the server is running.":t="API key validation failed. Please check your API key and try again.",console.warn(`[ApiClient] ${t}`),new Error(t)}}async getAdapterInfo(){var i;if(!this.apiKey)throw new Error("API key is required to get adapter information");try{const e=await fetch(`${this.apiUrl}/admin/api-keys/info`,{...this.getFetchOptions({method:"GET"})}).catch(t=>{throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t});if(!e.ok){let t="";try{t=await e.text()}catch{t=`HTTP ${e.status}`}let r,s;try{const o=JSON.parse(t);r=o.detail||o.message||t}catch{r=t||`HTTP ${e.status}`}switch(e.status){case 401:s="API key is invalid, disabled, or has no associated adapter";break;case 404:s="Adapter configuration not found";break;case 503:s="Service is not available";break;default:s=`Failed to get adapter info: ${r}`;break}throw new Error(s)}return await e.json()}catch(e){let t;throw e instanceof Error&&e.message?e.message.includes("API key")||e.message.includes("Adapter")||e.message.includes("invalid")||e.message.includes("disabled")||e.message.includes("not found")||e.message.includes("Could not connect")?t=e.message:t=`Failed to get adapter info: ${e.message}`:e.name==="TypeError"&&(i=e.message)!=null&&i.includes("Failed to fetch")?t="Could not connect to the server. Please check if the server is running.":t="Failed to get adapter information. Please try again.",console.warn(`[ApiClient] ${t}`),new Error(t)}}getFetchOptions(i={}){const e={};if(typeof window>"u"){const r=this.apiUrl.startsWith("https:")?$:F;r&&(e.agent=r)}else e.headers={Connection:"keep-alive"};const t={"X-Request-ID":Date.now().toString(36)+Math.random().toString(36).substring(2)};if(e.headers&&Object.assign(t,e.headers),i.headers){const r=i.headers;for(const[s,o]of Object.entries(r))(s.toLowerCase()!=="x-api-key"||!this.apiKey)&&(t[s]=o)}return this.apiKey&&(t["X-API-Key"]=this.apiKey),this.sessionId&&(t["X-Session-ID"]=this.sessionId),{...i,...e,headers:t}}createChatRequest(i,e=!0,t,r,s,o,a,h,p,y,v){const c={messages:[{role:"user",content:i}],stream:e};return t&&t.length>0&&(c.file_ids=t),r&&(c.thread_id=r),s&&(c.audio_input=s),o&&(c.audio_format=o),a&&(c.language=a),h!==void 0&&(c.return_audio=h),p&&(c.tts_voice=p),y&&(c.source_language=y),v&&(c.target_language=v),c}async*streamChat(i,e=!0,t,r,s,o,a,h,p,y,v){var c,C;try{const w=new AbortController,O=setTimeout(()=>w.abort(),6e4),g=await fetch(`${this.apiUrl}/v1/chat`,{...this.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json",Accept:e?"text/event-stream":"application/json"},body:JSON.stringify(this.createChatRequest(i,e,t,r,s,o,a,h,p,y,v))}),signal:w.signal});if(clearTimeout(O),!g.ok){const f=await g.text();throw new Error(`Network response was not ok: ${g.status} ${f}`)}if(!e){const f=await g.json();f.response&&(yield{text:f.response,done:!0,audio:f.audio,audioFormat:f.audio_format});return}const A=(c=g.body)==null?void 0:c.getReader();if(!A)throw new Error("No reader available");const _=new TextDecoder;let u="",E=!1;try{for(;;){const{done:f,value:S}=await A.read();if(f)break;const U=_.decode(S,{stream:!0});u+=U;let k=0,P;for(;(P=u.indexOf(`
2
+ `,k))!==-1;){const m=u.slice(k,P).trim();if(k=P+1,m&&m.startsWith("data: ")){const d=m.slice(6).trim();if(!d||d==="[DONE]"){yield{text:"",done:!0};return}try{const n=JSON.parse(d);if(n.error){const x=`Server error: ${((C=n.error)==null?void 0:C.message)||n.error||"Unknown server error"}`;throw console.warn(`[ApiClient] ${x}`),new Error(x)}if(n.done===!0){E=!0,yield{text:"",done:!0,audio:n.audio,audioFormat:n.audio_format||n.audioFormat,threading:n.threading};return}const b=n.response||"";n.audio_chunk!==void 0&&(yield{text:"",done:!1,audio_chunk:n.audio_chunk,audioFormat:n.audioFormat||n.audio_format||"opus",chunk_index:n.chunk_index??0}),(b||n.audio)&&(E=!0,yield{text:b,done:n.done||!1,audio:n.audio,audioFormat:n.audio_format||n.audioFormat,threading:n.threading})}catch(n){console.warn("[ApiClient] Unable to parse server response. This may be a temporary issue."),console.warn("[ApiClient] Parse error details:",n==null?void 0:n.message),console.warn("[ApiClient] JSON text length:",d==null?void 0:d.length),console.warn("[ApiClient] JSON text preview (first 200 chars):",d==null?void 0:d.substring(0,200)),console.warn("[ApiClient] JSON text preview (last 200 chars):",d==null?void 0:d.substring(d.length-200))}}else m&&(E=!0,yield{text:m,done:!1})}u=u.slice(k),u.length>1e6&&(console.warn("[ApiClient] Buffer too large, truncating..."),u=u.slice(-5e5))}E&&(yield{text:"",done:!0})}finally{A.releaseLock()}}catch(w){throw w.name==="AbortError"?new Error("Connection timed out. Please check if the server is running."):w.name==="TypeError"&&w.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):w}}async clearConversationHistory(i){const e=i||this.sessionId;if(!e)throw new Error("No session ID provided and no current session available");if(!this.apiKey)throw new Error("API key is required for clearing conversation history");const t={"Content-Type":"application/json","X-Session-ID":e,"X-API-Key":this.apiKey};try{const r=await fetch(`${this.apiUrl}/admin/chat-history/${e}`,{...this.getFetchOptions({method:"DELETE",headers:t})});if(!r.ok){const s=await r.text();throw new Error(`Failed to clear conversation history: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async deleteConversationWithFiles(i,e){const t=i||this.sessionId;if(!t)throw new Error("No session ID provided and no current session available");if(!this.apiKey)throw new Error("API key is required for deleting conversation");const r={"Content-Type":"application/json","X-Session-ID":t,"X-API-Key":this.apiKey},s=e&&e.length>0?`?file_ids=${e.join(",")}`:"",o=`${this.apiUrl}/admin/conversations/${t}${s}`;try{const a=await fetch(o,{...this.getFetchOptions({method:"DELETE",headers:r})});if(!a.ok){const h=await a.text();throw new Error(`Failed to delete conversation: ${a.status} ${h}`)}return await a.json()}catch(a){throw a.name==="TypeError"&&a.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):a}}async createThread(i,e){if(!this.apiKey)throw new Error("API key is required for creating threads");const t={"Content-Type":"application/json","X-API-Key":this.apiKey};try{const r=await fetch(`${this.apiUrl}/api/threads`,{...this.getFetchOptions({method:"POST",headers:t,body:JSON.stringify({message_id:i,session_id:e})})});if(!r.ok){const s=await r.text();throw new Error(`Failed to create thread: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async getThreadInfo(i){if(!this.apiKey)throw new Error("API key is required for getting thread info");const e={"X-API-Key":this.apiKey};try{const t=await fetch(`${this.apiUrl}/api/threads/${i}`,{...this.getFetchOptions({method:"GET",headers:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to get thread info: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async deleteThread(i){if(!this.apiKey)throw new Error("API key is required for deleting threads");const e={"X-API-Key":this.apiKey};try{const t=await fetch(`${this.apiUrl}/api/threads/${i}`,{...this.getFetchOptions({method:"DELETE",headers:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to delete thread: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async uploadFile(i){if(!this.apiKey)throw new Error("API key is required for file upload");const e=new FormData;e.append("file",i);try{const t=await fetch(`${this.apiUrl}/api/files/upload`,{...this.getFetchOptions({method:"POST",body:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to upload file: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async listFiles(){if(!this.apiKey)throw new Error("API key is required for listing files");try{const i=await fetch(`${this.apiUrl}/api/files`,{...this.getFetchOptions({method:"GET"})});if(!i.ok){const e=await i.text();throw new Error(`Failed to list files: ${i.status} ${e}`)}return await i.json()}catch(i){throw i.name==="TypeError"&&i.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):i}}async getFileInfo(i){if(!this.apiKey)throw new Error("API key is required for getting file info");try{const e=await fetch(`${this.apiUrl}/api/files/${i}`,{...this.getFetchOptions({method:"GET"})});if(!e.ok){const t=await e.text();throw new Error(`Failed to get file info: ${e.status} ${t}`)}return await e.json()}catch(e){throw e.name==="TypeError"&&e.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):e}}async queryFile(i,e,t=10){if(!this.apiKey)throw new Error("API key is required for querying files");try{const r=await fetch(`${this.apiUrl}/api/files/${i}/query`,{...this.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e,max_results:t})})});if(!r.ok){const s=await r.text();throw new Error(`Failed to query file: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async deleteFile(i){if(!this.apiKey)throw new Error("API key is required for deleting files");const e=`${this.apiUrl}/api/files/${i}`,t=this.getFetchOptions({method:"DELETE"});try{const r=await fetch(e,t);if(!r.ok){const s=await r.text();let o;try{const a=JSON.parse(s);o=a.detail||a.message||`Failed to delete file (HTTP ${r.status})`}catch{o=`Failed to delete file (HTTP ${r.status})`}throw console.warn(`[ApiClient] ${o}`),new Error(o)}return await r.json()}catch(r){let s;throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?s="Could not connect to the server. Please check if the server is running.":r.message&&!r.message.includes("Failed to delete file")?s=r.message:s="Failed to delete file. Please try again.",console.warn(`[ApiClient] ${s}`),new Error(s)}}}let T=null;const J=(l,i=null,e=null)=>{T=new D({apiUrl:l,apiKey:i,sessionId:e})};async function*L(l,i=!0,e,t,r,s,o,a,h,p,y){if(!T)throw new Error("API not configured. Please call configureApi() with your server URL before using any API functions.");yield*T.streamChat(l,i,e,t,r,s,o,a,h,p,y)}export{D as ApiClient,J as configureApi,L as streamChat};
@@ -0,0 +1,2 @@
1
+ import{_ as K}from"./index-DQigKykq.js";var j=Object.defineProperty,q=(l,i,e)=>i in l?j(l,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[i]=e,I=(l,i,e)=>q(l,typeof i!="symbol"?i+"":i,e);let F=null,$=null;typeof window>"u"&&Promise.all([K(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]).catch(()=>null),K(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]).catch(()=>null)]).then(([l,i])=>{var e,t;(e=l==null?void 0:l.default)!=null&&e.Agent?F=new l.default.Agent({keepAlive:!0}):l!=null&&l.Agent&&(F=new l.Agent({keepAlive:!0})),(t=i==null?void 0:i.default)!=null&&t.Agent?$=new i.default.Agent({keepAlive:!0}):i!=null&&i.Agent&&($=new i.Agent({keepAlive:!0}))}).catch(l=>{console.warn("Failed to initialize HTTP agents:",l.message)});class D{constructor(i){if(I(this,"apiUrl"),I(this,"apiKey"),I(this,"sessionId"),!i.apiUrl||typeof i.apiUrl!="string")throw new Error("API URL must be a valid string");if(i.apiKey!==void 0&&i.apiKey!==null&&typeof i.apiKey!="string")throw new Error("API key must be a valid string or null");if(i.sessionId!==void 0&&i.sessionId!==null&&typeof i.sessionId!="string")throw new Error("Session ID must be a valid string or null");this.apiUrl=i.apiUrl,this.apiKey=i.apiKey??null,this.sessionId=i.sessionId??null}setSessionId(i){if(i!==null&&typeof i!="string")throw new Error("Session ID must be a valid string or null");this.sessionId=i}getSessionId(){return this.sessionId}async validateApiKey(){var i;if(!this.apiKey)throw new Error("API key is required for validation");try{const e=await fetch(`${this.apiUrl}/admin/api-keys/${this.apiKey}/status`,{...this.getFetchOptions({method:"GET"})}).catch(r=>{throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r});if(!e.ok){let r="";try{r=await e.text()}catch{r=`HTTP ${e.status}`}let s,o;try{const a=JSON.parse(r);s=a.detail||a.message||r}catch{s=r||`HTTP ${e.status}`}switch(e.status){case 401:o="API key is invalid or expired";break;case 403:o="Access denied: API key does not have required permissions";break;case 404:o="API key not found";break;case 503:o="API key management is not available in inference-only mode";break;default:o=`Failed to validate API key: ${s}`;break}throw new Error(o)}const t=await e.json();if(!t.exists){const r="API key does not exist";throw new Error(r)}if(!t.active){const r="API key is inactive";throw new Error(r)}return t}catch(e){let t;throw e instanceof Error&&e.message?e.message.includes("API key")||e.message.includes("Access denied")||e.message.includes("invalid")||e.message.includes("expired")||e.message.includes("inactive")||e.message.includes("not found")||e.message.includes("Could not connect")?t=e.message:t=`API key validation failed: ${e.message}`:e.name==="TypeError"&&(i=e.message)!=null&&i.includes("Failed to fetch")?t="Could not connect to the server. Please check if the server is running.":t="API key validation failed. Please check your API key and try again.",console.warn(`[ApiClient] ${t}`),new Error(t)}}async getAdapterInfo(){var i;if(!this.apiKey)throw new Error("API key is required to get adapter information");try{const e=await fetch(`${this.apiUrl}/admin/api-keys/info`,{...this.getFetchOptions({method:"GET"})}).catch(t=>{throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t});if(!e.ok){let t="";try{t=await e.text()}catch{t=`HTTP ${e.status}`}let r,s;try{const o=JSON.parse(t);r=o.detail||o.message||t}catch{r=t||`HTTP ${e.status}`}switch(e.status){case 401:s="API key is invalid, disabled, or has no associated adapter";break;case 404:s="Adapter configuration not found";break;case 503:s="Service is not available";break;default:s=`Failed to get adapter info: ${r}`;break}throw new Error(s)}return await e.json()}catch(e){let t;throw e instanceof Error&&e.message?e.message.includes("API key")||e.message.includes("Adapter")||e.message.includes("invalid")||e.message.includes("disabled")||e.message.includes("not found")||e.message.includes("Could not connect")?t=e.message:t=`Failed to get adapter info: ${e.message}`:e.name==="TypeError"&&(i=e.message)!=null&&i.includes("Failed to fetch")?t="Could not connect to the server. Please check if the server is running.":t="Failed to get adapter information. Please try again.",console.warn(`[ApiClient] ${t}`),new Error(t)}}getFetchOptions(i={}){const e={};if(typeof window>"u"){const r=this.apiUrl.startsWith("https:")?$:F;r&&(e.agent=r)}else e.headers={Connection:"keep-alive"};const t={"X-Request-ID":Date.now().toString(36)+Math.random().toString(36).substring(2)};if(e.headers&&Object.assign(t,e.headers),i.headers){const r=i.headers;for(const[s,o]of Object.entries(r))(s.toLowerCase()!=="x-api-key"||!this.apiKey)&&(t[s]=o)}return this.apiKey&&(t["X-API-Key"]=this.apiKey),this.sessionId&&(t["X-Session-ID"]=this.sessionId),{...i,...e,headers:t}}createChatRequest(i,e=!0,t,r,s,o,a,h,p,y,v){const c={messages:[{role:"user",content:i}],stream:e};return t&&t.length>0&&(c.file_ids=t),r&&(c.thread_id=r),s&&(c.audio_input=s),o&&(c.audio_format=o),a&&(c.language=a),h!==void 0&&(c.return_audio=h),p&&(c.tts_voice=p),y&&(c.source_language=y),v&&(c.target_language=v),c}async*streamChat(i,e=!0,t,r,s,o,a,h,p,y,v){var c,C;try{const w=new AbortController,O=setTimeout(()=>w.abort(),6e4),g=await fetch(`${this.apiUrl}/v1/chat`,{...this.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json",Accept:e?"text/event-stream":"application/json"},body:JSON.stringify(this.createChatRequest(i,e,t,r,s,o,a,h,p,y,v))}),signal:w.signal});if(clearTimeout(O),!g.ok){const f=await g.text();throw new Error(`Network response was not ok: ${g.status} ${f}`)}if(!e){const f=await g.json();f.response&&(yield{text:f.response,done:!0,audio:f.audio,audioFormat:f.audio_format});return}const A=(c=g.body)==null?void 0:c.getReader();if(!A)throw new Error("No reader available");const _=new TextDecoder;let u="",E=!1;try{for(;;){const{done:f,value:S}=await A.read();if(f)break;const U=_.decode(S,{stream:!0});u+=U;let k=0,P;for(;(P=u.indexOf(`
2
+ `,k))!==-1;){const m=u.slice(k,P).trim();if(k=P+1,m&&m.startsWith("data: ")){const d=m.slice(6).trim();if(!d||d==="[DONE]"){yield{text:"",done:!0};return}try{const n=JSON.parse(d);if(n.error){const x=`Server error: ${((C=n.error)==null?void 0:C.message)||n.error||"Unknown server error"}`;throw console.warn(`[ApiClient] ${x}`),new Error(x)}if(n.done===!0){E=!0,yield{text:"",done:!0,audio:n.audio,audioFormat:n.audio_format||n.audioFormat,threading:n.threading};return}const b=n.response||"";n.audio_chunk!==void 0&&(yield{text:"",done:!1,audio_chunk:n.audio_chunk,audioFormat:n.audioFormat||n.audio_format||"opus",chunk_index:n.chunk_index??0}),(b||n.audio)&&(E=!0,yield{text:b,done:n.done||!1,audio:n.audio,audioFormat:n.audio_format||n.audioFormat,threading:n.threading})}catch(n){console.warn("[ApiClient] Unable to parse server response. This may be a temporary issue."),console.warn("[ApiClient] Parse error details:",n==null?void 0:n.message),console.warn("[ApiClient] JSON text length:",d==null?void 0:d.length),console.warn("[ApiClient] JSON text preview (first 200 chars):",d==null?void 0:d.substring(0,200)),console.warn("[ApiClient] JSON text preview (last 200 chars):",d==null?void 0:d.substring(d.length-200))}}else m&&(E=!0,yield{text:m,done:!1})}u=u.slice(k),u.length>1e6&&(console.warn("[ApiClient] Buffer too large, truncating..."),u=u.slice(-5e5))}E&&(yield{text:"",done:!0})}finally{A.releaseLock()}}catch(w){throw w.name==="AbortError"?new Error("Connection timed out. Please check if the server is running."):w.name==="TypeError"&&w.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):w}}async clearConversationHistory(i){const e=i||this.sessionId;if(!e)throw new Error("No session ID provided and no current session available");if(!this.apiKey)throw new Error("API key is required for clearing conversation history");const t={"Content-Type":"application/json","X-Session-ID":e,"X-API-Key":this.apiKey};try{const r=await fetch(`${this.apiUrl}/admin/chat-history/${e}`,{...this.getFetchOptions({method:"DELETE",headers:t})});if(!r.ok){const s=await r.text();throw new Error(`Failed to clear conversation history: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async deleteConversationWithFiles(i,e){const t=i||this.sessionId;if(!t)throw new Error("No session ID provided and no current session available");if(!this.apiKey)throw new Error("API key is required for deleting conversation");const r={"Content-Type":"application/json","X-Session-ID":t,"X-API-Key":this.apiKey},s=e&&e.length>0?`?file_ids=${e.join(",")}`:"",o=`${this.apiUrl}/admin/conversations/${t}${s}`;try{const a=await fetch(o,{...this.getFetchOptions({method:"DELETE",headers:r})});if(!a.ok){const h=await a.text();throw new Error(`Failed to delete conversation: ${a.status} ${h}`)}return await a.json()}catch(a){throw a.name==="TypeError"&&a.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):a}}async createThread(i,e){if(!this.apiKey)throw new Error("API key is required for creating threads");const t={"Content-Type":"application/json","X-API-Key":this.apiKey};try{const r=await fetch(`${this.apiUrl}/api/threads`,{...this.getFetchOptions({method:"POST",headers:t,body:JSON.stringify({message_id:i,session_id:e})})});if(!r.ok){const s=await r.text();throw new Error(`Failed to create thread: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async getThreadInfo(i){if(!this.apiKey)throw new Error("API key is required for getting thread info");const e={"X-API-Key":this.apiKey};try{const t=await fetch(`${this.apiUrl}/api/threads/${i}`,{...this.getFetchOptions({method:"GET",headers:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to get thread info: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async deleteThread(i){if(!this.apiKey)throw new Error("API key is required for deleting threads");const e={"X-API-Key":this.apiKey};try{const t=await fetch(`${this.apiUrl}/api/threads/${i}`,{...this.getFetchOptions({method:"DELETE",headers:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to delete thread: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async uploadFile(i){if(!this.apiKey)throw new Error("API key is required for file upload");const e=new FormData;e.append("file",i);try{const t=await fetch(`${this.apiUrl}/api/files/upload`,{...this.getFetchOptions({method:"POST",body:e})});if(!t.ok){const r=await t.text();throw new Error(`Failed to upload file: ${t.status} ${r}`)}return await t.json()}catch(t){throw t.name==="TypeError"&&t.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):t}}async listFiles(){if(!this.apiKey)throw new Error("API key is required for listing files");try{const i=await fetch(`${this.apiUrl}/api/files`,{...this.getFetchOptions({method:"GET"})});if(!i.ok){const e=await i.text();throw new Error(`Failed to list files: ${i.status} ${e}`)}return await i.json()}catch(i){throw i.name==="TypeError"&&i.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):i}}async getFileInfo(i){if(!this.apiKey)throw new Error("API key is required for getting file info");try{const e=await fetch(`${this.apiUrl}/api/files/${i}`,{...this.getFetchOptions({method:"GET"})});if(!e.ok){const t=await e.text();throw new Error(`Failed to get file info: ${e.status} ${t}`)}return await e.json()}catch(e){throw e.name==="TypeError"&&e.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):e}}async queryFile(i,e,t=10){if(!this.apiKey)throw new Error("API key is required for querying files");try{const r=await fetch(`${this.apiUrl}/api/files/${i}/query`,{...this.getFetchOptions({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:e,max_results:t})})});if(!r.ok){const s=await r.text();throw new Error(`Failed to query file: ${r.status} ${s}`)}return await r.json()}catch(r){throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?new Error("Could not connect to the server. Please check if the server is running."):r}}async deleteFile(i){if(!this.apiKey)throw new Error("API key is required for deleting files");const e=`${this.apiUrl}/api/files/${i}`,t=this.getFetchOptions({method:"DELETE"});try{const r=await fetch(e,t);if(!r.ok){const s=await r.text();let o;try{const a=JSON.parse(s);o=a.detail||a.message||`Failed to delete file (HTTP ${r.status})`}catch{o=`Failed to delete file (HTTP ${r.status})`}throw console.warn(`[ApiClient] ${o}`),new Error(o)}return await r.json()}catch(r){let s;throw r.name==="TypeError"&&r.message.includes("Failed to fetch")?s="Could not connect to the server. Please check if the server is running.":r.message&&!r.message.includes("Failed to delete file")?s=r.message:s="Failed to delete file. Please try again.",console.warn(`[ApiClient] ${s}`),new Error(s)}}}let T=null;const J=(l,i=null,e=null)=>{T=new D({apiUrl:l,apiKey:i,sessionId:e})};async function*L(l,i=!0,e,t,r,s,o,a,h,p,y){if(!T)throw new Error("API not configured. Please call configureApi() with your server URL before using any API functions.");yield*T.streamChat(l,i,e,t,r,s,o,a,h,p,y)}export{D as ApiClient,J as configureApi,L as streamChat};
@@ -0,0 +1 @@
1
+ import{aP as sn,aQ as an,aR as I,aS as X,ag as Z,aT as un,aU as l,ai as on,aV as Y,aW as q,aX as cn,aY as e,aZ as en,a_ as rn,a$ as yn}from"./index-DQigKykq.js";function fn(s){return s.innerRadius}function ln(s){return s.outerRadius}function mn(s){return s.startAngle}function gn(s){return s.endAngle}function pn(s){return s&&s.padAngle}function xn(s,v,D,O,R,d,_,a){var K=D-s,r=O-v,n=_-R,g=a-d,u=g*K-n*r;if(!(u*u<l))return u=(n*(v-d)-g*(s-R))/u,[s+u*K,v+u*r]}function H(s,v,D,O,R,d,_){var a=s-D,K=v-O,r=(_?d:-d)/Y(a*a+K*K),n=r*K,g=-r*a,u=s+n,i=v+g,y=D+n,f=O+g,B=(u+y)/2,o=(i+f)/2,p=y-u,m=f-i,T=p*p+m*m,A=R-d,E=u*f-y*i,S=(m<0?-1:1)*Y(en(0,A*A*T-E*E)),U=(E*m-p*S)/T,V=(-E*p-m*S)/T,W=(E*m+p*S)/T,x=(-E*p+m*S)/T,h=U-B,t=V-o,c=W-B,Q=x-o;return h*h+t*t>c*c+Q*Q&&(U=W,V=x),{cx:U,cy:V,x01:-n,y01:-g,x11:U*(R/A-1),y11:V*(R/A-1)}}function vn(){var s=fn,v=ln,D=Z(0),O=null,R=mn,d=gn,_=pn,a=null,K=sn(r);function r(){var n,g,u=+s.apply(this,arguments),i=+v.apply(this,arguments),y=R.apply(this,arguments)-un,f=d.apply(this,arguments)-un,B=cn(f-y),o=f>y;if(a||(a=n=K()),i<u&&(g=i,i=u,u=g),!(i>l))a.moveTo(0,0);else if(B>on-l)a.moveTo(i*I(y),i*X(y)),a.arc(0,0,i,y,f,!o),u>l&&(a.moveTo(u*I(f),u*X(f)),a.arc(0,0,u,f,y,o));else{var p=y,m=f,T=y,A=f,E=B,S=B,U=_.apply(this,arguments)/2,V=U>l&&(O?+O.apply(this,arguments):Y(u*u+i*i)),W=q(cn(i-u)/2,+D.apply(this,arguments)),x=W,h=W,t,c;if(V>l){var Q=rn(V/u*X(U)),$=rn(V/i*X(U));(E-=Q*2)>l?(Q*=o?1:-1,T+=Q,A-=Q):(E=0,T=A=(y+f)/2),(S-=$*2)>l?($*=o?1:-1,p+=$,m-=$):(S=0,p=m=(y+f)/2)}var L=i*I(p),M=i*X(p),b=u*I(A),k=u*X(A);if(W>l){var F=i*I(m),G=i*X(m),N=u*I(T),C=u*X(T),P;if(B<an)if(P=xn(L,M,N,C,F,G,b,k)){var J=L-P[0],j=M-P[1],w=F-P[0],z=G-P[1],nn=1/X(yn((J*w+j*z)/(Y(J*J+j*j)*Y(w*w+z*z)))/2),tn=Y(P[0]*P[0]+P[1]*P[1]);x=q(W,(u-tn)/(nn-1)),h=q(W,(i-tn)/(nn+1))}else x=h=0}S>l?h>l?(t=H(N,C,L,M,i,h,o),c=H(F,G,b,k,i,h,o),a.moveTo(t.cx+t.x01,t.cy+t.y01),h<W?a.arc(t.cx,t.cy,h,e(t.y01,t.x01),e(c.y01,c.x01),!o):(a.arc(t.cx,t.cy,h,e(t.y01,t.x01),e(t.y11,t.x11),!o),a.arc(0,0,i,e(t.cy+t.y11,t.cx+t.x11),e(c.cy+c.y11,c.cx+c.x11),!o),a.arc(c.cx,c.cy,h,e(c.y11,c.x11),e(c.y01,c.x01),!o))):(a.moveTo(L,M),a.arc(0,0,i,p,m,!o)):a.moveTo(L,M),!(u>l)||!(E>l)?a.lineTo(b,k):x>l?(t=H(b,k,F,G,u,-x,o),c=H(L,M,N,C,u,-x,o),a.lineTo(t.cx+t.x01,t.cy+t.y01),x<W?a.arc(t.cx,t.cy,x,e(t.y01,t.x01),e(c.y01,c.x01),!o):(a.arc(t.cx,t.cy,x,e(t.y01,t.x01),e(t.y11,t.x11),!o),a.arc(0,0,u,e(t.cy+t.y11,t.cx+t.x11),e(c.cy+c.y11,c.cx+c.x11),o),a.arc(c.cx,c.cy,x,e(c.y11,c.x11),e(c.y01,c.x01),!o))):a.arc(0,0,u,A,T,o)}if(a.closePath(),n)return a=null,n+""||null}return r.centroid=function(){var n=(+s.apply(this,arguments)+ +v.apply(this,arguments))/2,g=(+R.apply(this,arguments)+ +d.apply(this,arguments))/2-an/2;return[I(g)*n,X(g)*n]},r.innerRadius=function(n){return arguments.length?(s=typeof n=="function"?n:Z(+n),r):s},r.outerRadius=function(n){return arguments.length?(v=typeof n=="function"?n:Z(+n),r):v},r.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Z(+n),r):D},r.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:Z(+n),r):O},r.startAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Z(+n),r):R},r.endAngle=function(n){return arguments.length?(d=typeof n=="function"?n:Z(+n),r):d},r.padAngle=function(n){return arguments.length?(_=typeof n=="function"?n:Z(+n),r):_},r.context=function(n){return arguments.length?(a=n??null,r):a},r}export{vn as h};
@@ -1,9 +1,9 @@
1
- import{ak as se,r as me,P as q,V as _e,O as f,ae as ke,m as Ee,l as De,g as ge,a as we}from"./index-CV3ovvq1.js";import{a as ve}from"./clone-C0MdfhAf-_B1M49Tw.js";import{c as Ne,g as $e,x as Te,d as Oe,h as de,p as Ie}from"./edges-96097737-BnGLzlID--RpsQPpU.js";import{K as Ae}from"./graph-CvRY9YIM-BVZjlKfa.js";import{t as Ce}from"./channel-BYhLgIow-BPTRMgNI.js";import{r as Re}from"./Tableau10-D7jGxypv-Cyu9clx1.js";import"./createText-1719965b-D5GExXUl-CSo0puOR.js";var oe,ae,ee=function(){var e=function(m,s,r,l){for(r=r||{},l=m.length;l--;r[m[l]]=s);return r},o=[1,7],h=[1,13],c=[1,14],n=[1,15],g=[1,19],a=[1,16],y=[1,17],b=[1,18],d=[8,30],x=[8,21,28,29,30,31,32,40,44,47],_=[1,23],T=[1,24],k=[8,15,16,21,28,29,30,31,32,40,44,47],v=[8,15,16,21,27,28,29,30,31,32,40,44,47],L=[1,49],D={trace:function(){},yy:{},symbols_:{error:2,spaceLines:3,SPACELINE:4,NL:5,separator:6,SPACE:7,EOF:8,start:9,BLOCK_DIAGRAM_KEY:10,document:11,stop:12,statement:13,link:14,LINK:15,START_LINK:16,LINK_LABEL:17,STR:18,nodeStatement:19,columnsStatement:20,SPACE_BLOCK:21,blockStatement:22,classDefStatement:23,cssClassStatement:24,styleStatement:25,node:26,SIZE:27,COLUMNS:28,"id-block":29,end:30,block:31,NODE_ID:32,nodeShapeNLabel:33,dirList:34,DIR:35,NODE_DSTART:36,NODE_DEND:37,BLOCK_ARROW_START:38,BLOCK_ARROW_END:39,classDef:40,CLASSDEF_ID:41,CLASSDEF_STYLEOPTS:42,DEFAULT:43,class:44,CLASSENTITY_IDS:45,STYLECLASS:46,style:47,STYLE_ENTITY_IDS:48,STYLE_DEFINITION_DATA:49,$accept:0,$end:1},terminals_:{2:"error",4:"SPACELINE",5:"NL",7:"SPACE",8:"EOF",10:"BLOCK_DIAGRAM_KEY",15:"LINK",16:"START_LINK",17:"LINK_LABEL",18:"STR",21:"SPACE_BLOCK",27:"SIZE",28:"COLUMNS",29:"id-block",30:"end",31:"block",32:"NODE_ID",35:"DIR",36:"NODE_DSTART",37:"NODE_DEND",38:"BLOCK_ARROW_START",39:"BLOCK_ARROW_END",40:"classDef",41:"CLASSDEF_ID",42:"CLASSDEF_STYLEOPTS",43:"DEFAULT",44:"class",45:"CLASSENTITY_IDS",46:"STYLECLASS",47:"style",48:"STYLE_ENTITY_IDS",49:"STYLE_DEFINITION_DATA"},productions_:[0,[3,1],[3,2],[3,2],[6,1],[6,1],[6,1],[9,3],[12,1],[12,1],[12,2],[12,2],[11,1],[11,2],[14,1],[14,4],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[19,3],[19,2],[19,1],[20,1],[22,4],[22,3],[26,1],[26,2],[34,1],[34,2],[33,3],[33,4],[23,3],[23,3],[24,3],[25,3]],performAction:function(m,s,r,l,p,t,u){var i=t.length-1;switch(p){case 4:l.getLogger().debug("Rule: separator (NL) ");break;case 5:l.getLogger().debug("Rule: separator (Space) ");break;case 6:l.getLogger().debug("Rule: separator (EOF) ");break;case 7:l.getLogger().debug("Rule: hierarchy: ",t[i-1]),l.setHierarchy(t[i-1]);break;case 8:l.getLogger().debug("Stop NL ");break;case 9:l.getLogger().debug("Stop EOF ");break;case 10:l.getLogger().debug("Stop NL2 ");break;case 11:l.getLogger().debug("Stop EOF2 ");break;case 12:l.getLogger().debug("Rule: statement: ",t[i]),typeof t[i].length=="number"?this.$=t[i]:this.$=[t[i]];break;case 13:l.getLogger().debug("Rule: statement #2: ",t[i-1]),this.$=[t[i-1]].concat(t[i]);break;case 14:l.getLogger().debug("Rule: link: ",t[i],m),this.$={edgeTypeStr:t[i],label:""};break;case 15:l.getLogger().debug("Rule: LABEL link: ",t[i-3],t[i-1],t[i]),this.$={edgeTypeStr:t[i],label:t[i-1]};break;case 18:const O=parseInt(t[i]),B=l.generateId();this.$={id:B,type:"space",label:"",width:O,children:[]};break;case 23:l.getLogger().debug("Rule: (nodeStatement link node) ",t[i-2],t[i-1],t[i]," typestr: ",t[i-1].edgeTypeStr);const X=l.edgeStrToEdgeData(t[i-1].edgeTypeStr);this.$=[{id:t[i-2].id,label:t[i-2].label,type:t[i-2].type,directions:t[i-2].directions},{id:t[i-2].id+"-"+t[i].id,start:t[i-2].id,end:t[i].id,label:t[i-1].label,type:"edge",directions:t[i].directions,arrowTypeEnd:X,arrowTypeStart:"arrow_open"},{id:t[i].id,label:t[i].label,type:l.typeStr2Type(t[i].typeStr),directions:t[i].directions}];break;case 24:l.getLogger().debug("Rule: nodeStatement (abc88 node size) ",t[i-1],t[i]),this.$={id:t[i-1].id,label:t[i-1].label,type:l.typeStr2Type(t[i-1].typeStr),directions:t[i-1].directions,widthInColumns:parseInt(t[i],10)};break;case 25:l.getLogger().debug("Rule: nodeStatement (node) ",t[i]),this.$={id:t[i].id,label:t[i].label,type:l.typeStr2Type(t[i].typeStr),directions:t[i].directions,widthInColumns:1};break;case 26:l.getLogger().debug("APA123",this?this:"na"),l.getLogger().debug("COLUMNS: ",t[i]),this.$={type:"column-setting",columns:t[i]==="auto"?-1:parseInt(t[i])};break;case 27:l.getLogger().debug("Rule: id-block statement : ",t[i-2],t[i-1]),l.generateId(),this.$={...t[i-2],type:"composite",children:t[i-1]};break;case 28:l.getLogger().debug("Rule: blockStatement : ",t[i-2],t[i-1],t[i]);const C=l.generateId();this.$={id:C,type:"composite",label:"",children:t[i-1]};break;case 29:l.getLogger().debug("Rule: node (NODE_ID separator): ",t[i]),this.$={id:t[i]};break;case 30:l.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ",t[i-1],t[i]),this.$={id:t[i-1],label:t[i].label,typeStr:t[i].typeStr,directions:t[i].directions};break;case 31:l.getLogger().debug("Rule: dirList: ",t[i]),this.$=[t[i]];break;case 32:l.getLogger().debug("Rule: dirList: ",t[i-1],t[i]),this.$=[t[i-1]].concat(t[i]);break;case 33:l.getLogger().debug("Rule: nodeShapeNLabel: ",t[i-2],t[i-1],t[i]),this.$={typeStr:t[i-2]+t[i],label:t[i-1]};break;case 34:l.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ",t[i-3],t[i-2]," #3:",t[i-1],t[i]),this.$={typeStr:t[i-3]+t[i],label:t[i-2],directions:t[i-1]};break;case 35:case 36:this.$={type:"classDef",id:t[i-1].trim(),css:t[i].trim()};break;case 37:this.$={type:"applyClass",id:t[i-1].trim(),styleClass:t[i].trim()};break;case 38:this.$={type:"applyStyles",id:t[i-1].trim(),stylesStr:t[i].trim()};break}},table:[{9:1,10:[1,2]},{1:[3]},{11:3,13:4,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{8:[1,20]},e(d,[2,12],{13:4,19:5,20:6,22:8,23:9,24:10,25:11,26:12,11:21,21:o,28:h,29:c,31:n,32:g,40:a,44:y,47:b}),e(x,[2,16],{14:22,15:_,16:T}),e(x,[2,17]),e(x,[2,18]),e(x,[2,19]),e(x,[2,20]),e(x,[2,21]),e(x,[2,22]),e(k,[2,25],{27:[1,25]}),e(x,[2,26]),{19:26,26:12,32:g},{11:27,13:4,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{41:[1,28],43:[1,29]},{45:[1,30]},{48:[1,31]},e(v,[2,29],{33:32,36:[1,33],38:[1,34]}),{1:[2,7]},e(d,[2,13]),{26:35,32:g},{32:[2,14]},{17:[1,36]},e(k,[2,24]),{11:37,13:4,14:22,15:_,16:T,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{30:[1,38]},{42:[1,39]},{42:[1,40]},{46:[1,41]},{49:[1,42]},e(v,[2,30]),{18:[1,43]},{18:[1,44]},e(k,[2,23]),{18:[1,45]},{30:[1,46]},e(x,[2,28]),e(x,[2,35]),e(x,[2,36]),e(x,[2,37]),e(x,[2,38]),{37:[1,47]},{34:48,35:L},{15:[1,50]},e(x,[2,27]),e(v,[2,33]),{39:[1,51]},{34:52,35:L,39:[2,31]},{32:[2,15]},e(v,[2,34]),{39:[2,32]}],defaultActions:{20:[2,7],23:[2,14],50:[2,15],52:[2,32]},parseError:function(m,s){if(s.recoverable)this.trace(m);else{var r=new Error(m);throw r.hash=s,r}},parse:function(m){var s=this,r=[0],l=[],p=[null],t=[],u=this.table,i="",O=0,B=0,X=2,C=1,P=t.slice.call(arguments,1),E=Object.create(this.lexer),F={yy:{}};for(var G in this.yy)Object.prototype.hasOwnProperty.call(this.yy,G)&&(F.yy[G]=this.yy[G]);E.setInput(m,F.yy),F.yy.lexer=E,F.yy.parser=this,typeof E.yylloc>"u"&&(E.yylloc={});var J=E.yylloc;t.push(J);var Le=E.options&&E.options.ranges;typeof F.yy.parseError=="function"?this.parseError=F.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Se(){var z;return z=l.pop()||E.lex()||C,typeof z!="number"&&(z instanceof Array&&(l=z,z=l.pop()),z=s.symbols_[z]||z),z}for(var N,Y,I,Z,K={},j,R,le,H;;){if(Y=r[r.length-1],this.defaultActions[Y]?I=this.defaultActions[Y]:((N===null||typeof N>"u")&&(N=Se()),I=u[Y]&&u[Y][N]),typeof I>"u"||!I.length||!I[0]){var Q="";H=[];for(j in u[Y])this.terminals_[j]&&j>X&&H.push("'"+this.terminals_[j]+"'");E.showPosition?Q="Parse error on line "+(O+1)+`:
1
+ import{ak as se,o as me,F as q,J as _e,O as f,ae as ke,j as Ee,p as De,S as ge,b as we}from"./index-DQigKykq.js";import{a as ve}from"./clone-D01vUIhD-BmKLNBjy.js";import{c as Ne,g as $e,x as Te,d as Oe,h as de,p as Ie}from"./edges-96097737-Zc6U9nQz-Bwo4-Nya.js";import{K as Ae}from"./graph-BZahQKIN-Dz7VTHix.js";import{t as Ce}from"./channel-6PI3wNcc-xC-uPvXz.js";import{r as ze}from"./Tableau10-D7jGxypv-Cyu9clx1.js";import"./createText-1719965b-D9Y3vUMn-eo4dwQ-N.js";var oe,ae,ee=function(){var e=function(m,s,r,l){for(r=r||{},l=m.length;l--;r[m[l]]=s);return r},o=[1,7],h=[1,13],c=[1,14],n=[1,15],g=[1,19],a=[1,16],y=[1,17],b=[1,18],d=[8,30],x=[8,21,28,29,30,31,32,40,44,47],_=[1,23],T=[1,24],k=[8,15,16,21,28,29,30,31,32,40,44,47],v=[8,15,16,21,27,28,29,30,31,32,40,44,47],L=[1,49],D={trace:function(){},yy:{},symbols_:{error:2,spaceLines:3,SPACELINE:4,NL:5,separator:6,SPACE:7,EOF:8,start:9,BLOCK_DIAGRAM_KEY:10,document:11,stop:12,statement:13,link:14,LINK:15,START_LINK:16,LINK_LABEL:17,STR:18,nodeStatement:19,columnsStatement:20,SPACE_BLOCK:21,blockStatement:22,classDefStatement:23,cssClassStatement:24,styleStatement:25,node:26,SIZE:27,COLUMNS:28,"id-block":29,end:30,block:31,NODE_ID:32,nodeShapeNLabel:33,dirList:34,DIR:35,NODE_DSTART:36,NODE_DEND:37,BLOCK_ARROW_START:38,BLOCK_ARROW_END:39,classDef:40,CLASSDEF_ID:41,CLASSDEF_STYLEOPTS:42,DEFAULT:43,class:44,CLASSENTITY_IDS:45,STYLECLASS:46,style:47,STYLE_ENTITY_IDS:48,STYLE_DEFINITION_DATA:49,$accept:0,$end:1},terminals_:{2:"error",4:"SPACELINE",5:"NL",7:"SPACE",8:"EOF",10:"BLOCK_DIAGRAM_KEY",15:"LINK",16:"START_LINK",17:"LINK_LABEL",18:"STR",21:"SPACE_BLOCK",27:"SIZE",28:"COLUMNS",29:"id-block",30:"end",31:"block",32:"NODE_ID",35:"DIR",36:"NODE_DSTART",37:"NODE_DEND",38:"BLOCK_ARROW_START",39:"BLOCK_ARROW_END",40:"classDef",41:"CLASSDEF_ID",42:"CLASSDEF_STYLEOPTS",43:"DEFAULT",44:"class",45:"CLASSENTITY_IDS",46:"STYLECLASS",47:"style",48:"STYLE_ENTITY_IDS",49:"STYLE_DEFINITION_DATA"},productions_:[0,[3,1],[3,2],[3,2],[6,1],[6,1],[6,1],[9,3],[12,1],[12,1],[12,2],[12,2],[11,1],[11,2],[14,1],[14,4],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[19,3],[19,2],[19,1],[20,1],[22,4],[22,3],[26,1],[26,2],[34,1],[34,2],[33,3],[33,4],[23,3],[23,3],[24,3],[25,3]],performAction:function(m,s,r,l,p,t,u){var i=t.length-1;switch(p){case 4:l.getLogger().debug("Rule: separator (NL) ");break;case 5:l.getLogger().debug("Rule: separator (Space) ");break;case 6:l.getLogger().debug("Rule: separator (EOF) ");break;case 7:l.getLogger().debug("Rule: hierarchy: ",t[i-1]),l.setHierarchy(t[i-1]);break;case 8:l.getLogger().debug("Stop NL ");break;case 9:l.getLogger().debug("Stop EOF ");break;case 10:l.getLogger().debug("Stop NL2 ");break;case 11:l.getLogger().debug("Stop EOF2 ");break;case 12:l.getLogger().debug("Rule: statement: ",t[i]),typeof t[i].length=="number"?this.$=t[i]:this.$=[t[i]];break;case 13:l.getLogger().debug("Rule: statement #2: ",t[i-1]),this.$=[t[i-1]].concat(t[i]);break;case 14:l.getLogger().debug("Rule: link: ",t[i],m),this.$={edgeTypeStr:t[i],label:""};break;case 15:l.getLogger().debug("Rule: LABEL link: ",t[i-3],t[i-1],t[i]),this.$={edgeTypeStr:t[i],label:t[i-1]};break;case 18:const O=parseInt(t[i]),B=l.generateId();this.$={id:B,type:"space",label:"",width:O,children:[]};break;case 23:l.getLogger().debug("Rule: (nodeStatement link node) ",t[i-2],t[i-1],t[i]," typestr: ",t[i-1].edgeTypeStr);const X=l.edgeStrToEdgeData(t[i-1].edgeTypeStr);this.$=[{id:t[i-2].id,label:t[i-2].label,type:t[i-2].type,directions:t[i-2].directions},{id:t[i-2].id+"-"+t[i].id,start:t[i-2].id,end:t[i].id,label:t[i-1].label,type:"edge",directions:t[i].directions,arrowTypeEnd:X,arrowTypeStart:"arrow_open"},{id:t[i].id,label:t[i].label,type:l.typeStr2Type(t[i].typeStr),directions:t[i].directions}];break;case 24:l.getLogger().debug("Rule: nodeStatement (abc88 node size) ",t[i-1],t[i]),this.$={id:t[i-1].id,label:t[i-1].label,type:l.typeStr2Type(t[i-1].typeStr),directions:t[i-1].directions,widthInColumns:parseInt(t[i],10)};break;case 25:l.getLogger().debug("Rule: nodeStatement (node) ",t[i]),this.$={id:t[i].id,label:t[i].label,type:l.typeStr2Type(t[i].typeStr),directions:t[i].directions,widthInColumns:1};break;case 26:l.getLogger().debug("APA123",this?this:"na"),l.getLogger().debug("COLUMNS: ",t[i]),this.$={type:"column-setting",columns:t[i]==="auto"?-1:parseInt(t[i])};break;case 27:l.getLogger().debug("Rule: id-block statement : ",t[i-2],t[i-1]),l.generateId(),this.$={...t[i-2],type:"composite",children:t[i-1]};break;case 28:l.getLogger().debug("Rule: blockStatement : ",t[i-2],t[i-1],t[i]);const C=l.generateId();this.$={id:C,type:"composite",label:"",children:t[i-1]};break;case 29:l.getLogger().debug("Rule: node (NODE_ID separator): ",t[i]),this.$={id:t[i]};break;case 30:l.getLogger().debug("Rule: node (NODE_ID nodeShapeNLabel separator): ",t[i-1],t[i]),this.$={id:t[i-1],label:t[i].label,typeStr:t[i].typeStr,directions:t[i].directions};break;case 31:l.getLogger().debug("Rule: dirList: ",t[i]),this.$=[t[i]];break;case 32:l.getLogger().debug("Rule: dirList: ",t[i-1],t[i]),this.$=[t[i-1]].concat(t[i]);break;case 33:l.getLogger().debug("Rule: nodeShapeNLabel: ",t[i-2],t[i-1],t[i]),this.$={typeStr:t[i-2]+t[i],label:t[i-1]};break;case 34:l.getLogger().debug("Rule: BLOCK_ARROW nodeShapeNLabel: ",t[i-3],t[i-2]," #3:",t[i-1],t[i]),this.$={typeStr:t[i-3]+t[i],label:t[i-2],directions:t[i-1]};break;case 35:case 36:this.$={type:"classDef",id:t[i-1].trim(),css:t[i].trim()};break;case 37:this.$={type:"applyClass",id:t[i-1].trim(),styleClass:t[i].trim()};break;case 38:this.$={type:"applyStyles",id:t[i-1].trim(),stylesStr:t[i].trim()};break}},table:[{9:1,10:[1,2]},{1:[3]},{11:3,13:4,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{8:[1,20]},e(d,[2,12],{13:4,19:5,20:6,22:8,23:9,24:10,25:11,26:12,11:21,21:o,28:h,29:c,31:n,32:g,40:a,44:y,47:b}),e(x,[2,16],{14:22,15:_,16:T}),e(x,[2,17]),e(x,[2,18]),e(x,[2,19]),e(x,[2,20]),e(x,[2,21]),e(x,[2,22]),e(k,[2,25],{27:[1,25]}),e(x,[2,26]),{19:26,26:12,32:g},{11:27,13:4,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{41:[1,28],43:[1,29]},{45:[1,30]},{48:[1,31]},e(v,[2,29],{33:32,36:[1,33],38:[1,34]}),{1:[2,7]},e(d,[2,13]),{26:35,32:g},{32:[2,14]},{17:[1,36]},e(k,[2,24]),{11:37,13:4,14:22,15:_,16:T,19:5,20:6,21:o,22:8,23:9,24:10,25:11,26:12,28:h,29:c,31:n,32:g,40:a,44:y,47:b},{30:[1,38]},{42:[1,39]},{42:[1,40]},{46:[1,41]},{49:[1,42]},e(v,[2,30]),{18:[1,43]},{18:[1,44]},e(k,[2,23]),{18:[1,45]},{30:[1,46]},e(x,[2,28]),e(x,[2,35]),e(x,[2,36]),e(x,[2,37]),e(x,[2,38]),{37:[1,47]},{34:48,35:L},{15:[1,50]},e(x,[2,27]),e(v,[2,33]),{39:[1,51]},{34:52,35:L,39:[2,31]},{32:[2,15]},e(v,[2,34]),{39:[2,32]}],defaultActions:{20:[2,7],23:[2,14],50:[2,15],52:[2,32]},parseError:function(m,s){if(s.recoverable)this.trace(m);else{var r=new Error(m);throw r.hash=s,r}},parse:function(m){var s=this,r=[0],l=[],p=[null],t=[],u=this.table,i="",O=0,B=0,X=2,C=1,F=t.slice.call(arguments,1),E=Object.create(this.lexer),P={yy:{}};for(var G in this.yy)Object.prototype.hasOwnProperty.call(this.yy,G)&&(P.yy[G]=this.yy[G]);E.setInput(m,P.yy),P.yy.lexer=E,P.yy.parser=this,typeof E.yylloc>"u"&&(E.yylloc={});var V=E.yylloc;t.push(V);var Le=E.options&&E.options.ranges;typeof P.yy.parseError=="function"?this.parseError=P.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Se(){var R;return R=l.pop()||E.lex()||C,typeof R!="number"&&(R instanceof Array&&(l=R,R=l.pop()),R=s.symbols_[R]||R),R}for(var N,Y,I,Z,K={},j,z,le,H;;){if(Y=r[r.length-1],this.defaultActions[Y]?I=this.defaultActions[Y]:((N===null||typeof N>"u")&&(N=Se()),I=u[Y]&&u[Y][N]),typeof I>"u"||!I.length||!I[0]){var Q="";H=[];for(j in u[Y])this.terminals_[j]&&j>X&&H.push("'"+this.terminals_[j]+"'");E.showPosition?Q="Parse error on line "+(O+1)+`:
2
2
  `+E.showPosition()+`
3
- Expecting `+H.join(", ")+", got '"+(this.terminals_[N]||N)+"'":Q="Parse error on line "+(O+1)+": Unexpected "+(N==C?"end of input":"'"+(this.terminals_[N]||N)+"'"),this.parseError(Q,{text:E.match,token:this.terminals_[N]||N,line:E.yylineno,loc:J,expected:H})}if(I[0]instanceof Array&&I.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Y+", token: "+N);switch(I[0]){case 1:r.push(N),p.push(E.yytext),t.push(E.yylloc),r.push(I[1]),N=null,B=E.yyleng,i=E.yytext,O=E.yylineno,J=E.yylloc;break;case 2:if(R=this.productions_[I[1]][1],K.$=p[p.length-R],K._$={first_line:t[t.length-(R||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(R||1)].first_column,last_column:t[t.length-1].last_column},Le&&(K._$.range=[t[t.length-(R||1)].range[0],t[t.length-1].range[1]]),Z=this.performAction.apply(K,[i,B,O,F.yy,I[1],p,t].concat(P)),typeof Z<"u")return Z;R&&(r=r.slice(0,-1*R*2),p=p.slice(0,-1*R),t=t.slice(0,-1*R)),r.push(this.productions_[I[1]][0]),p.push(K.$),t.push(K._$),le=u[r[r.length-2]][r[r.length-1]],r.push(le);break;case 3:return!0}}return!0}},A=function(){var m={EOF:1,parseError:function(s,r){if(this.yy.parser)this.yy.parser.parseError(s,r);else throw new Error(s)},setInput:function(s,r){return this.yy=r||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var r=s.match(/(?:\r\n?|\n).*/g);return r?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},unput:function(s){var r=s.length,l=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-r),this.offset-=r;var p=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var t=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===p.length?this.yylloc.first_column:0)+p[p.length-l.length].length-l[0].length:this.yylloc.first_column-r},this.options.ranges&&(this.yylloc.range=[t[0],t[0]+this.yyleng-r]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
3
+ Expecting `+H.join(", ")+", got '"+(this.terminals_[N]||N)+"'":Q="Parse error on line "+(O+1)+": Unexpected "+(N==C?"end of input":"'"+(this.terminals_[N]||N)+"'"),this.parseError(Q,{text:E.match,token:this.terminals_[N]||N,line:E.yylineno,loc:V,expected:H})}if(I[0]instanceof Array&&I.length>1)throw new Error("Parse Error: multiple actions possible at state: "+Y+", token: "+N);switch(I[0]){case 1:r.push(N),p.push(E.yytext),t.push(E.yylloc),r.push(I[1]),N=null,B=E.yyleng,i=E.yytext,O=E.yylineno,V=E.yylloc;break;case 2:if(z=this.productions_[I[1]][1],K.$=p[p.length-z],K._$={first_line:t[t.length-(z||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(z||1)].first_column,last_column:t[t.length-1].last_column},Le&&(K._$.range=[t[t.length-(z||1)].range[0],t[t.length-1].range[1]]),Z=this.performAction.apply(K,[i,B,O,P.yy,I[1],p,t].concat(F)),typeof Z<"u")return Z;z&&(r=r.slice(0,-1*z*2),p=p.slice(0,-1*z),t=t.slice(0,-1*z)),r.push(this.productions_[I[1]][0]),p.push(K.$),t.push(K._$),le=u[r[r.length-2]][r[r.length-1]],r.push(le);break;case 3:return!0}}return!0}},A=function(){var m={EOF:1,parseError:function(s,r){if(this.yy.parser)this.yy.parser.parseError(s,r);else throw new Error(s)},setInput:function(s,r){return this.yy=r||this.yy||{},this._input=s,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var s=this._input[0];this.yytext+=s,this.yyleng++,this.offset++,this.match+=s,this.matched+=s;var r=s.match(/(?:\r\n?|\n).*/g);return r?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),s},unput:function(s){var r=s.length,l=s.split(/(?:\r\n?|\n)/g);this._input=s+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-r),this.offset-=r;var p=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var t=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===p.length?this.yylloc.first_column:0)+p[p.length-l.length].length-l[0].length:this.yylloc.first_column-r},this.options.ranges&&(this.yylloc.range=[t[0],t[0]+this.yyleng-r]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(s){this.unput(this.match.slice(s))},pastInput:function(){var s=this.matched.substr(0,this.matched.length-this.match.length);return(s.length>20?"...":"")+s.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var s=this.match;return s.length<20&&(s+=this._input.substr(0,20-s.length)),(s.substr(0,20)+(s.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var s=this.pastInput(),r=new Array(s.length+1).join("-");return s+this.upcomingInput()+`
5
5
  `+r+"^"},test_match:function(s,r){var l,p,t;if(this.options.backtrack_lexer&&(t={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(t.yylloc.range=this.yylloc.range.slice(0))),p=s[0].match(/(?:\r\n?|\n).*/g),p&&(this.yylineno+=p.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:p?p[p.length-1].length-p[p.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+s[0].length},this.yytext+=s[0],this.match+=s[0],this.matches=s,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(s[0].length),this.matched+=s[0],l=this.performAction.call(this,this.yy,this,r,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),l)return l;if(this._backtrack){for(var u in t)this[u]=t[u];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var s,r,l,p;this._more||(this.yytext="",this.match="");for(var t=this._currentRules(),u=0;u<t.length;u++)if(l=this._input.match(this.rules[t[u]]),l&&(!r||l[0].length>r[0].length)){if(r=l,p=u,this.options.backtrack_lexer){if(s=this.test_match(l,t[u]),s!==!1)return s;if(this._backtrack){r=!1;continue}else return!1}else if(!this.options.flex)break}return r?(s=this.test_match(r,t[p]),s!==!1?s:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
6
- `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var s=this.next();return s||this.lex()},begin:function(s){this.conditionStack.push(s)},popState:function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},pushState:function(s){this.begin(s)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(s,r,l,p){switch(l){case 0:return 10;case 1:return s.getLogger().debug("Found space-block"),31;case 2:return s.getLogger().debug("Found nl-block"),31;case 3:return s.getLogger().debug("Found space-block"),29;case 4:s.getLogger().debug(".",r.yytext);break;case 5:s.getLogger().debug("_",r.yytext);break;case 6:return 5;case 7:return r.yytext=-1,28;case 8:return r.yytext=r.yytext.replace(/columns\s+/,""),s.getLogger().debug("COLUMNS (LEX)",r.yytext),28;case 9:this.pushState("md_string");break;case 10:return"MD_STR";case 11:this.popState();break;case 12:this.pushState("string");break;case 13:s.getLogger().debug("LEX: POPPING STR:",r.yytext),this.popState();break;case 14:return s.getLogger().debug("LEX: STR end:",r.yytext),"STR";case 15:return r.yytext=r.yytext.replace(/space\:/,""),s.getLogger().debug("SPACE NUM (LEX)",r.yytext),21;case 16:return r.yytext="1",s.getLogger().debug("COLUMNS (LEX)",r.yytext),21;case 17:return 43;case 18:return"LINKSTYLE";case 19:return"INTERPOLATE";case 20:return this.pushState("CLASSDEF"),40;case 21:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";case 22:return this.popState(),this.pushState("CLASSDEFID"),41;case 23:return this.popState(),42;case 24:return this.pushState("CLASS"),44;case 25:return this.popState(),this.pushState("CLASS_STYLE"),45;case 26:return this.popState(),46;case 27:return this.pushState("STYLE_STMNT"),47;case 28:return this.popState(),this.pushState("STYLE_DEFINITION"),48;case 29:return this.popState(),49;case 30:return this.pushState("acc_title"),"acc_title";case 31:return this.popState(),"acc_title_value";case 32:return this.pushState("acc_descr"),"acc_descr";case 33:return this.popState(),"acc_descr_value";case 34:this.pushState("acc_descr_multiline");break;case 35:this.popState();break;case 36:return"acc_descr_multiline_value";case 37:return 30;case 38:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 39:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 40:return this.popState(),s.getLogger().debug("Lex: ))"),"NODE_DEND";case 41:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 42:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 43:return this.popState(),s.getLogger().debug("Lex: (-"),"NODE_DEND";case 44:return this.popState(),s.getLogger().debug("Lex: -)"),"NODE_DEND";case 45:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 46:return this.popState(),s.getLogger().debug("Lex: ]]"),"NODE_DEND";case 47:return this.popState(),s.getLogger().debug("Lex: ("),"NODE_DEND";case 48:return this.popState(),s.getLogger().debug("Lex: ])"),"NODE_DEND";case 49:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";case 50:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";case 51:return this.popState(),s.getLogger().debug("Lex: )]"),"NODE_DEND";case 52:return this.popState(),s.getLogger().debug("Lex: )"),"NODE_DEND";case 53:return this.popState(),s.getLogger().debug("Lex: ]>"),"NODE_DEND";case 54:return this.popState(),s.getLogger().debug("Lex: ]"),"NODE_DEND";case 55:return s.getLogger().debug("Lexa: -)"),this.pushState("NODE"),36;case 56:return s.getLogger().debug("Lexa: (-"),this.pushState("NODE"),36;case 57:return s.getLogger().debug("Lexa: ))"),this.pushState("NODE"),36;case 58:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 59:return s.getLogger().debug("Lex: ((("),this.pushState("NODE"),36;case 60:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 61:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 62:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 63:return s.getLogger().debug("Lexc: >"),this.pushState("NODE"),36;case 64:return s.getLogger().debug("Lexa: (["),this.pushState("NODE"),36;case 65:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 66:return this.pushState("NODE"),36;case 67:return this.pushState("NODE"),36;case 68:return this.pushState("NODE"),36;case 69:return this.pushState("NODE"),36;case 70:return this.pushState("NODE"),36;case 71:return this.pushState("NODE"),36;case 72:return this.pushState("NODE"),36;case 73:return s.getLogger().debug("Lexa: ["),this.pushState("NODE"),36;case 74:return this.pushState("BLOCK_ARROW"),s.getLogger().debug("LEX ARR START"),38;case 75:return s.getLogger().debug("Lex: NODE_ID",r.yytext),32;case 76:return s.getLogger().debug("Lex: EOF",r.yytext),8;case 77:this.pushState("md_string");break;case 78:this.pushState("md_string");break;case 79:return"NODE_DESCR";case 80:this.popState();break;case 81:s.getLogger().debug("Lex: Starting string"),this.pushState("string");break;case 82:s.getLogger().debug("LEX ARR: Starting string"),this.pushState("string");break;case 83:return s.getLogger().debug("LEX: NODE_DESCR:",r.yytext),"NODE_DESCR";case 84:s.getLogger().debug("LEX POPPING"),this.popState();break;case 85:s.getLogger().debug("Lex: =>BAE"),this.pushState("ARROW_DIR");break;case 86:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (right): dir:",r.yytext),"DIR";case 87:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (left):",r.yytext),"DIR";case 88:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (x):",r.yytext),"DIR";case 89:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (y):",r.yytext),"DIR";case 90:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (up):",r.yytext),"DIR";case 91:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (down):",r.yytext),"DIR";case 92:return r.yytext="]>",s.getLogger().debug("Lex (ARROW_DIR end):",r.yytext),this.popState(),this.popState(),"BLOCK_ARROW_END";case 93:return s.getLogger().debug("Lex: LINK","#"+r.yytext+"#"),15;case 94:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 95:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 96:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 97:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 98:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 99:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 100:this.pushState("md_string");break;case 101:return s.getLogger().debug("Lex: Starting string"),this.pushState("string"),"LINK_LABEL";case 102:return this.popState(),s.getLogger().debug("Lex: LINK","#"+r.yytext+"#"),15;case 103:return this.popState(),s.getLogger().debug("Lex: LINK",r.yytext),15;case 104:return this.popState(),s.getLogger().debug("Lex: LINK",r.yytext),15;case 105:return s.getLogger().debug("Lex: COLON",r.yytext),r.yytext=r.yytext.slice(1),27}},rules:[/^(?:block-beta\b)/,/^(?:block\s+)/,/^(?:block\n+)/,/^(?:block:)/,/^(?:[\s]+)/,/^(?:[\n]+)/,/^(?:((\u000D\u000A)|(\u000A)))/,/^(?:columns\s+auto\b)/,/^(?:columns\s+[\d]+)/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:space[:]\d+)/,/^(?:space\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:interpolate\b)/,/^(?:classDef\s+)/,/^(?:DEFAULT\s+)/,/^(?:\w+\s+)/,/^(?:[^\n]*)/,/^(?:class\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:style\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:end\b\s*)/,/^(?:\(\(\()/,/^(?:\)\)\))/,/^(?:[\)]\))/,/^(?:\}\})/,/^(?:\})/,/^(?:\(-)/,/^(?:-\))/,/^(?:\(\()/,/^(?:\]\])/,/^(?:\()/,/^(?:\]\))/,/^(?:\\\])/,/^(?:\/\])/,/^(?:\)\])/,/^(?:[\)])/,/^(?:\]>)/,/^(?:[\]])/,/^(?:-\))/,/^(?:\(-)/,/^(?:\)\))/,/^(?:\))/,/^(?:\(\(\()/,/^(?:\(\()/,/^(?:\{\{)/,/^(?:\{)/,/^(?:>)/,/^(?:\(\[)/,/^(?:\()/,/^(?:\[\[)/,/^(?:\[\|)/,/^(?:\[\()/,/^(?:\)\)\))/,/^(?:\[\\)/,/^(?:\[\/)/,/^(?:\[\\)/,/^(?:\[)/,/^(?:<\[)/,/^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/,/^(?:$)/,/^(?:["][`])/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]+)/,/^(?:["])/,/^(?:\]>\s*\()/,/^(?:,?\s*right\s*)/,/^(?:,?\s*left\s*)/,/^(?:,?\s*x\s*)/,/^(?:,?\s*y\s*)/,/^(?:,?\s*up\s*)/,/^(?:,?\s*down\s*)/,/^(?:\)\s*)/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?:\s*~~[\~]+\s*)/,/^(?:\s*[xo<]?--\s*)/,/^(?:\s*[xo<]?==\s*)/,/^(?:\s*[xo<]?-\.\s*)/,/^(?:["][`])/,/^(?:["])/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?::\d+)/],conditions:{STYLE_DEFINITION:{rules:[29],inclusive:!1},STYLE_STMNT:{rules:[28],inclusive:!1},CLASSDEFID:{rules:[23],inclusive:!1},CLASSDEF:{rules:[21,22],inclusive:!1},CLASS_STYLE:{rules:[26],inclusive:!1},CLASS:{rules:[25],inclusive:!1},LLABEL:{rules:[100,101,102,103,104],inclusive:!1},ARROW_DIR:{rules:[86,87,88,89,90,91,92],inclusive:!1},BLOCK_ARROW:{rules:[77,82,85],inclusive:!1},NODE:{rules:[38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,78,81],inclusive:!1},md_string:{rules:[10,11,79,80],inclusive:!1},space:{rules:[],inclusive:!1},string:{rules:[13,14,83,84],inclusive:!1},acc_descr_multiline:{rules:[35,36],inclusive:!1},acc_descr:{rules:[33],inclusive:!1},acc_title:{rules:[31],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,12,15,16,17,18,19,20,24,27,30,32,34,37,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,93,94,95,96,97,98,99,105],inclusive:!0}}};return m}();D.lexer=A;function w(){this.yy={}}return w.prototype=D,D.Parser=w,new w}();ee.parser=ee;const ze=ee;let $={},ie=[],M={};const ce="color",he="fill",Be="bgFill",ye=",",Pe=ge();let W={};const Fe=e=>De.sanitizeText(e,Pe),Ye=function(e,o=""){W[e]===void 0&&(W[e]={id:e,styles:[],textStyles:[]});const h=W[e];o!=null&&o.split(ye).forEach(c=>{const n=c.replace(/([^;]*);/,"$1").trim();if(c.match(ce)){const g=n.replace(he,Be).replace(ce,he);h.textStyles.push(g)}h.styles.push(n)})},Ke=function(e,o=""){const h=$[e];o!=null&&(h.styles=o.split(ye))},Xe=function(e,o){e.split(",").forEach(function(h){let c=$[h];if(c===void 0){const n=h.trim();$[n]={id:n,type:"na",children:[]},c=$[n]}c.classes||(c.classes=[]),c.classes.push(o)})},pe=(e,o)=>{const h=e.flat(),c=[];for(const n of h){if(n.label&&(n.label=Fe(n.label)),n.type==="classDef"){Ye(n.id,n.css);continue}if(n.type==="applyClass"){Xe(n.id,(n==null?void 0:n.styleClass)||"");continue}if(n.type==="applyStyles"){n!=null&&n.stylesStr&&Ke(n.id,n==null?void 0:n.stylesStr);continue}if(n.type==="column-setting")o.columns=n.columns||-1;else if(n.type==="edge")M[n.id]?M[n.id]++:M[n.id]=1,n.id=M[n.id]+"-"+n.id,ie.push(n);else{n.label||(n.type==="composite"?n.label="":n.label=n.id);const g=!$[n.id];if(g?$[n.id]=n:(n.type!=="na"&&($[n.id].type=n.type),n.label!==n.id&&($[n.id].label=n.label)),n.children&&pe(n.children,n),n.type==="space"){const a=n.width||1;for(let y=0;y<a;y++){const b=ve(n);b.id=b.id+"-"+y,$[b.id]=b,c.push(b)}}else g&&c.push(n)}}o.children=c};let re=[],U={id:"root",type:"composite",children:[],columns:-1};const Me=()=>{f.debug("Clear called"),Ee(),U={id:"root",type:"composite",children:[],columns:-1},$={root:U},re=[],W={},ie=[],M={}};function We(e){switch(f.debug("typeStr2Type",e),e){case"[]":return"square";case"()":return f.debug("we have a round"),"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function Ue(e){switch(f.debug("typeStr2Type",e),e){case"==":return"thick";default:return"normal"}}function je(e){switch(e.trim()){case"--x":return"arrow_cross";case"--o":return"arrow_circle";default:return"arrow_point"}}let ue=0;const He=()=>(ue++,"id-"+Math.random().toString(36).substr(2,12)+"-"+ue),qe=e=>{U.children=e,pe(e,U),re=U.children},Ve=e=>{const o=$[e];return o?o.columns?o.columns:o.children?o.children.length:-1:-1},Ge=()=>[...Object.values($)],Je=()=>re||[],Ze=()=>ie,Qe=e=>$[e],et=e=>{$[e.id]=e},tt=()=>console,st=function(){return W},it={getConfig:()=>se().block,typeStr2Type:We,edgeTypeStr2Type:Ue,edgeStrToEdgeData:je,getLogger:tt,getBlocksFlat:Ge,getBlocks:Je,getEdges:Ze,setHierarchy:qe,getBlock:Qe,setBlock:et,getColumns:Ve,getClasses:st,clear:Me,generateId:He},rt=it,V=(e,o)=>{const h=Ce,c=h(e,"r"),n=h(e,"g"),g=h(e,"b");return me(c,n,g,o)},nt=e=>`.label {
6
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var s=this.next();return s||this.lex()},begin:function(s){this.conditionStack.push(s)},popState:function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},pushState:function(s){this.begin(s)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(s,r,l,p){switch(l){case 0:return 10;case 1:return s.getLogger().debug("Found space-block"),31;case 2:return s.getLogger().debug("Found nl-block"),31;case 3:return s.getLogger().debug("Found space-block"),29;case 4:s.getLogger().debug(".",r.yytext);break;case 5:s.getLogger().debug("_",r.yytext);break;case 6:return 5;case 7:return r.yytext=-1,28;case 8:return r.yytext=r.yytext.replace(/columns\s+/,""),s.getLogger().debug("COLUMNS (LEX)",r.yytext),28;case 9:this.pushState("md_string");break;case 10:return"MD_STR";case 11:this.popState();break;case 12:this.pushState("string");break;case 13:s.getLogger().debug("LEX: POPPING STR:",r.yytext),this.popState();break;case 14:return s.getLogger().debug("LEX: STR end:",r.yytext),"STR";case 15:return r.yytext=r.yytext.replace(/space\:/,""),s.getLogger().debug("SPACE NUM (LEX)",r.yytext),21;case 16:return r.yytext="1",s.getLogger().debug("COLUMNS (LEX)",r.yytext),21;case 17:return 43;case 18:return"LINKSTYLE";case 19:return"INTERPOLATE";case 20:return this.pushState("CLASSDEF"),40;case 21:return this.popState(),this.pushState("CLASSDEFID"),"DEFAULT_CLASSDEF_ID";case 22:return this.popState(),this.pushState("CLASSDEFID"),41;case 23:return this.popState(),42;case 24:return this.pushState("CLASS"),44;case 25:return this.popState(),this.pushState("CLASS_STYLE"),45;case 26:return this.popState(),46;case 27:return this.pushState("STYLE_STMNT"),47;case 28:return this.popState(),this.pushState("STYLE_DEFINITION"),48;case 29:return this.popState(),49;case 30:return this.pushState("acc_title"),"acc_title";case 31:return this.popState(),"acc_title_value";case 32:return this.pushState("acc_descr"),"acc_descr";case 33:return this.popState(),"acc_descr_value";case 34:this.pushState("acc_descr_multiline");break;case 35:this.popState();break;case 36:return"acc_descr_multiline_value";case 37:return 30;case 38:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 39:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 40:return this.popState(),s.getLogger().debug("Lex: ))"),"NODE_DEND";case 41:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 42:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 43:return this.popState(),s.getLogger().debug("Lex: (-"),"NODE_DEND";case 44:return this.popState(),s.getLogger().debug("Lex: -)"),"NODE_DEND";case 45:return this.popState(),s.getLogger().debug("Lex: (("),"NODE_DEND";case 46:return this.popState(),s.getLogger().debug("Lex: ]]"),"NODE_DEND";case 47:return this.popState(),s.getLogger().debug("Lex: ("),"NODE_DEND";case 48:return this.popState(),s.getLogger().debug("Lex: ])"),"NODE_DEND";case 49:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";case 50:return this.popState(),s.getLogger().debug("Lex: /]"),"NODE_DEND";case 51:return this.popState(),s.getLogger().debug("Lex: )]"),"NODE_DEND";case 52:return this.popState(),s.getLogger().debug("Lex: )"),"NODE_DEND";case 53:return this.popState(),s.getLogger().debug("Lex: ]>"),"NODE_DEND";case 54:return this.popState(),s.getLogger().debug("Lex: ]"),"NODE_DEND";case 55:return s.getLogger().debug("Lexa: -)"),this.pushState("NODE"),36;case 56:return s.getLogger().debug("Lexa: (-"),this.pushState("NODE"),36;case 57:return s.getLogger().debug("Lexa: ))"),this.pushState("NODE"),36;case 58:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 59:return s.getLogger().debug("Lex: ((("),this.pushState("NODE"),36;case 60:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 61:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 62:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 63:return s.getLogger().debug("Lexc: >"),this.pushState("NODE"),36;case 64:return s.getLogger().debug("Lexa: (["),this.pushState("NODE"),36;case 65:return s.getLogger().debug("Lexa: )"),this.pushState("NODE"),36;case 66:return this.pushState("NODE"),36;case 67:return this.pushState("NODE"),36;case 68:return this.pushState("NODE"),36;case 69:return this.pushState("NODE"),36;case 70:return this.pushState("NODE"),36;case 71:return this.pushState("NODE"),36;case 72:return this.pushState("NODE"),36;case 73:return s.getLogger().debug("Lexa: ["),this.pushState("NODE"),36;case 74:return this.pushState("BLOCK_ARROW"),s.getLogger().debug("LEX ARR START"),38;case 75:return s.getLogger().debug("Lex: NODE_ID",r.yytext),32;case 76:return s.getLogger().debug("Lex: EOF",r.yytext),8;case 77:this.pushState("md_string");break;case 78:this.pushState("md_string");break;case 79:return"NODE_DESCR";case 80:this.popState();break;case 81:s.getLogger().debug("Lex: Starting string"),this.pushState("string");break;case 82:s.getLogger().debug("LEX ARR: Starting string"),this.pushState("string");break;case 83:return s.getLogger().debug("LEX: NODE_DESCR:",r.yytext),"NODE_DESCR";case 84:s.getLogger().debug("LEX POPPING"),this.popState();break;case 85:s.getLogger().debug("Lex: =>BAE"),this.pushState("ARROW_DIR");break;case 86:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (right): dir:",r.yytext),"DIR";case 87:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (left):",r.yytext),"DIR";case 88:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (x):",r.yytext),"DIR";case 89:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (y):",r.yytext),"DIR";case 90:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (up):",r.yytext),"DIR";case 91:return r.yytext=r.yytext.replace(/^,\s*/,""),s.getLogger().debug("Lex (down):",r.yytext),"DIR";case 92:return r.yytext="]>",s.getLogger().debug("Lex (ARROW_DIR end):",r.yytext),this.popState(),this.popState(),"BLOCK_ARROW_END";case 93:return s.getLogger().debug("Lex: LINK","#"+r.yytext+"#"),15;case 94:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 95:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 96:return s.getLogger().debug("Lex: LINK",r.yytext),15;case 97:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 98:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 99:return s.getLogger().debug("Lex: START_LINK",r.yytext),this.pushState("LLABEL"),16;case 100:this.pushState("md_string");break;case 101:return s.getLogger().debug("Lex: Starting string"),this.pushState("string"),"LINK_LABEL";case 102:return this.popState(),s.getLogger().debug("Lex: LINK","#"+r.yytext+"#"),15;case 103:return this.popState(),s.getLogger().debug("Lex: LINK",r.yytext),15;case 104:return this.popState(),s.getLogger().debug("Lex: LINK",r.yytext),15;case 105:return s.getLogger().debug("Lex: COLON",r.yytext),r.yytext=r.yytext.slice(1),27}},rules:[/^(?:block-beta\b)/,/^(?:block\s+)/,/^(?:block\n+)/,/^(?:block:)/,/^(?:[\s]+)/,/^(?:[\n]+)/,/^(?:((\u000D\u000A)|(\u000A)))/,/^(?:columns\s+auto\b)/,/^(?:columns\s+[\d]+)/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]*)/,/^(?:space[:]\d+)/,/^(?:space\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:interpolate\b)/,/^(?:classDef\s+)/,/^(?:DEFAULT\s+)/,/^(?:\w+\s+)/,/^(?:[^\n]*)/,/^(?:class\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:style\s+)/,/^(?:(\w+)+((,\s*\w+)*))/,/^(?:[^\n]*)/,/^(?:accTitle\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*:\s*)/,/^(?:(?!\n||)*[^\n]*)/,/^(?:accDescr\s*\{\s*)/,/^(?:[\}])/,/^(?:[^\}]*)/,/^(?:end\b\s*)/,/^(?:\(\(\()/,/^(?:\)\)\))/,/^(?:[\)]\))/,/^(?:\}\})/,/^(?:\})/,/^(?:\(-)/,/^(?:-\))/,/^(?:\(\()/,/^(?:\]\])/,/^(?:\()/,/^(?:\]\))/,/^(?:\\\])/,/^(?:\/\])/,/^(?:\)\])/,/^(?:[\)])/,/^(?:\]>)/,/^(?:[\]])/,/^(?:-\))/,/^(?:\(-)/,/^(?:\)\))/,/^(?:\))/,/^(?:\(\(\()/,/^(?:\(\()/,/^(?:\{\{)/,/^(?:\{)/,/^(?:>)/,/^(?:\(\[)/,/^(?:\()/,/^(?:\[\[)/,/^(?:\[\|)/,/^(?:\[\()/,/^(?:\)\)\))/,/^(?:\[\\)/,/^(?:\[\/)/,/^(?:\[\\)/,/^(?:\[)/,/^(?:<\[)/,/^(?:[^\(\[\n\-\)\{\}\s\<\>:]+)/,/^(?:$)/,/^(?:["][`])/,/^(?:["][`])/,/^(?:[^`"]+)/,/^(?:[`]["])/,/^(?:["])/,/^(?:["])/,/^(?:[^"]+)/,/^(?:["])/,/^(?:\]>\s*\()/,/^(?:,?\s*right\s*)/,/^(?:,?\s*left\s*)/,/^(?:,?\s*x\s*)/,/^(?:,?\s*y\s*)/,/^(?:,?\s*up\s*)/,/^(?:,?\s*down\s*)/,/^(?:\)\s*)/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?:\s*~~[\~]+\s*)/,/^(?:\s*[xo<]?--\s*)/,/^(?:\s*[xo<]?==\s*)/,/^(?:\s*[xo<]?-\.\s*)/,/^(?:["][`])/,/^(?:["])/,/^(?:\s*[xo<]?--+[-xo>]\s*)/,/^(?:\s*[xo<]?==+[=xo>]\s*)/,/^(?:\s*[xo<]?-?\.+-[xo>]?\s*)/,/^(?::\d+)/],conditions:{STYLE_DEFINITION:{rules:[29],inclusive:!1},STYLE_STMNT:{rules:[28],inclusive:!1},CLASSDEFID:{rules:[23],inclusive:!1},CLASSDEF:{rules:[21,22],inclusive:!1},CLASS_STYLE:{rules:[26],inclusive:!1},CLASS:{rules:[25],inclusive:!1},LLABEL:{rules:[100,101,102,103,104],inclusive:!1},ARROW_DIR:{rules:[86,87,88,89,90,91,92],inclusive:!1},BLOCK_ARROW:{rules:[77,82,85],inclusive:!1},NODE:{rules:[38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,78,81],inclusive:!1},md_string:{rules:[10,11,79,80],inclusive:!1},space:{rules:[],inclusive:!1},string:{rules:[13,14,83,84],inclusive:!1},acc_descr_multiline:{rules:[35,36],inclusive:!1},acc_descr:{rules:[33],inclusive:!1},acc_title:{rules:[31],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,12,15,16,17,18,19,20,24,27,30,32,34,37,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,93,94,95,96,97,98,99,105],inclusive:!0}}};return m}();D.lexer=A;function w(){this.yy={}}return w.prototype=D,D.Parser=w,new w}();ee.parser=ee;const Re=ee;let $={},ie=[],M={};const ce="color",he="fill",Be="bgFill",ye=",",Fe=ge();let W={};const Pe=e=>De.sanitizeText(e,Fe),Ye=function(e,o=""){W[e]===void 0&&(W[e]={id:e,styles:[],textStyles:[]});const h=W[e];o!=null&&o.split(ye).forEach(c=>{const n=c.replace(/([^;]*);/,"$1").trim();if(c.match(ce)){const g=n.replace(he,Be).replace(ce,he);h.textStyles.push(g)}h.styles.push(n)})},Ke=function(e,o=""){const h=$[e];o!=null&&(h.styles=o.split(ye))},Xe=function(e,o){e.split(",").forEach(function(h){let c=$[h];if(c===void 0){const n=h.trim();$[n]={id:n,type:"na",children:[]},c=$[n]}c.classes||(c.classes=[]),c.classes.push(o)})},pe=(e,o)=>{const h=e.flat(),c=[];for(const n of h){if(n.label&&(n.label=Pe(n.label)),n.type==="classDef"){Ye(n.id,n.css);continue}if(n.type==="applyClass"){Xe(n.id,(n==null?void 0:n.styleClass)||"");continue}if(n.type==="applyStyles"){n!=null&&n.stylesStr&&Ke(n.id,n==null?void 0:n.stylesStr);continue}if(n.type==="column-setting")o.columns=n.columns||-1;else if(n.type==="edge")M[n.id]?M[n.id]++:M[n.id]=1,n.id=M[n.id]+"-"+n.id,ie.push(n);else{n.label||(n.type==="composite"?n.label="":n.label=n.id);const g=!$[n.id];if(g?$[n.id]=n:(n.type!=="na"&&($[n.id].type=n.type),n.label!==n.id&&($[n.id].label=n.label)),n.children&&pe(n.children,n),n.type==="space"){const a=n.width||1;for(let y=0;y<a;y++){const b=ve(n);b.id=b.id+"-"+y,$[b.id]=b,c.push(b)}}else g&&c.push(n)}}o.children=c};let re=[],U={id:"root",type:"composite",children:[],columns:-1};const Me=()=>{f.debug("Clear called"),Ee(),U={id:"root",type:"composite",children:[],columns:-1},$={root:U},re=[],W={},ie=[],M={}};function We(e){switch(f.debug("typeStr2Type",e),e){case"[]":return"square";case"()":return f.debug("we have a round"),"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function Ue(e){switch(f.debug("typeStr2Type",e),e){case"==":return"thick";default:return"normal"}}function je(e){switch(e.trim()){case"--x":return"arrow_cross";case"--o":return"arrow_circle";default:return"arrow_point"}}let ue=0;const He=()=>(ue++,"id-"+Math.random().toString(36).substr(2,12)+"-"+ue),qe=e=>{U.children=e,pe(e,U),re=U.children},Je=e=>{const o=$[e];return o?o.columns?o.columns:o.children?o.children.length:-1:-1},Ge=()=>[...Object.values($)],Ve=()=>re||[],Ze=()=>ie,Qe=e=>$[e],et=e=>{$[e.id]=e},tt=()=>console,st=function(){return W},it={getConfig:()=>se().block,typeStr2Type:We,edgeTypeStr2Type:Ue,edgeStrToEdgeData:je,getLogger:tt,getBlocksFlat:Ge,getBlocks:Ve,getEdges:Ze,setHierarchy:qe,getBlock:Qe,setBlock:et,getColumns:Je,getClasses:st,clear:Me,generateId:He},rt=it,J=(e,o)=>{const h=Ce,c=h(e,"r"),n=h(e,"g"),g=h(e,"b");return me(c,n,g,o)},nt=e=>`.label {
7
7
  font-family: ${e.fontFamily};
8
8
  color: ${e.nodeTextColor||e.textColor};
9
9
  }
@@ -73,14 +73,14 @@ Expecting `+H.join(", ")+", got '"+(this.terminals_[N]||N)+"'":Q="Parse error on
73
73
 
74
74
  /* For html labels only */
75
75
  .labelBkg {
76
- background-color: ${V(e.edgeLabelBackground,.5)};
76
+ background-color: ${J(e.edgeLabelBackground,.5)};
77
77
  // background-color:
78
78
  }
79
79
 
80
80
  .node .cluster {
81
- // fill: ${V(e.mainBkg,.5)};
82
- fill: ${V(e.clusterBkg,.5)};
83
- stroke: ${V(e.clusterBorder,.2)};
81
+ // fill: ${J(e.mainBkg,.5)};
82
+ fill: ${J(e.clusterBkg,.5)};
83
+ stroke: ${J(e.clusterBorder,.2)};
84
84
  box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px, rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
85
85
  stroke-width: 1px;
86
86
  }
@@ -115,4 +115,4 @@ Expecting `+H.join(", ")+", got '"+(this.terminals_[N]||N)+"'":Q="Parse error on
115
115
  font-size: 18px;
116
116
  fill: ${e.textColor};
117
117
  }
118
- `,lt=nt;function be(e,o,h=!1){var c,n,g;const a=e;let y="default";(((c=a==null?void 0:a.classes)==null?void 0:c.length)||0)>0&&(y=((a==null?void 0:a.classes)||[]).join(" ")),y=y+" flowchart-label";let b=0,d="",x;switch(a.type){case"round":b=5,d="rect";break;case"composite":b=0,d="composite",x=0;break;case"square":d="rect";break;case"diamond":d="question";break;case"hexagon":d="hexagon";break;case"block_arrow":d="block_arrow";break;case"odd":d="rect_left_inv_arrow";break;case"lean_right":d="lean_right";break;case"lean_left":d="lean_left";break;case"trapezoid":d="trapezoid";break;case"inv_trapezoid":d="inv_trapezoid";break;case"rect_left_inv_arrow":d="rect_left_inv_arrow";break;case"circle":d="circle";break;case"ellipse":d="ellipse";break;case"stadium":d="stadium";break;case"subroutine":d="subroutine";break;case"cylinder":d="cylinder";break;case"group":d="rect";break;case"doublecircle":d="doublecircle";break;default:d="rect"}const _=we((a==null?void 0:a.styles)||[]),T=a.label,k=a.size||{width:0,height:0,x:0,y:0};return{labelStyle:_.labelStyle,shape:d,labelText:T,rx:b,ry:b,class:y,style:_.style,id:a.id,directions:a.directions,width:k.width,height:k.height,x:k.x,y:k.y,positioned:h,intersect:void 0,type:a.type,padding:x??(((g=(n=se())==null?void 0:n.block)==null?void 0:g.padding)||0)}}async function ot(e,o,h){const c=be(o,h,!1);if(c.type==="group")return;const n=await de(e,c),g=n.node().getBBox(),a=h.getBlock(c.id);a.size={width:g.width,height:g.height,x:0,y:0,node:n},h.setBlock(a),n.remove()}async function at(e,o,h){const c=be(o,h,!0);h.getBlock(c.id).type!=="space"&&(await de(e,c),o.intersect=c==null?void 0:c.intersect,Ie(c))}async function ne(e,o,h,c){for(const n of o)await c(e,n,h),n.children&&await ne(e,n.children,h,c)}async function ct(e,o,h){await ne(e,o,h,ot)}async function ht(e,o,h){await ne(e,o,h,at)}async function ut(e,o,h,c,n){const g=new Ae({multigraph:!0,compound:!0});g.setGraph({rankdir:"TB",nodesep:10,ranksep:10,marginx:8,marginy:8});for(const a of h)a.size&&g.setNode(a.id,{width:a.size.width,height:a.size.height,intersect:a.intersect});for(const a of o)if(a.start&&a.end){const y=c.getBlock(a.start),b=c.getBlock(a.end);if(y!=null&&y.size&&b!=null&&b.size){const d=y.size,x=b.size,_=[{x:d.x,y:d.y},{x:d.x+(x.x-d.x)/2,y:d.y+(x.y-d.y)/2},{x:x.x,y:x.y}];await $e(e,{v:a.start,w:a.end,name:a.id},{...a,arrowTypeEnd:a.arrowTypeEnd,arrowTypeStart:a.arrowTypeStart,points:_,classes:"edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"},void 0,"block",g,n),a.label&&(await Te(e,{...a,label:a.label,labelStyle:"stroke: #333; stroke-width: 1.5px;fill:none;",arrowTypeEnd:a.arrowTypeEnd,arrowTypeStart:a.arrowTypeStart}),await Oe({...a,x:_[1].x,y:_[1].y},{originalPath:_}))}}}const S=((ae=(oe=ge())==null?void 0:oe.block)==null?void 0:ae.padding)||8;function gt(e,o){if(e===0||!Number.isInteger(e))throw new Error("Columns must be an integer !== 0.");if(o<0||!Number.isInteger(o))throw new Error("Position must be a non-negative integer."+o);if(e<0)return{px:o,py:0};if(e===1)return{px:0,py:o};const h=o%e,c=Math.floor(o/e);return{px:h,py:c}}const dt=e=>{let o=0,h=0;for(const c of e.children){const{width:n,height:g,x:a,y}=c.size||{width:0,height:0,x:0,y:0};f.debug("getMaxChildSize abc95 child:",c.id,"width:",n,"height:",g,"x:",a,"y:",y,c.type),c.type!=="space"&&(n>o&&(o=n/(e.widthInColumns||1)),g>h&&(h=g))}return{width:o,height:h}};function te(e,o,h=0,c=0){var n,g,a,y,b,d,x,_,T,k,v;f.debug("setBlockSizes abc95 (start)",e.id,(n=e==null?void 0:e.size)==null?void 0:n.x,"block width =",e==null?void 0:e.size,"sieblingWidth",h),(g=e==null?void 0:e.size)!=null&&g.width||(e.size={width:h,height:c,x:0,y:0});let L=0,D=0;if(((a=e.children)==null?void 0:a.length)>0){for(const t of e.children)te(t,o);const A=dt(e);L=A.width,D=A.height,f.debug("setBlockSizes abc95 maxWidth of",e.id,":s children is ",L,D);for(const t of e.children)t.size&&(f.debug(`abc95 Setting size of children of ${e.id} id=${t.id} ${L} ${D} ${t.size}`),t.size.width=L*(t.widthInColumns||1)+S*((t.widthInColumns||1)-1),t.size.height=D,t.size.x=0,t.size.y=0,f.debug(`abc95 updating size of ${e.id} children child:${t.id} maxWidth:${L} maxHeight:${D}`));for(const t of e.children)te(t,o,L,D);const w=e.columns||-1;let m=0;for(const t of e.children)m+=t.widthInColumns||1;let s=e.children.length;w>0&&w<m&&(s=w),e.widthInColumns;const r=Math.ceil(m/s);let l=s*(L+S)+S,p=r*(D+S)+S;if(l<h){f.debug(`Detected to small siebling: abc95 ${e.id} sieblingWidth ${h} sieblingHeight ${c} width ${l}`),l=h,p=c;const t=(h-s*S-S)/s,u=(c-r*S-S)/r;f.debug("Size indata abc88",e.id,"childWidth",t,"maxWidth",L),f.debug("Size indata abc88",e.id,"childHeight",u,"maxHeight",D),f.debug("Size indata abc88 xSize",s,"padding",S);for(const i of e.children)i.size&&(i.size.width=t,i.size.height=u,i.size.x=0,i.size.y=0)}if(f.debug(`abc95 (finale calc) ${e.id} xSize ${s} ySize ${r} columns ${w}${e.children.length} width=${Math.max(l,((y=e.size)==null?void 0:y.width)||0)}`),l<(((b=e==null?void 0:e.size)==null?void 0:b.width)||0)){l=((d=e==null?void 0:e.size)==null?void 0:d.width)||0;const t=w>0?Math.min(e.children.length,w):e.children.length;if(t>0){const u=(l-t*S-S)/t;f.debug("abc95 (growing to fit) width",e.id,l,(x=e.size)==null?void 0:x.width,u);for(const i of e.children)i.size&&(i.size.width=u)}}e.size={width:l,height:p,x:0,y:0}}f.debug("setBlockSizes abc94 (done)",e.id,(_=e==null?void 0:e.size)==null?void 0:_.x,(T=e==null?void 0:e.size)==null?void 0:T.width,(k=e==null?void 0:e.size)==null?void 0:k.y,(v=e==null?void 0:e.size)==null?void 0:v.height)}function xe(e,o){var h,c,n,g,a,y,b,d,x,_,T,k,v,L,D,A,w;f.debug(`abc85 layout blocks (=>layoutBlocks) ${e.id} x: ${(h=e==null?void 0:e.size)==null?void 0:h.x} y: ${(c=e==null?void 0:e.size)==null?void 0:c.y} width: ${(n=e==null?void 0:e.size)==null?void 0:n.width}`);const m=e.columns||-1;if(f.debug("layoutBlocks columns abc95",e.id,"=>",m,e),e.children&&e.children.length>0){const s=((a=(g=e==null?void 0:e.children[0])==null?void 0:g.size)==null?void 0:a.width)||0,r=e.children.length*s+(e.children.length-1)*S;f.debug("widthOfChildren 88",r,"posX");let l=0;f.debug("abc91 block?.size?.x",e.id,(y=e==null?void 0:e.size)==null?void 0:y.x);let p=(b=e==null?void 0:e.size)!=null&&b.x?((d=e==null?void 0:e.size)==null?void 0:d.x)+(-((x=e==null?void 0:e.size)==null?void 0:x.width)/2||0):-S,t=0;for(const u of e.children){const i=e;if(!u.size)continue;const{width:O,height:B}=u.size,{px:X,py:C}=gt(m,l);if(C!=t&&(t=C,p=(_=e==null?void 0:e.size)!=null&&_.x?((T=e==null?void 0:e.size)==null?void 0:T.x)+(-((k=e==null?void 0:e.size)==null?void 0:k.width)/2||0):-S,f.debug("New row in layout for block",e.id," and child ",u.id,t)),f.debug(`abc89 layout blocks (child) id: ${u.id} Pos: ${l} (px, py) ${X},${C} (${(v=i==null?void 0:i.size)==null?void 0:v.x},${(L=i==null?void 0:i.size)==null?void 0:L.y}) parent: ${i.id} width: ${O}${S}`),i.size){const P=O/2;u.size.x=p+S+P,f.debug(`abc91 layout blocks (calc) px, pyid:${u.id} startingPos=X${p} new startingPosX${u.size.x} ${P} padding=${S} width=${O} halfWidth=${P} => x:${u.size.x} y:${u.size.y} ${u.widthInColumns} (width * (child?.w || 1)) / 2 ${O*((u==null?void 0:u.widthInColumns)||1)/2}`),p=u.size.x+P,u.size.y=i.size.y-i.size.height/2+C*(B+S)+B/2+S,f.debug(`abc88 layout blocks (calc) px, pyid:${u.id}startingPosX${p}${S}${P}=>x:${u.size.x}y:${u.size.y}${u.widthInColumns}(width * (child?.w || 1)) / 2${O*((u==null?void 0:u.widthInColumns)||1)/2}`)}u.children&&xe(u),l+=(u==null?void 0:u.widthInColumns)||1,f.debug("abc88 columnsPos",u,l)}}f.debug(`layout blocks (<==layoutBlocks) ${e.id} x: ${(D=e==null?void 0:e.size)==null?void 0:D.x} y: ${(A=e==null?void 0:e.size)==null?void 0:A.y} width: ${(w=e==null?void 0:e.size)==null?void 0:w.width}`)}function fe(e,{minX:o,minY:h,maxX:c,maxY:n}={minX:0,minY:0,maxX:0,maxY:0}){if(e.size&&e.id!=="root"){const{x:g,y:a,width:y,height:b}=e.size;g-y/2<o&&(o=g-y/2),a-b/2<h&&(h=a-b/2),g+y/2>c&&(c=g+y/2),a+b/2>n&&(n=a+b/2)}if(e.children)for(const g of e.children)({minX:o,minY:h,maxX:c,maxY:n}=fe(g,{minX:o,minY:h,maxX:c,maxY:n}));return{minX:o,minY:h,maxX:c,maxY:n}}function yt(e){const o=e.getBlock("root");if(!o)return;te(o,e,0,0),xe(o),f.debug("getBlocks",JSON.stringify(o,null,2));const{minX:h,minY:c,maxX:n,maxY:g}=fe(o),a=g-c,y=n-h;return{x:h,y:c,width:y,height:a}}const pt=function(e,o){return o.db.getClasses()},bt=async function(e,o,h,c){const{securityLevel:n,block:g}=se(),a=c.db;let y;n==="sandbox"&&(y=q("#i"+o));const b=n==="sandbox"?q(y.nodes()[0].contentDocument.body):q("body"),d=n==="sandbox"?b.select(`[id="${o}"]`):q(`[id="${o}"]`);Ne(d,["point","circle","cross"],c.type,o);const x=a.getBlocks(),_=a.getBlocksFlat(),T=a.getEdges(),k=d.insert("g").attr("class","block");await ct(k,x,a);const v=yt(a);if(await ht(k,x,a),await ut(k,T,_,a,o),v){const L=v,D=Math.max(1,Math.round(.125*(L.width/L.height))),A=L.height+D+10,w=L.width+10,{useMaxWidth:m}=g;_e(d,A,w,!!m),f.debug("Here Bounds",v,L),d.attr("viewBox",`${L.x-5} ${L.y-5} ${L.width+10} ${L.height+10}`)}ke(Re)},xt={draw:bt,getClasses:pt},Dt={parser:ze,db:rt,renderer:xt,styles:lt};export{Dt as diagram};
118
+ `,lt=nt;function be(e,o,h=!1){var c,n,g;const a=e;let y="default";(((c=a==null?void 0:a.classes)==null?void 0:c.length)||0)>0&&(y=((a==null?void 0:a.classes)||[]).join(" ")),y=y+" flowchart-label";let b=0,d="",x;switch(a.type){case"round":b=5,d="rect";break;case"composite":b=0,d="composite",x=0;break;case"square":d="rect";break;case"diamond":d="question";break;case"hexagon":d="hexagon";break;case"block_arrow":d="block_arrow";break;case"odd":d="rect_left_inv_arrow";break;case"lean_right":d="lean_right";break;case"lean_left":d="lean_left";break;case"trapezoid":d="trapezoid";break;case"inv_trapezoid":d="inv_trapezoid";break;case"rect_left_inv_arrow":d="rect_left_inv_arrow";break;case"circle":d="circle";break;case"ellipse":d="ellipse";break;case"stadium":d="stadium";break;case"subroutine":d="subroutine";break;case"cylinder":d="cylinder";break;case"group":d="rect";break;case"doublecircle":d="doublecircle";break;default:d="rect"}const _=we((a==null?void 0:a.styles)||[]),T=a.label,k=a.size||{width:0,height:0,x:0,y:0};return{labelStyle:_.labelStyle,shape:d,labelText:T,rx:b,ry:b,class:y,style:_.style,id:a.id,directions:a.directions,width:k.width,height:k.height,x:k.x,y:k.y,positioned:h,intersect:void 0,type:a.type,padding:x??(((g=(n=se())==null?void 0:n.block)==null?void 0:g.padding)||0)}}async function ot(e,o,h){const c=be(o,h,!1);if(c.type==="group")return;const n=await de(e,c),g=n.node().getBBox(),a=h.getBlock(c.id);a.size={width:g.width,height:g.height,x:0,y:0,node:n},h.setBlock(a),n.remove()}async function at(e,o,h){const c=be(o,h,!0);h.getBlock(c.id).type!=="space"&&(await de(e,c),o.intersect=c==null?void 0:c.intersect,Ie(c))}async function ne(e,o,h,c){for(const n of o)await c(e,n,h),n.children&&await ne(e,n.children,h,c)}async function ct(e,o,h){await ne(e,o,h,ot)}async function ht(e,o,h){await ne(e,o,h,at)}async function ut(e,o,h,c,n){const g=new Ae({multigraph:!0,compound:!0});g.setGraph({rankdir:"TB",nodesep:10,ranksep:10,marginx:8,marginy:8});for(const a of h)a.size&&g.setNode(a.id,{width:a.size.width,height:a.size.height,intersect:a.intersect});for(const a of o)if(a.start&&a.end){const y=c.getBlock(a.start),b=c.getBlock(a.end);if(y!=null&&y.size&&b!=null&&b.size){const d=y.size,x=b.size,_=[{x:d.x,y:d.y},{x:d.x+(x.x-d.x)/2,y:d.y+(x.y-d.y)/2},{x:x.x,y:x.y}];await $e(e,{v:a.start,w:a.end,name:a.id},{...a,arrowTypeEnd:a.arrowTypeEnd,arrowTypeStart:a.arrowTypeStart,points:_,classes:"edge-thickness-normal edge-pattern-solid flowchart-link LS-a1 LE-b1"},void 0,"block",g,n),a.label&&(await Te(e,{...a,label:a.label,labelStyle:"stroke: #333; stroke-width: 1.5px;fill:none;",arrowTypeEnd:a.arrowTypeEnd,arrowTypeStart:a.arrowTypeStart}),await Oe({...a,x:_[1].x,y:_[1].y},{originalPath:_}))}}}const S=((ae=(oe=ge())==null?void 0:oe.block)==null?void 0:ae.padding)||8;function gt(e,o){if(e===0||!Number.isInteger(e))throw new Error("Columns must be an integer !== 0.");if(o<0||!Number.isInteger(o))throw new Error("Position must be a non-negative integer."+o);if(e<0)return{px:o,py:0};if(e===1)return{px:0,py:o};const h=o%e,c=Math.floor(o/e);return{px:h,py:c}}const dt=e=>{let o=0,h=0;for(const c of e.children){const{width:n,height:g,x:a,y}=c.size||{width:0,height:0,x:0,y:0};f.debug("getMaxChildSize abc95 child:",c.id,"width:",n,"height:",g,"x:",a,"y:",y,c.type),c.type!=="space"&&(n>o&&(o=n/(e.widthInColumns||1)),g>h&&(h=g))}return{width:o,height:h}};function te(e,o,h=0,c=0){var n,g,a,y,b,d,x,_,T,k,v;f.debug("setBlockSizes abc95 (start)",e.id,(n=e==null?void 0:e.size)==null?void 0:n.x,"block width =",e==null?void 0:e.size,"sieblingWidth",h),(g=e==null?void 0:e.size)!=null&&g.width||(e.size={width:h,height:c,x:0,y:0});let L=0,D=0;if(((a=e.children)==null?void 0:a.length)>0){for(const t of e.children)te(t,o);const A=dt(e);L=A.width,D=A.height,f.debug("setBlockSizes abc95 maxWidth of",e.id,":s children is ",L,D);for(const t of e.children)t.size&&(f.debug(`abc95 Setting size of children of ${e.id} id=${t.id} ${L} ${D} ${t.size}`),t.size.width=L*(t.widthInColumns||1)+S*((t.widthInColumns||1)-1),t.size.height=D,t.size.x=0,t.size.y=0,f.debug(`abc95 updating size of ${e.id} children child:${t.id} maxWidth:${L} maxHeight:${D}`));for(const t of e.children)te(t,o,L,D);const w=e.columns||-1;let m=0;for(const t of e.children)m+=t.widthInColumns||1;let s=e.children.length;w>0&&w<m&&(s=w),e.widthInColumns;const r=Math.ceil(m/s);let l=s*(L+S)+S,p=r*(D+S)+S;if(l<h){f.debug(`Detected to small siebling: abc95 ${e.id} sieblingWidth ${h} sieblingHeight ${c} width ${l}`),l=h,p=c;const t=(h-s*S-S)/s,u=(c-r*S-S)/r;f.debug("Size indata abc88",e.id,"childWidth",t,"maxWidth",L),f.debug("Size indata abc88",e.id,"childHeight",u,"maxHeight",D),f.debug("Size indata abc88 xSize",s,"padding",S);for(const i of e.children)i.size&&(i.size.width=t,i.size.height=u,i.size.x=0,i.size.y=0)}if(f.debug(`abc95 (finale calc) ${e.id} xSize ${s} ySize ${r} columns ${w}${e.children.length} width=${Math.max(l,((y=e.size)==null?void 0:y.width)||0)}`),l<(((b=e==null?void 0:e.size)==null?void 0:b.width)||0)){l=((d=e==null?void 0:e.size)==null?void 0:d.width)||0;const t=w>0?Math.min(e.children.length,w):e.children.length;if(t>0){const u=(l-t*S-S)/t;f.debug("abc95 (growing to fit) width",e.id,l,(x=e.size)==null?void 0:x.width,u);for(const i of e.children)i.size&&(i.size.width=u)}}e.size={width:l,height:p,x:0,y:0}}f.debug("setBlockSizes abc94 (done)",e.id,(_=e==null?void 0:e.size)==null?void 0:_.x,(T=e==null?void 0:e.size)==null?void 0:T.width,(k=e==null?void 0:e.size)==null?void 0:k.y,(v=e==null?void 0:e.size)==null?void 0:v.height)}function xe(e,o){var h,c,n,g,a,y,b,d,x,_,T,k,v,L,D,A,w;f.debug(`abc85 layout blocks (=>layoutBlocks) ${e.id} x: ${(h=e==null?void 0:e.size)==null?void 0:h.x} y: ${(c=e==null?void 0:e.size)==null?void 0:c.y} width: ${(n=e==null?void 0:e.size)==null?void 0:n.width}`);const m=e.columns||-1;if(f.debug("layoutBlocks columns abc95",e.id,"=>",m,e),e.children&&e.children.length>0){const s=((a=(g=e==null?void 0:e.children[0])==null?void 0:g.size)==null?void 0:a.width)||0,r=e.children.length*s+(e.children.length-1)*S;f.debug("widthOfChildren 88",r,"posX");let l=0;f.debug("abc91 block?.size?.x",e.id,(y=e==null?void 0:e.size)==null?void 0:y.x);let p=(b=e==null?void 0:e.size)!=null&&b.x?((d=e==null?void 0:e.size)==null?void 0:d.x)+(-((x=e==null?void 0:e.size)==null?void 0:x.width)/2||0):-S,t=0;for(const u of e.children){const i=e;if(!u.size)continue;const{width:O,height:B}=u.size,{px:X,py:C}=gt(m,l);if(C!=t&&(t=C,p=(_=e==null?void 0:e.size)!=null&&_.x?((T=e==null?void 0:e.size)==null?void 0:T.x)+(-((k=e==null?void 0:e.size)==null?void 0:k.width)/2||0):-S,f.debug("New row in layout for block",e.id," and child ",u.id,t)),f.debug(`abc89 layout blocks (child) id: ${u.id} Pos: ${l} (px, py) ${X},${C} (${(v=i==null?void 0:i.size)==null?void 0:v.x},${(L=i==null?void 0:i.size)==null?void 0:L.y}) parent: ${i.id} width: ${O}${S}`),i.size){const F=O/2;u.size.x=p+S+F,f.debug(`abc91 layout blocks (calc) px, pyid:${u.id} startingPos=X${p} new startingPosX${u.size.x} ${F} padding=${S} width=${O} halfWidth=${F} => x:${u.size.x} y:${u.size.y} ${u.widthInColumns} (width * (child?.w || 1)) / 2 ${O*((u==null?void 0:u.widthInColumns)||1)/2}`),p=u.size.x+F,u.size.y=i.size.y-i.size.height/2+C*(B+S)+B/2+S,f.debug(`abc88 layout blocks (calc) px, pyid:${u.id}startingPosX${p}${S}${F}=>x:${u.size.x}y:${u.size.y}${u.widthInColumns}(width * (child?.w || 1)) / 2${O*((u==null?void 0:u.widthInColumns)||1)/2}`)}u.children&&xe(u),l+=(u==null?void 0:u.widthInColumns)||1,f.debug("abc88 columnsPos",u,l)}}f.debug(`layout blocks (<==layoutBlocks) ${e.id} x: ${(D=e==null?void 0:e.size)==null?void 0:D.x} y: ${(A=e==null?void 0:e.size)==null?void 0:A.y} width: ${(w=e==null?void 0:e.size)==null?void 0:w.width}`)}function fe(e,{minX:o,minY:h,maxX:c,maxY:n}={minX:0,minY:0,maxX:0,maxY:0}){if(e.size&&e.id!=="root"){const{x:g,y:a,width:y,height:b}=e.size;g-y/2<o&&(o=g-y/2),a-b/2<h&&(h=a-b/2),g+y/2>c&&(c=g+y/2),a+b/2>n&&(n=a+b/2)}if(e.children)for(const g of e.children)({minX:o,minY:h,maxX:c,maxY:n}=fe(g,{minX:o,minY:h,maxX:c,maxY:n}));return{minX:o,minY:h,maxX:c,maxY:n}}function yt(e){const o=e.getBlock("root");if(!o)return;te(o,e,0,0),xe(o),f.debug("getBlocks",JSON.stringify(o,null,2));const{minX:h,minY:c,maxX:n,maxY:g}=fe(o),a=g-c,y=n-h;return{x:h,y:c,width:y,height:a}}const pt=function(e,o){return o.db.getClasses()},bt=async function(e,o,h,c){const{securityLevel:n,block:g}=se(),a=c.db;let y;n==="sandbox"&&(y=q("#i"+o));const b=n==="sandbox"?q(y.nodes()[0].contentDocument.body):q("body"),d=n==="sandbox"?b.select(`[id="${o}"]`):q(`[id="${o}"]`);Ne(d,["point","circle","cross"],c.type,o);const x=a.getBlocks(),_=a.getBlocksFlat(),T=a.getEdges(),k=d.insert("g").attr("class","block");await ct(k,x,a);const v=yt(a);if(await ht(k,x,a),await ut(k,T,_,a,o),v){const L=v,D=Math.max(1,Math.round(.125*(L.width/L.height))),A=L.height+D+10,w=L.width+10,{useMaxWidth:m}=g;_e(d,A,w,!!m),f.debug("Here Bounds",v,L),d.attr("viewBox",`${L.x-5} ${L.y-5} ${L.width+10} ${L.height+10}`)}ke(ze)},xt={draw:bt,getClasses:pt},Dt={parser:Re,db:rt,renderer:xt,styles:lt};export{Dt as diagram};