@telepath-computer/television 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/assets/index-Ctq-tqkf.js +443 -0
- package/dist/browser/assets/index-W7D1rDld.css +1 -0
- package/dist/browser/index.html +2 -2
- package/dist/cli.cjs +7 -1
- package/dist/electron.cjs +7 -1
- package/package.json +1 -1
- package/dist/browser/assets/index-BmwVdck9.css +0 -1
- package/dist/browser/assets/index-DZhAP0Dt.js +0 -430
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
var wi=Object.defineProperty;var Fr=r=>{throw TypeError(r)};var bi=(r,t,e)=>t in r?wi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var h=(r,t,e)=>bi(r,typeof t!="symbol"?t+"":t,e),Wt=(r,t,e)=>t.has(r)||Fr("Cannot "+e);var f=(r,t,e)=>(Wt(r,t,"read from private field"),e?e.call(r):t.get(r)),_=(r,t,e)=>t.has(r)?Fr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),I=(r,t,e,s)=>(Wt(r,t,"write to private field"),s?s.call(r,e):t.set(r,e),e),m=(r,t,e)=>(Wt(r,t,"access private method"),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(i){if(i.ep)return;i.ep=!0;const n=e(i);fetch(i.href,n)}})();const Ur=new WeakMap;function vi(r){return(typeof r=="object"||typeof r=="function")&&r!==null&&"then"in r&&typeof r.then=="function"}function ge(r){return typeof r=="string"?r:typeof r=="symbol"?r.description??r.toString():r.name||"(anonymous class)"}function Br(){return new Error("register(Key, factory) requires a factory function. Wrap existing instances as () => instance.")}function yi(){return new Error("register(Key, factory) does not accept async factories. Await setup before registering.")}class Si{constructor(){h(this,"entries",new Map);h(this,"constructionStack",[])}register(t,e){if(e===void 0){if(typeof t!="function")throw Br();this.validateClassRegistration(t),this.storeFactory(t,()=>this.instantiateClass(t));return}if(typeof e!="function")throw Br();if(e.constructor.name==="AsyncFunction")throw yi();this.storeFactory(t,e)}has(t){var e;return((e=this.entries.get(t))==null?void 0:e.factory)!==void 0}resolve(t){return this.resolveAny(t)}storeFactory(t,e){const s=this.getOrCreateEntry(t);s.factory=e,s.instance=void 0,s.error=void 0}validateClassRegistration(t){const e=Ur.get(t);if(e){if(t.length!==e.length)throw new Error(`${ge(t)} cannot be registered with register(Class). @injectable(...) declared ${e.length} dependencies but constructor arity is ${t.length}. Use register(Key, () => value) instead.`);return}if(t.length!==0)throw new Error(`${ge(t)} cannot be registered with register(Class). Undecorated classes must have zero required constructor parameters. Use register(Key, () => value) instead.`)}instantiateClass(t){const e=Ur.get(t);if(!e)return new t;const s=e.map(i=>this.resolveAny(i));return new t(...s)}resolveAny(t){return this.getOrCreateEntry(t).proxy}getOrCreateEntry(t){let e=this.entries.get(t);return e||(e={key:t},e.proxy=this.createProxy(e),this.entries.set(t,e),e)}createProxy(t){return new Proxy({},{get:(e,s)=>{if(s==="then")return;const i=this.getInstance(t),n=Reflect.get(i,s,i);return typeof n=="function"?n.bind(i):n},set:(e,s,i)=>{const n=this.getInstance(t);return Reflect.set(n,s,i,n)},has:(e,s)=>{const i=this.getInstance(t);return s in i}})}getInstance(t){if(t.instance)return t.instance;if(t.error)throw t.error;if(!t.factory)throw new Error(`${ge(t.key)} was resolved but never registered`);const e=this.constructionStack.indexOf(t.key);if(e!==-1){const s=[...this.constructionStack.slice(e),t.key].map(i=>ge(i)).join(" -> ");throw new Error(`Circular dependency detected: ${s}`)}this.constructionStack.push(t.key);try{const s=t.factory();if(vi(s))throw new Error(`Factory for ${ge(t.key)} returned a Promise. Await setup before registering.`);if(typeof s!="object"||s===null)throw new Error(`Factory for ${ge(t.key)} returned a non-object value. Wrap primitives in an object.`);return t.instance=s,s}catch(s){throw t.error=s,s}finally{this.constructionStack.pop()}}}const O=new Si;function xi(r){return{all:r=r||new Map,on:function(t,e){var s=r.get(t);s?s.push(e):r.set(t,[e])},off:function(t,e){var s=r.get(t);s&&(e?s.splice(s.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var s=r.get(t);s&&s.slice().map(function(i){i(e)}),(s=r.get("*"))&&s.slice().map(function(i){i(t,e)})}}}let br=class{constructor(){h(this,"emitter",xi());h(this,"on",(t,e)=>(this.emitter.on(t,e),{dispose:()=>this.emitter.off(t,e)}));h(this,"once",(t,e)=>{const s=i=>{e(i),this.emitter.off(t,s)};return this.emitter.on(t,s),{dispose:()=>this.emitter.off(t,s)}});h(this,"off",this.emitter.off)}emit(t,...[e]){this.emitter.emit(t,e)}};const xs="0123456789ABCDEFGHJKMNPQRSTVWXYZ",pt=32,_i=16,_s=10,qr=0xffffffffffff;var ae;(function(r){r.Base32IncorrectEncoding="B32_ENC_INVALID",r.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",r.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",r.EncodeTimeNegative="ENC_TIME_NEG",r.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",r.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",r.PRNGDetectFailure="PRNG_DETECT",r.ULIDInvalid="ULID_INVALID",r.Unexpected="UNEXPECTED",r.UUIDInvalid="UUID_INVALID"})(ae||(ae={}));class Ee extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}}function Ai(r){const t=Math.floor(r()*pt)%pt;return xs.charAt(t)}function $i(r){const t=Ei(),e=t&&(t.crypto||t.msCrypto)||null;if(typeof(e==null?void 0:e.getRandomValues)=="function")return()=>{const s=new Uint8Array(1);return e.getRandomValues(s),s[0]/256};if(typeof(e==null?void 0:e.randomBytes)=="function")return()=>e.randomBytes(1).readUInt8()/256;throw new Ee(ae.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Ei(){return Ri()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function Ci(r,t){let e="";for(;r>0;r--)e=Ai(t)+e;return e}function Di(r,t=_s){if(isNaN(r))throw new Ee(ae.EncodeTimeValueMalformed,`Time must be a number: ${r}`);if(r>qr)throw new Ee(ae.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${qr}: ${r}`);if(r<0)throw new Ee(ae.EncodeTimeNegative,`Time must be positive: ${r}`);if(Number.isInteger(r)===!1)throw new Ee(ae.EncodeTimeValueMalformed,`Time must be an integer: ${r}`);let e,s="";for(let i=t;i>0;i--)e=r%pt,s=xs.charAt(e)+s,r=(r-e)/pt;return s}function Ri(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function Xr(r,t){const e=$i(),s=Date.now();return Di(s,_s)+Ci(_i,e)}const L=2,X=6,Ti=1,Pi=2,Ii=3,Li=4,Mi=[Ti,L],Wi=[Pi,Ii,Li,X];function we(r){const t=Math.round(r);return Mi.includes(t)?t:L}function ft(r){const t=Math.round(r);return Wi.includes(t)?t:X}function Xt(r){return{type:"artifact",artifactID:r,cols:L,rows:X}}function vr(r){return{type:"artifact",artifactID:r.artifactID,cols:we(r.cols??L),rows:ft(r.rows??X)}}function Pe(r){const t=Array.isArray(r.layout)?r.layout.map(e=>vr(e)):[];return{id:r.id,name:r.name,layout:t}}function Ot(r){return r.layout.map(t=>t.artifactID)}const tt=[{cols:2,rows:6},{cols:2,rows:4},{cols:2,rows:3},{cols:2,rows:2},{cols:1,rows:2}],zt="create-artifact",Nt="remove-artifact",rt="update-layout";class Oi extends br{constructor(e){var i;super();h(this,"artifacts",new Map);h(this,"activeWorkspaceID",null);h(this,"scrollPosition",0);h(this,"activeWorkspaceData",null);h(this,"clientStore");h(this,"servers");h(this,"pendingMutations",new Map);h(this,"pendingWorkspaceCreates",new Map);h(this,"pendingWorkspaceDeletes",new Map);this.clientStore=e.clientStore,this.servers=e.servers;const s=this.clientStore.get();this.activeWorkspaceID=(s==null?void 0:s.lastWorkspaceID)??null,this.activeWorkspaceID&&(this.scrollPosition=((i=s==null?void 0:s.workspaces[this.activeWorkspaceID])==null?void 0:i.scrollPosition)??0)}get workspaces(){return[...this.servers.values()].flatMap(e=>[...e.workspaces.values()])}get activeWorkspace(){return this.activeWorkspaceData}get activeWorkspaceServerURL(){var e;return this.activeWorkspaceID?((e=this.findWorkspace(this.activeWorkspaceID))==null?void 0:e.serverURL)??null:null}get activeArtifacts(){return(this.activeWorkspaceData?Ot(this.activeWorkspaceData):[]).map(e=>this.artifacts.get(e)).filter(e=>e!==void 0)}setActiveWorkspace(e){this.selectWorkspace(e)}setScrollPosition(e){const s=Math.max(0,e);this.scrollPosition!==s&&(this.scrollPosition=s,this.persistWorkspaceViewState(),this.emit("change"))}createArtifact(e){var l;const s=this.activeWorkspaceData;if(!s)return;const i=this.snapshotState(),n={id:Xr(),type:"markdown",title:e.title,content:e.content};s.layout.some(c=>c.artifactID===n.id)||s.layout.push(Xt(n.id)),this.artifacts.set(n.id,n),this.scrollPosition=Math.max(s.layout.length-1,0),this.persistWorkspaceViewState(),this.emit("change");const a=((l=this.findWorkspace(s.id))==null?void 0:l.server)??null,o=this.getMutationKey(zt,n.id);this.pendingMutations.set(o,i),this.sendServerMessage(a,{type:"create-artifact",id:n.id,title:e.title,content:e.content,workspaceID:s.id})||(this.pendingMutations.delete(o),this.restoreState(i),this.emit("change"))}removeArtifact(e){var o;const s=this.activeWorkspaceData;if(!s||!this.artifacts.has(e))return;const i=this.snapshotState();this.removeArtifactLocally(e),this.emit("change");const n=((o=this.findWorkspace(s.id))==null?void 0:o.server)??null,a=this.getMutationKey(Nt,e);this.pendingMutations.set(a,i),this.sendServerMessage(n,{type:"remove-artifact",artifactID:e,workspaceID:s.id})||(this.pendingMutations.delete(a),this.restoreState(i),this.emit("change"))}reorderLayout(e){const s=this.activeWorkspaceData;if(!s)return;const i=Ot(s);if(e.length!==i.length||e.every((o,l)=>o===i[l]))return;const n=new Map(s.layout.map(o=>[o.artifactID,structuredClone(o)]));if(new Set(e).size!==e.length)return;const a=e.map(o=>n.get(o)).filter(o=>o!==void 0);a.length===e.length&&this.updateLayout(a)}cycleArtifactLayout(e){const s=this.activeWorkspaceData;if(!s)return;const i=s.layout.findIndex(a=>a.artifactID===e);if(i===-1)return;const n=s.layout.map((a,o)=>o===i?{...a,...zi(a.cols,a.rows)}:structuredClone(a));this.updateLayout(n)}handleServerEvent(e,s){var i;switch(s.type){case"workspace-list":this.syncActiveWorkspaceState(e,!0);break;case"workspace-updated":this.syncActiveWorkspaceState(e,!1),Array.isArray(s.fields.layout)&&this.pendingMutations.delete(this.getMutationKey(rt,s.workspaceID));break;case"workspace-removed":{this.syncActiveWorkspaceState(e,!1);const n=this.pendingWorkspaceDeletes.get(s.workspaceID);n&&(this.pendingWorkspaceDeletes.delete(s.workspaceID),n.resolve());break}case"workspace-created":if(this.pendingWorkspaceCreates.has(s.workspace.id)){const n=this.pendingWorkspaceCreates.get(s.workspace.id);this.pendingWorkspaceCreates.delete(s.workspace.id),this.selectWorkspace(s.workspace.id),n==null||n.resolve();return}this.syncActiveWorkspaceState(e,!1);break;case"workspace":this.applyWorkspaceSnapshot(s.workspace,s.artifacts);break;case"artifact-created":this.pendingMutations.delete(this.getMutationKey(zt,s.artifact.id)),this.applyArtifactCreated(s);break;case"artifact-updated":this.applyArtifactUpdated(s);break;case"artifact-removed":if(this.pendingMutations.delete(this.getMutationKey(Nt,s.artifactID)),((i=this.activeWorkspaceData)==null?void 0:i.id)!==s.workspaceID)return;this.removeArtifactLocally(s.artifactID)&&this.emit("change");break;case"error":this.handleServerError(s);break}}createWorkspace(e,s){const i=this.servers.get(e)??null,n=Xr(),a=Gr();return this.pendingWorkspaceCreates.set(n,a),this.sendServerMessage(i,{type:"create-workspace",id:n,name:s})||(this.pendingWorkspaceCreates.delete(n),a.reject(new Error(`Server unavailable: ${e}`))),a.promise}deleteWorkspace(){var a;const e=this.activeWorkspaceData;if(!e)return Promise.reject(new Error("No active workspace"));const s=this.pendingWorkspaceDeletes.get(e.id);if(s)return s.promise;const i=((a=this.findWorkspace(e.id))==null?void 0:a.server)??null,n=Gr();return this.pendingWorkspaceDeletes.set(e.id,n),this.sendServerMessage(i,{type:"delete-workspace",workspaceID:e.id})||(this.pendingWorkspaceDeletes.delete(e.id),n.reject(new Error(`Server unavailable: ${e.id}`))),n.promise}renameWorkspace(e){var n;const s=this.activeWorkspaceData;if(!s)return;const i=((n=this.findWorkspace(s.id))==null?void 0:n.server)??null;s.name=e,this.emit("change"),this.sendServerMessage(i,{type:"update-workspace",workspaceID:s.id,fields:{name:e}})}updateLayout(e){var o;const s=this.activeWorkspaceData;if(!s)return;const i=this.snapshotState();s.layout=e,this.emit("change");const n=((o=this.findWorkspace(s.id))==null?void 0:o.server)??null,a=this.getMutationKey(rt,s.id);this.pendingMutations.set(a,i),this.sendServerMessage(n,{type:"update-workspace",workspaceID:s.id,fields:{layout:e.map(l=>structuredClone(l))}})||(this.pendingMutations.delete(a),this.restoreState(i),this.emit("change"))}syncActiveWorkspaceState(e,s){const i=this.activeWorkspaceID?this.findWorkspace(this.activeWorkspaceID):null;if(!i){const n=this.pickNextWorkspace();if(!n){const a=this.activeWorkspaceID!==null||this.activeWorkspaceData!==null||this.artifacts.size>0;this.activeWorkspaceID=null,this.activeWorkspaceData=null,this.artifacts.clear(),this.scrollPosition=0,a&&this.emit("change");return}this.selectWorkspace(n.workspace.id);return}this.applyServerWorkspaceState(i.workspace),s&&i.serverURL===e&&this.requestWorkspace(i.serverURL,i.workspace.id)}hasPendingLayoutMutation(e){return this.pendingMutations.has(this.getMutationKey(rt,e))}selectWorkspace(e){const s=this.findWorkspace(e);s&&(this.activeWorkspaceID=e,this.activeWorkspaceData=structuredClone(Pe(s.workspace)),this.artifacts.clear(),this.restoreWorkspaceViewState(),this.persistActiveWorkspace(),this.requestWorkspace(s.serverURL,e),this.emit("change"))}requestWorkspace(e,s){const i=this.servers.get(e);this.sendServerMessage(i??null,{type:"get-workspace",workspaceID:s})}applyWorkspaceSnapshot(e,s){if(e.id===this.activeWorkspaceID){this.applyServerWorkspaceState(e),this.artifacts.clear();for(const i of s)this.artifacts.set(i.id,structuredClone(i));this.restoreWorkspaceViewState(),this.emit("change")}}applyServerWorkspaceState(e){const s=Pe(e);if(!this.activeWorkspaceData||this.activeWorkspaceData.id!==s.id){this.activeWorkspaceData=structuredClone(s);return}this.activeWorkspaceData.name=s.name,this.hasPendingLayoutMutation(s.id)||(this.activeWorkspaceData.layout=s.layout.map(i=>structuredClone(i)))}applyArtifactCreated(e){var s;((s=this.activeWorkspaceData)==null?void 0:s.id)===e.workspaceID&&(this.activeWorkspaceData.layout.some(i=>i.artifactID===e.artifact.id)||this.activeWorkspaceData.layout.push(Xt(e.artifact.id)),this.artifacts.set(e.artifact.id,e.artifact),this.emit("change"))}applyArtifactUpdated(e){const s=this.artifacts.get(e.artifactID);s&&(Object.assign(s,e.fields),this.emit("change"))}removeArtifactLocally(e){if(!this.activeWorkspaceData)return!1;const s=this.artifacts.delete(e),i=this.activeWorkspaceData.layout.length;return this.activeWorkspaceData.layout=this.activeWorkspaceData.layout.filter(n=>n.artifactID!==e),!(!s&&i===this.activeWorkspaceData.layout.length)}snapshotState(){return{activeWorkspaceData:this.activeWorkspaceData?structuredClone(this.activeWorkspaceData):null,scrollPosition:this.scrollPosition,artifacts:new Map([...this.artifacts.entries()].map(([e,s])=>[e,structuredClone(s)]))}}restoreState(e){this.activeWorkspaceData=e.activeWorkspaceData?structuredClone(e.activeWorkspaceData):null,this.scrollPosition=e.scrollPosition,this.artifacts.clear();for(const[s,i]of e.artifacts.entries())this.artifacts.set(s,structuredClone(i));this.persistWorkspaceViewState()}handleServerError(e){const s=e.request;if(s){if(s.type==="create-artifact"){const i=this.getMutationKey(zt,s.id),n=this.pendingMutations.get(i);if(!n)return;this.pendingMutations.delete(i),this.restoreState(n),this.emit("change");return}if(s.type==="create-workspace"){const i=this.pendingWorkspaceCreates.get(s.id);if(!i)return;this.pendingWorkspaceCreates.delete(s.id),i.reject(new Error(e.message));return}if(s.type==="delete-workspace"){const i=this.pendingWorkspaceDeletes.get(s.workspaceID);if(!i)return;this.pendingWorkspaceDeletes.delete(s.workspaceID),i.reject(new Error(e.message));return}if(s.type==="update-workspace"&&Array.isArray(s.fields.layout)){const i=this.getMutationKey(rt,s.workspaceID),n=this.pendingMutations.get(i);if(!n)return;this.pendingMutations.delete(i),this.restoreState(n),this.emit("change");return}if(s.type==="remove-artifact"){const i=this.getMutationKey(Nt,s.artifactID),n=this.pendingMutations.get(i);if(!n)return;this.pendingMutations.delete(i),this.restoreState(n),this.emit("change")}}}restoreWorkspaceViewState(){var i,n;if(!this.activeWorkspaceID){this.scrollPosition=0;return}const e=((n=(i=this.clientStore.get())==null?void 0:i.workspaces[this.activeWorkspaceID])==null?void 0:n.scrollPosition)??0,s=this.activeWorkspaceData?Ot(this.activeWorkspaceData):[];this.scrollPosition=Math.max(0,Math.min(e,Math.max(s.length-1,0))),this.persistWorkspaceViewState()}persistActiveWorkspace(){this.clientStore.update(e=>{e.lastWorkspaceID=this.activeWorkspaceID})}persistWorkspaceViewState(){this.activeWorkspaceID&&this.clientStore.update(e=>{var s,i;(s=e.workspaces)[i=this.activeWorkspaceID]??(s[i]={scrollPosition:0}),e.workspaces[this.activeWorkspaceID].scrollPosition=this.scrollPosition})}findWorkspace(e){for(const[s,i]of this.servers){const n=i.workspaces.get(e);if(n)return{serverURL:s,server:i,workspace:n}}return null}pickNextWorkspace(){var s;const e=(s=this.clientStore.get())==null?void 0:s.lastWorkspaceID;if(e){const i=this.findWorkspace(e);if(i)return i}for(const[i,n]of this.servers){const a=n.workspaces.values().next().value;if(a)return{serverURL:i,server:n,workspace:a}}return null}sendServerMessage(e,s){return!(e!=null&&e.socket)||e.socket.readyState!==1?!1:(e.socket.send(JSON.stringify(s)),!0)}getMutationKey(e,s){return`${e}:${s}`}}function zi(r,t){const e=tt.findIndex(i=>i.cols===r&&i.rows===t),s=e===-1?0:(e+1)%tt.length;return{cols:tt[s].cols,rows:tt[s].rows}}function Gr(){let r,t;return{promise:new Promise((s,i)=>{r=s,t=i}),resolve:r,reject:t}}var As=Symbol.for("immer-nothing"),Vr=Symbol.for("immer-draftable"),M=Symbol.for("immer-state");function F(r,...t){throw new Error(`[Immer] minified error nr: ${r}. Full error at: https://bit.ly/3cXEKWf`)}var Le=Object.getPrototypeOf;function be(r){return!!r&&!!r[M]}function ce(r){var t;return r?$s(r)||Array.isArray(r)||!!r[Vr]||!!((t=r.constructor)!=null&&t[Vr])||Ye(r)||Et(r):!1}var Ni=Object.prototype.constructor.toString(),Kr=new WeakMap;function $s(r){if(!r||typeof r!="object")return!1;const t=Object.getPrototypeOf(r);if(t===null||t===Object.prototype)return!0;const e=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(e===Object)return!0;if(typeof e!="function")return!1;let s=Kr.get(e);return s===void 0&&(s=Function.toString.call(e),Kr.set(e,s)),s===Ni}function gt(r,t,e=!0){$t(r)===0?(e?Reflect.ownKeys(r):Object.keys(r)).forEach(i=>{t(i,r[i],r)}):r.forEach((s,i)=>t(i,s,r))}function $t(r){const t=r[M];return t?t.type_:Array.isArray(r)?1:Ye(r)?2:Et(r)?3:0}function Gt(r,t){return $t(r)===2?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function Es(r,t,e){const s=$t(r);s===2?r.set(t,e):s===3?r.add(e):r[t]=e}function Hi(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Ye(r){return r instanceof Map}function Et(r){return r instanceof Set}function ee(r){return r.copy_||r.base_}function Vt(r,t){if(Ye(r))return new Map(r);if(Et(r))return new Set(r);if(Array.isArray(r))return Array.prototype.slice.call(r);const e=$s(r);if(t===!0||t==="class_only"&&!e){const s=Object.getOwnPropertyDescriptors(r);delete s[M];let i=Reflect.ownKeys(s);for(let n=0;n<i.length;n++){const a=i[n],o=s[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(s[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:r[a]})}return Object.create(Le(r),s)}else{const s=Le(r);if(s!==null&&e)return{...r};const i=Object.create(s);return Object.assign(i,r)}}function yr(r,t=!1){return Ct(r)||be(r)||!ce(r)||($t(r)>1&&Object.defineProperties(r,{set:st,add:st,clear:st,delete:st}),Object.freeze(r),t&&Object.values(r).forEach(e=>yr(e,!0))),r}function Fi(){F(2)}var st={value:Fi};function Ct(r){return r===null||typeof r!="object"?!0:Object.isFrozen(r)}var Ui={};function he(r){const t=Ui[r];return t||F(0,r),t}var Me;function Cs(){return Me}function Bi(r,t){return{drafts_:[],parent_:r,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Zr(r,t){t&&(he("Patches"),r.patches_=[],r.inversePatches_=[],r.patchListener_=t)}function Kt(r){Zt(r),r.drafts_.forEach(qi),r.drafts_=null}function Zt(r){r===Me&&(Me=r.parent_)}function jr(r){return Me=Bi(Me,r)}function qi(r){const t=r[M];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Yr(r,t){t.unfinalizedDrafts_=t.drafts_.length;const e=t.drafts_[0];return r!==void 0&&r!==e?(e[M].modified_&&(Kt(t),F(4)),ce(r)&&(r=mt(t,r),t.parent_||kt(t,r)),t.patches_&&he("Patches").generateReplacementPatches_(e[M].base_,r,t.patches_,t.inversePatches_)):r=mt(t,e,[]),Kt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),r!==As?r:void 0}function mt(r,t,e){if(Ct(t))return t;const s=r.immer_.shouldUseStrictIteration(),i=t[M];if(!i)return gt(t,(n,a)=>Qr(r,i,t,n,a,e),s),t;if(i.scope_!==r)return t;if(!i.modified_)return kt(r,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const n=i.copy_;let a=n,o=!1;i.type_===3&&(a=new Set(n),n.clear(),o=!0),gt(a,(l,c)=>Qr(r,i,n,l,c,e,o),s),kt(r,n,!1),e&&r.patches_&&he("Patches").generatePatches_(i,e,r.patches_,r.inversePatches_)}return i.copy_}function Qr(r,t,e,s,i,n,a){if(i==null||typeof i!="object"&&!a)return;const o=Ct(i);if(!(o&&!a)){if(be(i)){const l=n&&t&&t.type_!==3&&!Gt(t.assigned_,s)?n.concat(s):void 0,c=mt(r,i,l);if(Es(e,s,c),be(c))r.canAutoFreeze_=!1;else return}else a&&e.add(i);if(ce(i)&&!o){if(!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||t&&t.base_&&t.base_[s]===i&&o)return;mt(r,i),(!t||!t.scope_.parent_)&&typeof s!="symbol"&&(Ye(e)?e.has(s):Object.prototype.propertyIsEnumerable.call(e,s))&&kt(r,i)}}}function kt(r,t,e=!1){!r.parent_&&r.immer_.autoFreeze_&&r.canAutoFreeze_&&yr(t,e)}function Xi(r,t){const e=Array.isArray(r),s={type_:e?1:0,scope_:t?t.scope_:Cs(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:r,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=s,n=Sr;e&&(i=[s],n=We);const{revoke:a,proxy:o}=Proxy.revocable(i,n);return s.draft_=o,s.revoke_=a,o}var Sr={get(r,t){if(t===M)return r;const e=ee(r);if(!Gt(e,t))return Gi(r,e,t);const s=e[t];return r.finalized_||!ce(s)?s:s===Ht(r.base_,t)?(Ft(r),r.copy_[t]=Yt(s,r)):s},has(r,t){return t in ee(r)},ownKeys(r){return Reflect.ownKeys(ee(r))},set(r,t,e){const s=Ds(ee(r),t);if(s!=null&&s.set)return s.set.call(r.draft_,e),!0;if(!r.modified_){const i=Ht(ee(r),t),n=i==null?void 0:i[M];if(n&&n.base_===e)return r.copy_[t]=e,r.assigned_[t]=!1,!0;if(Hi(e,i)&&(e!==void 0||Gt(r.base_,t)))return!0;Ft(r),jt(r)}return r.copy_[t]===e&&(e!==void 0||t in r.copy_)||Number.isNaN(e)&&Number.isNaN(r.copy_[t])||(r.copy_[t]=e,r.assigned_[t]=!0),!0},deleteProperty(r,t){return Ht(r.base_,t)!==void 0||t in r.base_?(r.assigned_[t]=!1,Ft(r),jt(r)):delete r.assigned_[t],r.copy_&&delete r.copy_[t],!0},getOwnPropertyDescriptor(r,t){const e=ee(r),s=Reflect.getOwnPropertyDescriptor(e,t);return s&&{writable:!0,configurable:r.type_!==1||t!=="length",enumerable:s.enumerable,value:e[t]}},defineProperty(){F(11)},getPrototypeOf(r){return Le(r.base_)},setPrototypeOf(){F(12)}},We={};gt(Sr,(r,t)=>{We[r]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});We.deleteProperty=function(r,t){return We.set.call(this,r,t,void 0)};We.set=function(r,t,e){return Sr.set.call(this,r[0],t,e,r[0])};function Ht(r,t){const e=r[M];return(e?ee(e):r)[t]}function Gi(r,t,e){var i;const s=Ds(t,e);return s?"value"in s?s.value:(i=s.get)==null?void 0:i.call(r.draft_):void 0}function Ds(r,t){if(!(t in r))return;let e=Le(r);for(;e;){const s=Object.getOwnPropertyDescriptor(e,t);if(s)return s;e=Le(e)}}function jt(r){r.modified_||(r.modified_=!0,r.parent_&&jt(r.parent_))}function Ft(r){r.copy_||(r.copy_=Vt(r.base_,r.scope_.immer_.useStrictShallowCopy_))}var Vi=class{constructor(r){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,e,s)=>{if(typeof t=="function"&&typeof e!="function"){const n=e;e=t;const a=this;return function(l=n,...c){return a.produce(l,u=>e.call(this,u,...c))}}typeof e!="function"&&F(6),s!==void 0&&typeof s!="function"&&F(7);let i;if(ce(t)){const n=jr(this),a=Yt(t,void 0);let o=!0;try{i=e(a),o=!1}finally{o?Kt(n):Zt(n)}return Zr(n,s),Yr(i,n)}else if(!t||typeof t!="object"){if(i=e(t),i===void 0&&(i=t),i===As&&(i=void 0),this.autoFreeze_&&yr(i,!0),s){const n=[],a=[];he("Patches").generateReplacementPatches_(t,i,n,a),s(n,a)}return i}else F(1,t)},this.produceWithPatches=(t,e)=>{if(typeof t=="function")return(a,...o)=>this.produceWithPatches(a,l=>t(l,...o));let s,i;return[this.produce(t,e,(a,o)=>{s=a,i=o}),s,i]},typeof(r==null?void 0:r.autoFreeze)=="boolean"&&this.setAutoFreeze(r.autoFreeze),typeof(r==null?void 0:r.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(r.useStrictShallowCopy),typeof(r==null?void 0:r.useStrictIteration)=="boolean"&&this.setUseStrictIteration(r.useStrictIteration)}createDraft(r){ce(r)||F(8),be(r)&&(r=Ki(r));const t=jr(this),e=Yt(r,void 0);return e[M].isManual_=!0,Zt(t),e}finishDraft(r,t){const e=r&&r[M];(!e||!e.isManual_)&&F(9);const{scope_:s}=e;return Zr(s,t),Yr(void 0,s)}setAutoFreeze(r){this.autoFreeze_=r}setUseStrictShallowCopy(r){this.useStrictShallowCopy_=r}setUseStrictIteration(r){this.useStrictIteration_=r}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(r,t){let e;for(e=t.length-1;e>=0;e--){const i=t[e];if(i.path.length===0&&i.op==="replace"){r=i.value;break}}e>-1&&(t=t.slice(e+1));const s=he("Patches").applyPatches_;return be(r)?s(r,t):this.produce(r,i=>s(i,t))}};function Yt(r,t){const e=Ye(r)?he("MapSet").proxyMap_(r,t):Et(r)?he("MapSet").proxySet_(r,t):Xi(r,t);return(t?t.scope_:Cs()).drafts_.push(e),e}function Ki(r){return be(r)||F(10,r),Rs(r)}function Rs(r){if(!ce(r)||Ct(r))return r;const t=r[M];let e,s=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,e=Vt(r,t.scope_.immer_.useStrictShallowCopy_),s=t.scope_.immer_.shouldUseStrictIteration()}else e=Vt(r,!0);return gt(e,(i,n)=>{Es(e,i,Rs(n))},s),t&&(t.finalized_=!1),e}var Zi=new Vi,ji=Zi.produce,Yi=Object.defineProperty,Qi=(r,t,e)=>t in r?Yi(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,it=(r,t,e)=>Qi(r,typeof t!="symbol"?t+"":t,e);function Ji(r){return{all:r=r||new Map,on:function(t,e){var s=r.get(t);s?s.push(e):r.set(t,[e])},off:function(t,e){var s=r.get(t);s&&(e?s.splice(s.indexOf(e)>>>0,1):r.set(t,[]))},emit:function(t,e){var s=r.get(t);s&&s.slice().map(function(i){i(e)}),(s=r.get("*"))&&s.slice().map(function(i){i(t,e)})}}}var en=class{constructor(){it(this,"emitter",Ji()),it(this,"on",(r,t)=>(this.emitter.on(r,t),{dispose:()=>this.emitter.off(r,t)})),it(this,"once",(r,t)=>{const e=s=>{t(s),this.emitter.off(r,e)};return this.emitter.on(r,e),{dispose:()=>this.emitter.off(r,e)}}),it(this,"off",this.emitter.off)}emit(r,...[t]){this.emitter.emit(r,t)}},tn="store-",rn=class extends en{emitChange(r){this.emit("change",{state:r})}},sn=class{constructor(r,t,e){this.emitter=new rn,this.id=r,this.initValue=t,this.key=`${tn}${r}`,this.storage=(e==null?void 0:e.storage)==="session"?sessionStorage:localStorage,this.get()===void 0&&this.storage.setItem(this.key,JSON.stringify(t))}get(){const r=this.storage.getItem(this.key);return r===null?void 0:JSON.parse(r)}update(r){const t=this.get()??{},e=ji(t,r);this.storage.setItem(this.key,JSON.stringify(e)),this.emitter.emitChange(e)}reset(){this.storage.setItem(this.key,JSON.stringify(this.initValue)),this.emitter.emitChange(this.initValue)}on(r,t){return this.emitter.on(r,({state:e})=>t(e))}subscribe(r){const t=this.on("change",r),e=this.get();return e!==void 0&&r(e),t}};const nn="Local";function K(r){return new URL(r).origin}function an(r){return{servers:[{url:K(r),name:nn}],lastWorkspaceID:null,workspaces:{}}}function on(r,t){return new sn(r,an(t))}const ln=4401,Jr=1e3,cn=3e4,hn=2;class Ts extends br{constructor(e){super();h(this,"url");h(this,"name");h(this,"token");h(this,"servers");h(this,"createSocket");h(this,"reconnectDelay",Jr);h(this,"reconnectTimer",null);h(this,"closed",!1);this.url=K(e.url),this.name=e.name,this.token=e.token??null,this.servers=e.servers,this.createSocket=e.createSocket??(s=>new WebSocket(s))}connect(){var i;this.closed=!1,this.clearReconnectTimer();const e=this.createSocket(un(this.url,this.token)),s={url:this.url,name:this.name,socket:e,workspaces:((i=this.servers.get(this.url))==null?void 0:i.workspaces)??new Map};this.servers.set(this.url,s),this.reconnectDelay=Jr,this.emit("change"),e.addEventListener("message",n=>{const a=fn(pn(n));this.applyServerMessage(s,a),this.emit("serverEvent",{serverURL:s.url,event:a}),this.emit("change")}),e.addEventListener("close",n=>{if(this.servers.get(s.url)!==s||(s.socket=null,this.emit("change"),this.closed))return;if(dn(n)===ln){this.closed=!0,this.emit("auth-failed");return}const a=this.reconnectDelay;this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},a),this.reconnectDelay=Math.min(a*hn,cn)})}disconnect(){var s;this.closed=!0,this.clearReconnectTimer();const e=this.servers.get(this.url);e&&(this.servers.delete(this.url),(s=e.socket)==null||s.close(),this.emit("change"))}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}applyServerMessage(e,s){switch(s.type){case"workspace-list":e.workspaces=new Map(s.workspaces.map(i=>[i.id,structuredClone(i)]));break;case"workspace-created":e.workspaces.set(s.workspace.id,structuredClone(s.workspace));break;case"workspace-updated":{const i=e.workspaces.get(s.workspaceID);i&&(typeof s.fields.name=="string"&&(i.name=s.fields.name),Array.isArray(s.fields.layout)&&(i.layout=s.fields.layout.map(n=>vr(n))));break}case"workspace-removed":e.workspaces.delete(s.workspaceID);break;case"artifact-created":{const i=e.workspaces.get(s.workspaceID);i&&!i.layout.some(n=>n.artifactID===s.artifact.id)&&i.layout.push(Xt(s.artifact.id));break}case"artifact-removed":{const i=e.workspaces.get(s.workspaceID);i&&(i.layout=i.layout.filter(n=>n.artifactID!==s.artifactID));break}}}}function un(r,t){const e=new URL(r);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/ws",e.search="",t&&e.searchParams.set("token",t),e.hash="",e.toString()}function dn(r){return typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="number"?r.code:null}function pn(r){const t=typeof r=="string"?r:typeof r=="object"&&r!==null&&"data"in r&&typeof r.data=="string"?r.data:"";return JSON.parse(t)}function fn(r){switch(r.type){case"workspace-list":return{...r,workspaces:r.workspaces.map(t=>Pe(t))};case"workspace-created":return{...r,workspace:Pe(r.workspace)};case"workspace":return{...r,workspace:Pe(r.workspace)};case"workspace-updated":return{...r,fields:{...r.fields,...Array.isArray(r.fields.layout)?{layout:r.fields.layout.map(t=>vr(t))}:{}}};default:return r}}class gn extends br{constructor(e){super();h(this,"localServerURL");h(this,"clientStore");h(this,"servers");h(this,"workspaceService");h(this,"createSocket");h(this,"connections",new Map);this.clientStore=e.clientStore,this.servers=e.servers,this.workspaceService=e.workspaceService,this.localServerURL=e.localServerURL?K(e.localServerURL):null,this.createSocket=e.createSocket??(s=>new WebSocket(s))}get serverRecords(){return[...this.servers.values()]}connectConfiguredServers(){const e=this.clientStore.get();for(const s of(e==null?void 0:e.servers)??[])this.connectServer(s)}addServer(e,s){const i=K(e),n=this.connections.get(i);n&&(n.disconnect(),this.connections.delete(i)),this.connectServer({url:i,name:s}),this.clientStore.update(a=>{a.servers=a.servers.filter(o=>K(o.url)!==i),a.servers.push({url:i,name:s})}),this.emit("change")}removeServer(e){var n;const s=K(e);this.localServerURL&&s===this.localServerURL||!this.servers.get(s)||((n=this.connections.get(s))==null||n.disconnect(),this.connections.delete(s),this.clientStore.update(a=>{a.servers=a.servers.filter(o=>K(o.url)!==s)}),this.emit("change"))}connectServer(e){const s=K(e.url),i=new Ts({url:s,name:e.name,servers:this.servers,createSocket:this.createSocket});this.connections.set(s,i),i.on("serverEvent",({serverURL:n,event:a})=>{this.workspaceService.handleServerEvent(n,a),this.emit("change")}),i.on("change",()=>this.emit("change")),i.connect()}}const mn="serverURL",kn="token",wn="mode",bn="electron";function vn(r=window.location.search,t=window.location.origin){const s=new URLSearchParams(r).get(mn);return s?new URL(s).origin:new URL(t).origin}function yn(r=window.location.search){return new URLSearchParams(r).get(kn)}function Sn(r=window.location.search){return new URLSearchParams(r).get(wn)===bn}/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const Ie=globalThis,es=r=>r,wt=Ie.trustedTypes,ts=wt?wt.createPolicy("lit-html",{createHTML:r=>r}):void 0,Ps="$lit$",Z=`lit$${Math.random().toFixed(9).slice(2)}$`,Is="?"+Z,xn=`<${Is}>`,ue=document,Oe=()=>ue.createComment(""),ze=r=>r===null||typeof r!="object"&&typeof r!="function",xr=Array.isArray,_n=r=>xr(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Ut=`[
|
|
6
|
+
\f\r]`,_e=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,rs=/-->/g,ss=/>/g,J=RegExp(`>|${Ut}(?:([^\\s"'>=/]+)(${Ut}*=${Ut}*(?:[^
|
|
7
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),is=/'/g,ns=/"/g,Ls=/^(?:script|style|textarea|title)$/i,An=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),v=An(1),ve=Symbol.for("lit-noChange"),C=Symbol.for("lit-nothing"),as=new WeakMap,oe=ue.createTreeWalker(ue,129);function Ms(r,t){if(!xr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return ts!==void 0?ts.createHTML(t):t}const $n=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",a=_e;for(let o=0;o<e;o++){const l=r[o];let c,u,d=-1,g=0;for(;g<l.length&&(a.lastIndex=g,u=a.exec(l),u!==null);)g=a.lastIndex,a===_e?u[1]==="!--"?a=rs:u[1]!==void 0?a=ss:u[2]!==void 0?(Ls.test(u[2])&&(i=RegExp("</"+u[2],"g")),a=J):u[3]!==void 0&&(a=J):a===J?u[0]===">"?(a=i??_e,d=-1):u[1]===void 0?d=-2:(d=a.lastIndex-u[2].length,c=u[1],a=u[3]===void 0?J:u[3]==='"'?ns:is):a===ns||a===is?a=J:a===rs||a===ss?a=_e:(a=J,i=void 0);const p=a===J&&r[o+1].startsWith("/>")?" ":"";n+=a===_e?l+xn:d>=0?(s.push(c),l.slice(0,d)+Ps+l.slice(d)+Z+p):l+Z+(d===-2?o:p)}return[Ms(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class Ne{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,a=0;const o=t.length-1,l=this.parts,[c,u]=$n(t,e);if(this.el=Ne.createElement(c,s),oe.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=oe.nextNode())!==null&&l.length<o;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(Ps)){const g=u[a++],p=i.getAttribute(d).split(Z),w=/([.?@])?(.*)/.exec(g);l.push({type:1,index:n,name:w[2],strings:p,ctor:w[1]==="."?Cn:w[1]==="?"?Dn:w[1]==="@"?Rn:Dt}),i.removeAttribute(d)}else d.startsWith(Z)&&(l.push({type:6,index:n}),i.removeAttribute(d));if(Ls.test(i.tagName)){const d=i.textContent.split(Z),g=d.length-1;if(g>0){i.textContent=wt?wt.emptyScript:"";for(let p=0;p<g;p++)i.append(d[p],Oe()),oe.nextNode(),l.push({type:2,index:++n});i.append(d[g],Oe())}}}else if(i.nodeType===8)if(i.data===Is)l.push({type:2,index:n});else{let d=-1;for(;(d=i.data.indexOf(Z,d+1))!==-1;)l.push({type:7,index:n}),d+=Z.length-1}n++}}static createElement(t,e){const s=ue.createElement("template");return s.innerHTML=t,s}}function ye(r,t,e=r,s){var a,o;if(t===ve)return t;let i=s!==void 0?(a=e._$Co)==null?void 0:a[s]:e._$Cl;const n=ze(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((o=i==null?void 0:i._$AO)==null||o.call(i,!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=ye(r,i._$AS(r,t.values),i,s)),t}class En{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??ue).importNode(e,!0);oe.currentNode=i;let n=oe.nextNode(),a=0,o=0,l=s[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new _r(n,n.nextSibling,this,t):l.type===1?c=new l.ctor(n,l.name,l.strings,this,t):l.type===6&&(c=new Tn(n,this,t)),this._$AV.push(c),l=s[++o]}a!==(l==null?void 0:l.index)&&(n=oe.nextNode(),a++)}return oe.currentNode=ue,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}let _r=class Ws{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=C,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ye(this,t,e),ze(t)?t===C||t==null||t===""?(this._$AH!==C&&this._$AR(),this._$AH=C):t!==this._$AH&&t!==ve&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):_n(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==C&&ze(this._$AH)?this._$AA.nextSibling.data=t:this.T(ue.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Ne.createElement(Ms(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const a=new En(i,this),o=a.u(this.options);a.p(e),this.T(o),this._$AH=a}}_$AC(t){let e=as.get(t.strings);return e===void 0&&as.set(t.strings,e=new Ne(t)),e}k(t){xr(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Ws(this.O(Oe()),this.O(Oe()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t!==this._$AB;){const i=es(t).nextSibling;es(t).remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class Dt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=C,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=C}_$AI(t,e=this,s,i){const n=this.strings;let a=!1;if(n===void 0)t=ye(this,t,e,0),a=!ze(t)||t!==this._$AH&&t!==ve,a&&(this._$AH=t);else{const o=t;let l,c;for(t=n[0],l=0;l<n.length-1;l++)c=ye(this,o[s+l],e,l),c===ve&&(c=this._$AH[l]),a||(a=!ze(c)||c!==this._$AH[l]),c===C?t=C:t!==C&&(t+=(c??"")+n[l+1]),this._$AH[l]=c}a&&!i&&this.j(t)}j(t){t===C?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Cn extends Dt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===C?void 0:t}}let Dn=class extends Dt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==C)}},Rn=class extends Dt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=ye(this,t,e,0)??C)===ve)return;const s=this._$AH,i=t===C&&s!==C||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==C&&(s===C||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Tn=class{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){ye(this,t)}};const Bt=Ie.litHtmlPolyfillSupport;Bt==null||Bt(Ne,_r),(Ie.litHtmlVersions??(Ie.litHtmlVersions=[])).push("3.3.2");const D=(r,t,e)=>{const s=t;let i=s._$litPart$;return i===void 0&&(s._$litPart$=i=new _r(t.insertBefore(Oe(),null),null,void 0,{})),i._$AI(r),i};/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright 2017 Google LLC
|
|
10
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
+
*/const Pn={CHILD:2},Os=r=>(...t)=>({_$litDirective$:r,values:t});class In{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright 2017 Google LLC
|
|
14
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
15
|
+
*/class bt extends In{constructor(t){if(super(t),this.it=C,t.type!==Pn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===C||t==null)return this._t=void 0,this.it=t;if(t===ve)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}bt.directiveName="unsafeHTML",bt.resultType=1;const Ln=Os(bt);/**
|
|
16
|
+
* @license
|
|
17
|
+
* Copyright 2017 Google LLC
|
|
18
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
+
*/class Qt extends bt{}Qt.directiveName="unsafeSVG",Qt.resultType=2;const Mn=Os(Qt),Wn={size:16,color:"currentColor",weight:"regular"};function On(r){return typeof r=="string"?{regular:r}:r}function Ar(r,t="0 0 256 256"){const e=On(r);return s=>{const{size:i,color:n,weight:a}={...Wn,...s},o=e[a]??e.regular;return v`<svg
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
data-ui-icon=""
|
|
22
|
+
width="${i}"
|
|
23
|
+
height="${i}"
|
|
24
|
+
viewBox="${t}"
|
|
25
|
+
fill="${n}"
|
|
26
|
+
>${Mn(o)}</svg>`}}const zn=new Map,qt=new Set;var me,lt;const Wr=class Wr extends HTMLElement{constructor(){super(...arguments);_(this,me)}connectedCallback(){m(this,me,lt).call(this)}disconnectedCallback(){qt.delete(this)}attributeChangedCallback(){m(this,me,lt).call(this)}refresh(){m(this,me,lt).call(this)}get name(){return this.getAttribute("name")}get size(){const e=this.getAttribute("size");if(e===null)return;const s=Number(e);return Number.isFinite(s)?s:void 0}get weight(){const e=this.getAttribute("weight");return e==="bold"||e==="regular"?e:void 0}};me=new WeakSet,lt=function(){const e=this.name?zn.get(this.name):null;if(!e){this.name&&qt.add(this),D(null,this);return}qt.delete(this),D(e({size:this.size,weight:this.weight}),this)},Wr.observedAttributes=["name","size","weight"];let Jt=Wr;customElements.get("icon-element")||customElements.define("icon-element",Jt);const zs=Ar('<path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/>'),er=Ar('<path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"/>'),Nn=Ar('<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Zm88-29.84q.06-2.16,0-4.32l14.92-18.64a8,8,0,0,0,1.48-7.06,107.21,107.21,0,0,0-10.88-26.25,8,8,0,0,0-6-3.93l-23.72-2.64q-1.48-1.56-3-3L186,40.54a8,8,0,0,0-3.94-6,107.71,107.71,0,0,0-26.25-10.87,8,8,0,0,0-7.06,1.49L130.16,40Q128,40,125.84,40L107.2,25.11a8,8,0,0,0-7.06-1.48A107.6,107.6,0,0,0,73.89,34.51a8,8,0,0,0-3.93,6L67.32,64.27q-1.56,1.49-3,3L40.54,70a8,8,0,0,0-6,3.94,107.71,107.71,0,0,0-10.87,26.25,8,8,0,0,0,1.49,7.06L40,125.84Q40,128,40,130.16L25.11,148.8a8,8,0,0,0-1.48,7.06,107.21,107.21,0,0,0,10.88,26.25,8,8,0,0,0,6,3.93l23.72,2.64q1.49,1.56,3,3L70,215.46a8,8,0,0,0,3.94,6,107.71,107.71,0,0,0,26.25,10.87,8,8,0,0,0,7.06-1.49L125.84,216q2.16.06,4.32,0l18.64,14.92a8,8,0,0,0,7.06,1.48,107.21,107.21,0,0,0,26.25-10.88,8,8,0,0,0,3.93-6l2.64-23.72q1.56-1.48,3-3L215.46,186a8,8,0,0,0,6-3.94,107.71,107.71,0,0,0,10.87-26.25,8,8,0,0,0-1.49-7.06Zm-16.1-6.5a73.93,73.93,0,0,1,0,8.68,8,8,0,0,0,1.74,5.48l14.19,17.73a91.57,91.57,0,0,1-6.23,15L187,173.11a8,8,0,0,0-5.1,2.64,74.11,74.11,0,0,1-6.14,6.14,8,8,0,0,0-2.64,5.1l-2.51,22.58a91.32,91.32,0,0,1-15,6.23l-17.74-14.19a8,8,0,0,0-5-1.75h-.48a73.93,73.93,0,0,1-8.68,0,8,8,0,0,0-5.48,1.74L100.45,215.8a91.57,91.57,0,0,1-15-6.23L82.89,187a8,8,0,0,0-2.64-5.1,74.11,74.11,0,0,1-6.14-6.14,8,8,0,0,0-5.1-2.64L46.43,170.6a91.32,91.32,0,0,1-6.23-15l14.19-17.74a8,8,0,0,0,1.74-5.48,73.93,73.93,0,0,1,0-8.68,8,8,0,0,0-1.74-5.48L40.2,100.45a91.57,91.57,0,0,1,6.23-15L69,82.89a8,8,0,0,0,5.1-2.64,74.11,74.11,0,0,1,6.14-6.14A8,8,0,0,0,82.89,69L85.4,46.43a91.32,91.32,0,0,1,15-6.23l17.74,14.19a8,8,0,0,0,5.48,1.74,73.93,73.93,0,0,1,8.68,0,8,8,0,0,0,5.48-1.74L155.55,40.2a91.57,91.57,0,0,1,15,6.23L173.11,69a8,8,0,0,0,2.64,5.1,74.11,74.11,0,0,1,6.14,6.14,8,8,0,0,0,5.1,2.64l22.58,2.51a91.32,91.32,0,0,1,6.23,15l-14.19,17.74A8,8,0,0,0,199.87,123.66Z"/>');class Ns extends Event{constructor(t){super("dropdown-item-select",{bubbles:!0,composed:!0}),this.value=t}}class Hs extends Event{constructor(t){super("select",{bubbles:!0,composed:!0}),this.value=t}}var W,z,j,ke,x,He,k,Fs,Ce,Us,Bs,rr,sr,ct,te,le,Fe,Ue,Be,_t,qs,Xs,ir,De,nr,q;const Or=class Or extends HTMLElement{constructor(){super();_(this,k);_(this,W,!1);_(this,z,null);_(this,j,null);_(this,ke);_(this,x,null);_(this,He,new MutationObserver(e=>m(this,k,qs).call(this,e)));_(this,le,()=>{m(this,k,ct).call(this,!f(this,W))});_(this,Fe,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),f(this,le).call(this))});_(this,Ue,e=>{f(this,W)&&(e.composedPath().includes(this)||m(this,k,ct).call(this,!1))});_(this,Be,e=>{e instanceof Ns&&(e.stopPropagation(),I(this,W,!1),m(this,k,Ce).call(this,e.value),m(this,k,q).call(this),this.dispatchEvent(new Hs(e.value)))});_(this,_t,()=>{m(this,k,ir).call(this)});I(this,ke,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("dropdown-item-select",f(this,Be)),document.addEventListener("click",f(this,Ue),!0),m(this,k,Fs).call(this),f(this,He).observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["selected","value","slot"]}),m(this,k,q).call(this)}disconnectedCallback(){this.removeEventListener("dropdown-item-select",f(this,Be)),document.removeEventListener("click",f(this,Ue),!0),f(this,He).disconnect(),m(this,k,nr).call(this)}attributeChangedCallback(){m(this,k,q).call(this)}get title(){return this.getAttribute("title")??""}get value(){return f(this,z)}set value(e){e===null?(m(this,k,te).call(this,null,null),m(this,k,Us).call(this)):m(this,k,Ce).call(this,e),m(this,k,q).call(this)}close(){m(this,k,ct).call(this,!1)}};W=new WeakMap,z=new WeakMap,j=new WeakMap,ke=new WeakMap,x=new WeakMap,He=new WeakMap,k=new WeakSet,Fs=function(){var s;const e=this.querySelector("dropdown-item[selected]");e&&m(this,k,te).call(this,e.value,((s=e.textContent)==null?void 0:s.trim())??null)},Ce=function(e){var s;for(const i of f(this,k,rr))i.value===e?(m(this,k,te).call(this,e,((s=i.textContent)==null?void 0:s.trim())??null),i.hasAttribute("selected")||i.setAttribute("selected","")):i.hasAttribute("selected")&&i.removeAttribute("selected")},Us=function(){const e=this.querySelectorAll("dropdown-item[selected]");for(const s of e)s.removeAttribute("selected")},Bs=function(e){for(const s of f(this,k,rr))if(s.value===e)return s;return null},rr=function(){return this.querySelectorAll("dropdown-item")},sr=function(){return f(this,j)??this.title},ct=function(e){f(this,W)!==e&&(I(this,W,e),m(this,k,q).call(this))},te=function(e,s){I(this,z,e),I(this,j,s)},le=new WeakMap,Fe=new WeakMap,Ue=new WeakMap,Be=new WeakMap,_t=new WeakMap,qs=function(e){e.every(i=>i.target instanceof Element?i.target.closest('[slot="trigger"]')!==null:!1)||m(this,k,Xs).call(this)},Xs=function(){var s,i;const e=this.querySelector("dropdown-item[selected]");if(e){const n=e.value,a=((s=e.textContent)==null?void 0:s.trim())??null,o=f(this,z)!==n||f(this,j)!==a;m(this,k,te).call(this,n,a),m(this,k,Ce).call(this,n),o?m(this,k,q).call(this):m(this,k,De).call(this);return}if(f(this,z)!==null){const n=m(this,k,Bs).call(this,f(this,z));if(n){const a=((i=n.textContent)==null?void 0:i.trim())??null,o=f(this,j)!==a;m(this,k,te).call(this,f(this,z),a),m(this,k,Ce).call(this,f(this,z)),o?m(this,k,q).call(this):m(this,k,De).call(this);return}}if(f(this,z)!==null||f(this,j)!==null){m(this,k,te).call(this,null,null),m(this,k,q).call(this);return}m(this,k,De).call(this)},ir=function(){const e=f(this,ke).querySelector('slot[name="trigger"]'),s=e instanceof HTMLSlotElement?e.assignedElements({flatten:!0})[0]??null:null;f(this,x)!==s&&(m(this,k,nr).call(this),I(this,x,s),f(this,x)&&(f(this,x).addEventListener("click",f(this,le)),f(this,x)instanceof HTMLButtonElement?f(this,x).hasAttribute("type")||(f(this,x).type="button"):(f(this,x).hasAttribute("role")||f(this,x).setAttribute("role","button"),f(this,x).hasAttribute("tabindex")||(f(this,x).tabIndex=0),f(this,x).addEventListener("keydown",f(this,Fe))))),m(this,k,De).call(this)},De=function(){f(this,x)&&(f(this,x).setAttribute("data-dropdown-trigger",""),f(this,x).setAttribute("aria-haspopup","listbox"),f(this,x).setAttribute("aria-expanded",f(this,W)?"true":"false"),D(v`
|
|
27
|
+
<span class="trigger-label" data-dropdown-trigger-label>${f(this,k,sr)}</span>
|
|
28
|
+
<span class="trigger-icon" data-dropdown-trigger-icon aria-hidden="true">
|
|
29
|
+
${er({size:14})}
|
|
30
|
+
</span>
|
|
31
|
+
`,f(this,x)))},nr=function(){f(this,x)&&(f(this,x).removeEventListener("click",f(this,le)),f(this,x).removeEventListener("keydown",f(this,Fe)),f(this,x).removeAttribute("data-dropdown-trigger"),f(this,x).removeAttribute("aria-haspopup"),f(this,x).removeAttribute("aria-expanded"),I(this,x,null))},q=function(){this.toggleAttribute("open",f(this,W)),D(v`
|
|
32
|
+
<slot name="trigger" @slotchange=${f(this,_t)}>
|
|
33
|
+
<button
|
|
34
|
+
class="fallback-trigger"
|
|
35
|
+
part="trigger"
|
|
36
|
+
type="button"
|
|
37
|
+
aria-haspopup="listbox"
|
|
38
|
+
aria-expanded=${f(this,W)?"true":"false"}
|
|
39
|
+
@click=${f(this,le)}
|
|
40
|
+
>
|
|
41
|
+
<span class="trigger-label" part="trigger-label">${f(this,k,sr)}</span>
|
|
42
|
+
<span class="trigger-icon" part="trigger-icon" aria-hidden="true">
|
|
43
|
+
${er({size:14})}
|
|
44
|
+
</span>
|
|
45
|
+
</button>
|
|
46
|
+
</slot>
|
|
47
|
+
${f(this,W)?v`
|
|
48
|
+
<div class="panel" part="panel" role="listbox">
|
|
49
|
+
<slot></slot>
|
|
50
|
+
</div>
|
|
51
|
+
`:null}
|
|
52
|
+
`,f(this,ke)),queueMicrotask(()=>m(this,k,ir).call(this))},Or.observedAttributes=["title"];let tr=Or;class Hn extends HTMLElement{}class Fn extends HTMLElement{}class Un extends HTMLElement{}var pe,or,Gs,qe,Xe;const zr=class zr extends HTMLElement{constructor(){super(...arguments);_(this,pe);_(this,qe,()=>{this.action||m(this,pe,Gs).call(this)});_(this,Xe,e=>{e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.click())})}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","option"),this.hasAttribute("tabindex")||(this.tabIndex=0),this.addEventListener("click",f(this,qe)),this.addEventListener("keydown",f(this,Xe)),m(this,pe,or).call(this)}disconnectedCallback(){this.removeEventListener("click",f(this,qe)),this.removeEventListener("keydown",f(this,Xe))}attributeChangedCallback(){m(this,pe,or).call(this)}get value(){return this.getAttribute("value")??""}get selected(){return this.hasAttribute("selected")}get action(){return this.hasAttribute("action")}};pe=new WeakSet,or=function(){if(this.action){this.setAttribute("role","button"),this.removeAttribute("aria-selected");return}this.setAttribute("role","option"),this.setAttribute("aria-selected",this.selected?"true":"false")},Gs=function(){this.dispatchEvent(new Ns(this.value))},qe=new WeakMap,Xe=new WeakMap,zr.observedAttributes=["action","selected","value"];let ar=zr;customElements.get("dropdown-menu")||customElements.define("dropdown-menu",tr);customElements.get("dropdown-group")||customElements.define("dropdown-group",Hn);customElements.get("dropdown-label")||customElements.define("dropdown-label",Fn);customElements.get("dropdown-divider")||customElements.define("dropdown-divider",Un);customElements.get("dropdown-item")||customElements.define("dropdown-item",ar);class Bn extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}var Ge,Y,cr,At,Ve,hr;const Nr=class Nr extends HTMLElement{constructor(){super();_(this,Y);_(this,Ge);_(this,At,e=>{e.target===e.currentTarget&&m(this,Y,cr).call(this)});_(this,Ve,e=>{this.open&&e.key==="Escape"&&m(this,Y,cr).call(this)});I(this,Ge,this.attachShadow({mode:"open"}))}connectedCallback(){document.addEventListener("keydown",f(this,Ve)),m(this,Y,hr).call(this)}disconnectedCallback(){document.removeEventListener("keydown",f(this,Ve))}attributeChangedCallback(){m(this,Y,hr).call(this)}get open(){return this.hasAttribute("open")}};Ge=new WeakMap,Y=new WeakSet,cr=function(){this.dispatchEvent(new Bn)},At=new WeakMap,Ve=new WeakMap,hr=function(){D(v`
|
|
53
|
+
${this.open?v`
|
|
54
|
+
<div class="backdrop" part="backdrop" @click=${f(this,At)}>
|
|
55
|
+
<slot></slot>
|
|
56
|
+
</div>
|
|
57
|
+
`:null}
|
|
58
|
+
`,f(this,Ge))},Nr.observedAttributes=["open"];let lr=Nr;customElements.get("modal-overlay")||customElements.define("modal-overlay",lr);class Vs extends Event{constructor(){super("close",{bubbles:!0,composed:!0})}}class qn extends HTMLElement{}var Ke,T,Ze,$,ht,ut,Ks,Zs,Re,js,je,dr;const Hr=class Hr extends HTMLElement{constructor(){super();_(this,$);_(this,Ke);_(this,T,[]);_(this,Ze,new MutationObserver(()=>m(this,$,js).call(this)));_(this,je,e=>{const s=e.target;if(!(s instanceof Element))return;const i=s.closest("[data-navigate]");if(i){this.navigate(i.dataset.navigate??"");return}s.closest("[data-back]")&&this.back()});I(this,Ke,this.attachShadow({mode:"open"}))}connectedCallback(){this.addEventListener("click",f(this,je)),f(this,Ze).observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["id","title"]}),m(this,$,Re).call(this)}disconnectedCallback(){this.removeEventListener("click",f(this,je)),f(this,Ze).disconnect(),I(this,T,[])}attributeChangedCallback(){m(this,$,dr).call(this)}get closable(){return this.hasAttribute("closable")}navigate(e){var n;const s=((n=f(this,$,ht))==null?void 0:n.id)??null;e===s||!m(this,$,ut).call(this,e)||(f(this,T).push(e),m(this,$,Re).call(this))}back(){f(this,T).length<=1||(f(this,T).pop(),m(this,$,Re).call(this))}};Ke=new WeakMap,T=new WeakMap,Ze=new WeakMap,$=new WeakSet,ht=function(){const e=f(this,T)[f(this,T).length-1]??null;return e?m(this,$,ut).call(this,e):null},ut=function(e){const s=this.querySelectorAll("panel-page");for(const i of s)if(i.id===e)return i;return null},Ks=function(){if(I(this,T,f(this,T).filter(s=>m(this,$,ut).call(this,s)!==null)),f(this,T).length>0)return;const e=this.querySelector("panel-page");e!=null&&e.id&&I(this,T,[e.id])},Zs=function(){m(this,$,Ks).call(this);const e=f(this,$,ht),s=this.querySelectorAll("panel-page");for(const i of s)i.hidden=i!==e},Re=function(){m(this,$,Zs).call(this),m(this,$,dr).call(this)},js=function(){m(this,$,Re).call(this)},je=new WeakMap,dr=function(){const e=f(this,$,ht);D(v`
|
|
59
|
+
<section class="panel" part="panel">
|
|
60
|
+
<header class="title-bar" part="header">
|
|
61
|
+
<div class="title-group" part="title-group">
|
|
62
|
+
${f(this,T).length>1?v`
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
class="title-button"
|
|
66
|
+
part="button back-button"
|
|
67
|
+
aria-label="Back"
|
|
68
|
+
@click=${()=>this.back()}
|
|
69
|
+
>
|
|
70
|
+
<span class="back-icon" part="icon back-icon">
|
|
71
|
+
${er({size:14})}
|
|
72
|
+
</span>
|
|
73
|
+
</button>
|
|
74
|
+
`:null}
|
|
75
|
+
<h2 class="title" part="title">${(e==null?void 0:e.getAttribute("title"))??""}</h2>
|
|
76
|
+
</div>
|
|
77
|
+
${this.closable?v`
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="title-button"
|
|
81
|
+
part="button close-button"
|
|
82
|
+
aria-label="Close"
|
|
83
|
+
@click=${()=>this.dispatchEvent(new Vs)}
|
|
84
|
+
>
|
|
85
|
+
<span class="close-icon" part="icon close-icon">${zs({size:14})}</span>
|
|
86
|
+
</button>
|
|
87
|
+
`:null}
|
|
88
|
+
</header>
|
|
89
|
+
<slot></slot>
|
|
90
|
+
</section>
|
|
91
|
+
`,f(this,Ke))},Hr.observedAttributes=["closable"];let ur=Hr;customElements.get("panel-view")||customElements.define("panel-view",ur);customElements.get("panel-page")||customElements.define("panel-page",qn);class Qe{constructor(){this.disposables=[]}add(t){return this.disposables.push(t),t}dispose(){for(const t of this.disposables)t.dispose();this.disposables=[]}}function $r(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fe=$r();function Ys(r){fe=r}var ne={exec:()=>null};function y(r,t=""){let e=typeof r=="string"?r:r.source,s={replace:(i,n)=>{let a=typeof n=="string"?n:n.source;return a=a.replace(R.caret,"$1"),e=e.replace(i,a),s},getRegex:()=>new RegExp(e,t)};return s}var Xn=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),R={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:r=>new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}#`),htmlBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:r=>new RegExp(`^ {0,${Math.min(3,r-1)}}>`)},Gn=/^(?:[ \t]*(?:\n|$))+/,Vn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Kn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Je=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Er=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Qs=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Js=y(Qs).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),jn=y(Qs).replace(/bull/g,Er).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Cr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Yn=/^[^\n]+/,Dr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Qn=y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Dr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jn=y(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Er).getRegex(),Rt="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Rr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ea=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Rr).replace("tag",Rt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ei=y(Cr).replace("hr",Je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Rt).getRegex(),ta=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ei).getRegex(),Tr={blockquote:ta,code:Vn,def:Qn,fences:Kn,heading:Zn,hr:Je,html:ea,lheading:Js,list:Jn,newline:Gn,paragraph:ei,table:ne,text:Yn},os=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Rt).getRegex(),ra={...Tr,lheading:jn,table:os,paragraph:y(Cr).replace("hr",Je).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",os).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Rt).getRegex()},sa={...Tr,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Rr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ne,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(Cr).replace("hr",Je).replace("heading",` *#{1,6} *[^
|
|
92
|
+
]`).replace("lheading",Js).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ia=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,na=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ti=/^( {2,}|\\)\n(?!\s*$)/,aa=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Tt=/[\p{P}\p{S}]/u,Pr=/[\s\p{P}\p{S}]/u,ri=/[^\s\p{P}\p{S}]/u,oa=y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pr).getRegex(),si=/(?!~)[\p{P}\p{S}]/u,la=/(?!~)[\s\p{P}\p{S}]/u,ca=/(?:[^\s\p{P}\p{S}]|~)/u,ii=/(?![*_])[\p{P}\p{S}]/u,ha=/(?![*_])[\s\p{P}\p{S}]/u,ua=/(?:[^\s\p{P}\p{S}]|[*_])/u,da=y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Xn?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ni=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,pa=y(ni,"u").replace(/punct/g,Tt).getRegex(),fa=y(ni,"u").replace(/punct/g,si).getRegex(),ai="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ga=y(ai,"gu").replace(/notPunctSpace/g,ri).replace(/punctSpace/g,Pr).replace(/punct/g,Tt).getRegex(),ma=y(ai,"gu").replace(/notPunctSpace/g,ca).replace(/punctSpace/g,la).replace(/punct/g,si).getRegex(),ka=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ri).replace(/punctSpace/g,Pr).replace(/punct/g,Tt).getRegex(),wa=y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ii).getRegex(),ba="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",va=y(ba,"gu").replace(/notPunctSpace/g,ua).replace(/punctSpace/g,ha).replace(/punct/g,ii).getRegex(),ya=y(/\\(punct)/,"gu").replace(/punct/g,Tt).getRegex(),Sa=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xa=y(Rr).replace("(?:-->|$)","-->").getRegex(),_a=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xa).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),vt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Aa=y(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",vt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),oi=y(/^!?\[(label)\]\[(ref)\]/).replace("label",vt).replace("ref",Dr).getRegex(),li=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",Dr).getRegex(),$a=y("reflink|nolink(?!\\()","g").replace("reflink",oi).replace("nolink",li).getRegex(),ls=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ir={_backpedal:ne,anyPunctuation:ya,autolink:Sa,blockSkip:da,br:ti,code:na,del:ne,delLDelim:ne,delRDelim:ne,emStrongLDelim:pa,emStrongRDelimAst:ga,emStrongRDelimUnd:ka,escape:ia,link:Aa,nolink:li,punctuation:oa,reflink:oi,reflinkSearch:$a,tag:_a,text:aa,url:ne},Ea={...Ir,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",vt).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",vt).getRegex()},pr={...Ir,emStrongRDelimAst:ma,emStrongLDelim:fa,delLDelim:wa,delRDelim:va,url:y(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ls).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:y(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ls).getRegex()},Ca={...pr,br:y(ti).replace("{2,}","*").getRegex(),text:y(pr.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},nt={normal:Tr,gfm:ra,pedantic:sa},Ae={normal:Ir,gfm:pr,breaks:Ca,pedantic:Ea},Da={"&":"&","<":"<",">":">",'"':""","'":"'"},cs=r=>Da[r];function U(r,t){if(t){if(R.escapeTest.test(r))return r.replace(R.escapeReplace,cs)}else if(R.escapeTestNoEncode.test(r))return r.replace(R.escapeReplaceNoEncode,cs);return r}function hs(r){try{r=encodeURI(r).replace(R.percentDecode,"%")}catch{return null}return r}function us(r,t){var n;let e=r.replace(R.findPipe,(a,o,l)=>{let c=!1,u=o;for(;--u>=0&&l[u]==="\\";)c=!c;return c?"|":" |"}),s=e.split(R.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!((n=s.at(-1))!=null&&n.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(R.slashPipe,"|");return s}function $e(r,t,e){let s=r.length;if(s===0)return"";let i=0;for(;i<s&&r.charAt(s-i-1)===t;)i++;return r.slice(0,s-i)}function Ra(r,t){if(r.indexOf(t[1])===-1)return-1;let e=0;for(let s=0;s<r.length;s++)if(r[s]==="\\")s++;else if(r[s]===t[0])e++;else if(r[s]===t[1]&&(e--,e<0))return s;return e>0?-2:-1}function Ta(r,t=0){let e=t,s="";for(let i of r)if(i===" "){let n=4-e%4;s+=" ".repeat(n),e+=n}else s+=i,e++;return s}function ds(r,t,e,s,i){let n=t.href,a=t.title||null,o=r[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:r[0].charAt(0)==="!"?"image":"link",raw:e,href:n,title:a,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,l}function Pa(r,t,e){let s=r.match(e.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
|
|
93
|
+
`).map(n=>{let a=n.match(e.other.beginningSpace);if(a===null)return n;let[o]=a;return o.length>=i.length?n.slice(i.length):n}).join(`
|
|
94
|
+
`)}var yt=class{constructor(r){h(this,"options");h(this,"rules");h(this,"lexer");this.options=r||fe}space(r){let t=this.rules.block.newline.exec(r);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(r){let t=this.rules.block.code.exec(r);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:$e(e,`
|
|
95
|
+
`)}}}fences(r){let t=this.rules.block.fences.exec(r);if(t){let e=t[0],s=Pa(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(r){let t=this.rules.block.heading.exec(r);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let s=$e(e,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(e=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(r){let t=this.rules.block.hr.exec(r);if(t)return{type:"hr",raw:$e(t[0],`
|
|
96
|
+
`)}}blockquote(r){let t=this.rules.block.blockquote.exec(r);if(t){let e=$e(t[0],`
|
|
97
|
+
`).split(`
|
|
98
|
+
`),s="",i="",n=[];for(;e.length>0;){let a=!1,o=[],l;for(l=0;l<e.length;l++)if(this.rules.other.blockquoteStart.test(e[l]))o.push(e[l]),a=!0;else if(!a)o.push(e[l]);else break;e=e.slice(l);let c=o.join(`
|
|
99
|
+
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
100
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
101
|
+
${c}`:c,i=i?`${i}
|
|
102
|
+
${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,n,!0),this.lexer.state.top=d,e.length===0)break;let g=n.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let p=g,w=p.raw+`
|
|
103
|
+
`+e.join(`
|
|
104
|
+
`),b=this.blockquote(w);n[n.length-1]=b,s=s.substring(0,s.length-p.raw.length)+b.raw,i=i.substring(0,i.length-p.text.length)+b.text;break}else if((g==null?void 0:g.type)==="list"){let p=g,w=p.raw+`
|
|
105
|
+
`+e.join(`
|
|
106
|
+
`),b=this.list(w);n[n.length-1]=b,s=s.substring(0,s.length-g.raw.length)+b.raw,i=i.substring(0,i.length-p.raw.length)+b.raw,e=w.substring(n.at(-1).raw.length).split(`
|
|
107
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:n,text:i}}}list(r){var e,s;let t=this.rules.block.list.exec(r);if(t){let i=t[1].trim(),n=i.length>1,a={type:"list",raw:"",ordered:n,start:n?+i.slice(0,-1):"",loose:!1,items:[]};i=n?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=n?i:"[*+-]");let o=this.rules.other.listItemRegex(i),l=!1;for(;r;){let u=!1,d="",g="";if(!(t=o.exec(r))||this.rules.block.hr.test(r))break;d=t[0],r=r.substring(d.length);let p=Ta(t[2].split(`
|
|
108
|
+
`,1)[0],t[1].length),w=r.split(`
|
|
109
|
+
`,1)[0],b=!p.trim(),A=0;if(this.options.pedantic?(A=2,g=p.trimStart()):b?A=t[1].length+1:(A=p.search(this.rules.other.nonSpaceChar),A=A>4?1:A,g=p.slice(A),A+=t[1].length),b&&this.rules.other.blankLine.test(w)&&(d+=w+`
|
|
110
|
+
`,r=r.substring(w.length+1),u=!0),!u){let G=this.rules.other.nextBulletRegex(A),Se=this.rules.other.hrRegex(A),E=this.rules.other.fencesBeginRegex(A),V=this.rules.other.headingBeginRegex(A),Mt=this.rules.other.htmlBeginRegex(A),et=this.rules.other.blockquoteBeginRegex(A);for(;r;){let xe=r.split(`
|
|
111
|
+
`,1)[0],Q;if(w=xe,this.options.pedantic?(w=w.replace(this.rules.other.listReplaceNesting," "),Q=w):Q=w.replace(this.rules.other.tabCharGlobal," "),E.test(w)||V.test(w)||Mt.test(w)||et.test(w)||G.test(w)||Se.test(w))break;if(Q.search(this.rules.other.nonSpaceChar)>=A||!w.trim())g+=`
|
|
112
|
+
`+Q.slice(A);else{if(b||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||E.test(p)||V.test(p)||Se.test(p))break;g+=`
|
|
113
|
+
`+w}b=!w.trim(),d+=xe+`
|
|
114
|
+
`,r=r.substring(xe.length+1),p=Q.slice(A)}}a.loose||(l?a.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(l=!0)),a.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(g),loose:!1,text:g,tokens:[]}),a.raw+=d}let c=a.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;a.raw=a.raw.trimEnd();for(let u of a.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){if(u.text=u.text.replace(this.rules.other.listReplaceTask,""),((e=u.tokens[0])==null?void 0:e.type)==="text"||((s=u.tokens[0])==null?void 0:s.type)==="paragraph"){u.tokens[0].raw=u.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),u.tokens[0].text=u.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let g=this.lexer.inlineQueue.length-1;g>=0;g--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[g].src)){this.lexer.inlineQueue[g].src=this.lexer.inlineQueue[g].src.replace(this.rules.other.listReplaceTask,"");break}}let d=this.rules.other.listTaskCheckbox.exec(u.raw);if(d){let g={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};u.checked=g.checked,a.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=g.raw+u.tokens[0].raw,u.tokens[0].text=g.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(g)):u.tokens.unshift({type:"paragraph",raw:g.raw,text:g.raw,tokens:[g]}):u.tokens.unshift(g)}}if(!a.loose){let d=u.tokens.filter(p=>p.type==="space"),g=d.length>0&&d.some(p=>this.rules.other.anyLine.test(p.raw));a.loose=g}}if(a.loose)for(let u of a.items){u.loose=!0;for(let d of u.tokens)d.type==="text"&&(d.type="paragraph")}return a}}html(r){let t=this.rules.block.html.exec(r);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(r){let t=this.rules.block.def.exec(r);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:i}}}table(r){var a;let t=this.rules.block.table.exec(r);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let e=us(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(a=t[3])!=null&&a.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
115
|
+
`):[],n={type:"table",raw:t[0],header:[],align:[],rows:[]};if(e.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?n.align.push("right"):this.rules.other.tableAlignCenter.test(o)?n.align.push("center"):this.rules.other.tableAlignLeft.test(o)?n.align.push("left"):n.align.push(null);for(let o=0;o<e.length;o++)n.header.push({text:e[o],tokens:this.lexer.inline(e[o]),header:!0,align:n.align[o]});for(let o of i)n.rows.push(us(o,n.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:n.align[c]})));return n}}lheading(r){let t=this.rules.block.lheading.exec(r);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(r){let t=this.rules.block.paragraph.exec(r);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
116
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(r){let t=this.rules.block.text.exec(r);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(r){let t=this.rules.inline.escape.exec(r);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(r){let t=this.rules.inline.tag.exec(r);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(r){let t=this.rules.inline.link.exec(r);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let n=$e(e.slice(0,-1),"\\");if((e.length-n.length)%2===0)return}else{let n=Ra(t[2],"()");if(n===-2)return;if(n>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+n;t[2]=t[2].substring(0,n),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let n=this.rules.other.pedanticHrefTitle.exec(s);n&&(s=n[1],i=n[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?s=s.slice(1):s=s.slice(1,-1)),ds(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(r,t){let e;if((e=this.rules.inline.reflink.exec(r))||(e=this.rules.inline.nolink.exec(r))){let s=(e[2]||e[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let n=e[0].charAt(0);return{type:"text",raw:n,text:n}}return ds(e,i,e[0],this.lexer,this.rules)}}emStrong(r,t,e=""){let s=this.rules.inline.emStrongLDelim.exec(r);if(!(!s||s[3]&&e.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!e||this.rules.inline.punctuation.exec(e))){let i=[...s[0]].length-1,n,a,o=i,l=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*r.length+i);(s=c.exec(t))!=null;){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n)continue;if(a=[...n].length,s[3]||s[4]){o+=a;continue}else if((s[5]||s[6])&&i%3&&!((i+a)%3)){l+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+l);let u=[...s[0]][0].length,d=r.slice(0,i+s.index+u+a);if(Math.min(i,a)%2){let p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}let g=d.slice(2,-2);return{type:"strong",raw:d,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(r){let t=this.rules.inline.code.exec(r);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return s&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(r){let t=this.rules.inline.br.exec(r);if(t)return{type:"br",raw:t[0]}}del(r,t,e=""){let s=this.rules.inline.delLDelim.exec(r);if(s&&(!s[1]||!e||this.rules.inline.punctuation.exec(e))){let i=[...s[0]].length-1,n,a,o=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*r.length+i);(s=l.exec(t))!=null;){if(n=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!n||(a=[...n].length,a!==i))continue;if(s[3]||s[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let c=[...s[0]][0].length,u=r.slice(0,i+s.index+c+a),d=u.slice(i,-i);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(r){let t=this.rules.inline.autolink.exec(r);if(t){let e,s;return t[2]==="@"?(e=t[1],s="mailto:"+e):(e=t[1],s=e),{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}url(r){var e;let t;if(t=this.rules.inline.url.exec(r)){let s,i;if(t[2]==="@")s=t[0],i="mailto:"+s;else{let n;do n=t[0],t[0]=((e=this.rules.inline._backpedal.exec(t[0]))==null?void 0:e[0])??"";while(n!==t[0]);s=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(r){let t=this.rules.inline.text.exec(r);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},N=class fr{constructor(t){h(this,"tokens");h(this,"options");h(this,"state");h(this,"inlineQueue");h(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||fe,this.options.tokenizer=this.options.tokenizer||new yt,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let e={other:R,block:nt.normal,inline:Ae.normal};this.options.pedantic?(e.block=nt.pedantic,e.inline=Ae.pedantic):this.options.gfm&&(e.block=nt.gfm,this.options.breaks?e.inline=Ae.breaks:e.inline=Ae.gfm),this.tokenizer.rules=e}static get rules(){return{block:nt,inline:Ae}}static lex(t,e){return new fr(e).lex(t)}static lexInline(t,e){return new fr(e).inlineTokens(t)}lex(t){t=t.replace(R.carriageReturn,`
|
|
117
|
+
`),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let s=this.inlineQueue[e];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],s=!1){var i,n,a;for(this.options.pedantic&&(t=t.replace(R.tabCharGlobal," ").replace(R.spaceLine,""));t;){let o;if((n=(i=this.options.extensions)==null?void 0:i.block)!=null&&n.some(c=>(o=c.call({lexer:this},t,e))?(t=t.substring(o.raw.length),e.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let c=e.at(-1);o.raw.length===1&&c!==void 0?c.raw+=`
|
|
118
|
+
`:e.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let c=e.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
119
|
+
`)?"":`
|
|
120
|
+
`)+o.raw,c.text+=`
|
|
121
|
+
`+o.text,this.inlineQueue.at(-1).src=c.text):e.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let c=e.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
122
|
+
`)?"":`
|
|
123
|
+
`)+o.raw,c.text+=`
|
|
124
|
+
`+o.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},e.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),e.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),e.push(o);continue}let l=t;if((a=this.options.extensions)!=null&&a.startBlock){let c=1/0,u=t.slice(1),d;this.options.extensions.startBlock.forEach(g=>{d=g.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(this.state.top&&(o=this.tokenizer.paragraph(l))){let c=e.at(-1);s&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
125
|
+
`)?"":`
|
|
126
|
+
`)+o.raw,c.text+=`
|
|
127
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):e.push(o),s=l.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let c=e.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
128
|
+
`)?"":`
|
|
129
|
+
`)+o.raw,c.text+=`
|
|
130
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):e.push(o);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,e}inline(t,e=[]){return this.inlineQueue.push({src:t,tokens:e}),e}inlineTokens(t,e=[]){var l,c,u,d,g;let s=t,i=null;if(this.tokens.links){let p=Object.keys(this.tokens.links);if(p.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)p.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let n;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)n=i[2]?i[2].length:0,s=s.slice(0,i.index+n)+"["+"a".repeat(i[0].length-n-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((c=(l=this.options.hooks)==null?void 0:l.emStrongMask)==null?void 0:c.call({lexer:this},s))??s;let a=!1,o="";for(;t;){a||(o=""),a=!1;let p;if((d=(u=this.options.extensions)==null?void 0:u.inline)!=null&&d.some(b=>(p=b.call({lexer:this},t,e))?(t=t.substring(p.raw.length),e.push(p),!0):!1))continue;if(p=this.tokenizer.escape(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.tag(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.link(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(p.raw.length);let b=e.at(-1);p.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=p.raw,b.text+=p.text):e.push(p);continue}if(p=this.tokenizer.emStrong(t,s,o)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.codespan(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.br(t)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.del(t,s,o)){t=t.substring(p.raw.length),e.push(p);continue}if(p=this.tokenizer.autolink(t)){t=t.substring(p.raw.length),e.push(p);continue}if(!this.state.inLink&&(p=this.tokenizer.url(t))){t=t.substring(p.raw.length),e.push(p);continue}let w=t;if((g=this.options.extensions)!=null&&g.startInline){let b=1/0,A=t.slice(1),G;this.options.extensions.startInline.forEach(Se=>{G=Se.call({lexer:this},A),typeof G=="number"&&G>=0&&(b=Math.min(b,G))}),b<1/0&&b>=0&&(w=t.substring(0,b+1))}if(p=this.tokenizer.inlineText(w)){t=t.substring(p.raw.length),p.raw.slice(-1)!=="_"&&(o=p.raw.slice(-1)),a=!0;let b=e.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=p.raw,b.text+=p.text):e.push(p);continue}if(t){let b="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return e}},St=class{constructor(r){h(this,"options");h(this,"parser");this.options=r||fe}space(r){return""}code({text:r,lang:t,escaped:e}){var n;let s=(n=(t||"").match(R.notSpaceStart))==null?void 0:n[0],i=r.replace(R.endingNewline,"")+`
|
|
131
|
+
`;return s?'<pre><code class="language-'+U(s)+'">'+(e?i:U(i,!0))+`</code></pre>
|
|
132
|
+
`:"<pre><code>"+(e?i:U(i,!0))+`</code></pre>
|
|
133
|
+
`}blockquote({tokens:r}){return`<blockquote>
|
|
134
|
+
${this.parser.parse(r)}</blockquote>
|
|
135
|
+
`}html({text:r}){return r}def(r){return""}heading({tokens:r,depth:t}){return`<h${t}>${this.parser.parseInline(r)}</h${t}>
|
|
136
|
+
`}hr(r){return`<hr>
|
|
137
|
+
`}list(r){let t=r.ordered,e=r.start,s="";for(let a=0;a<r.items.length;a++){let o=r.items[a];s+=this.listitem(o)}let i=t?"ol":"ul",n=t&&e!==1?' start="'+e+'"':"";return"<"+i+n+`>
|
|
138
|
+
`+s+"</"+i+`>
|
|
139
|
+
`}listitem(r){return`<li>${this.parser.parse(r.tokens)}</li>
|
|
140
|
+
`}checkbox({checked:r}){return"<input "+(r?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:r}){return`<p>${this.parser.parseInline(r)}</p>
|
|
141
|
+
`}table(r){let t="",e="";for(let i=0;i<r.header.length;i++)e+=this.tablecell(r.header[i]);t+=this.tablerow({text:e});let s="";for(let i=0;i<r.rows.length;i++){let n=r.rows[i];e="";for(let a=0;a<n.length;a++)e+=this.tablecell(n[a]);s+=this.tablerow({text:e})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
142
|
+
<thead>
|
|
143
|
+
`+t+`</thead>
|
|
144
|
+
`+s+`</table>
|
|
145
|
+
`}tablerow({text:r}){return`<tr>
|
|
146
|
+
${r}</tr>
|
|
147
|
+
`}tablecell(r){let t=this.parser.parseInline(r.tokens),e=r.header?"th":"td";return(r.align?`<${e} align="${r.align}">`:`<${e}>`)+t+`</${e}>
|
|
148
|
+
`}strong({tokens:r}){return`<strong>${this.parser.parseInline(r)}</strong>`}em({tokens:r}){return`<em>${this.parser.parseInline(r)}</em>`}codespan({text:r}){return`<code>${U(r,!0)}</code>`}br(r){return"<br>"}del({tokens:r}){return`<del>${this.parser.parseInline(r)}</del>`}link({href:r,title:t,tokens:e}){let s=this.parser.parseInline(e),i=hs(r);if(i===null)return s;r=i;let n='<a href="'+r+'"';return t&&(n+=' title="'+U(t)+'"'),n+=">"+s+"</a>",n}image({href:r,title:t,text:e,tokens:s}){s&&(e=this.parser.parseInline(s,this.parser.textRenderer));let i=hs(r);if(i===null)return U(e);r=i;let n=`<img src="${r}" alt="${U(e)}"`;return t&&(n+=` title="${U(t)}"`),n+=">",n}text(r){return"tokens"in r&&r.tokens?this.parser.parseInline(r.tokens):"escaped"in r&&r.escaped?r.text:U(r.text)}},Lr=class{strong({text:r}){return r}em({text:r}){return r}codespan({text:r}){return r}del({text:r}){return r}html({text:r}){return r}text({text:r}){return r}link({text:r}){return""+r}image({text:r}){return""+r}br(){return""}checkbox({raw:r}){return r}},H=class gr{constructor(t){h(this,"options");h(this,"renderer");h(this,"textRenderer");this.options=t||fe,this.options.renderer=this.options.renderer||new St,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Lr}static parse(t,e){return new gr(e).parse(t)}static parseInline(t,e){return new gr(e).parseInline(t)}parse(t){var s,i;let e="";for(let n=0;n<t.length;n++){let a=t[n];if((i=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&i[a.type]){let l=a,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){e+=c||"";continue}}let o=a;switch(o.type){case"space":{e+=this.renderer.space(o);break}case"hr":{e+=this.renderer.hr(o);break}case"heading":{e+=this.renderer.heading(o);break}case"code":{e+=this.renderer.code(o);break}case"table":{e+=this.renderer.table(o);break}case"blockquote":{e+=this.renderer.blockquote(o);break}case"list":{e+=this.renderer.list(o);break}case"checkbox":{e+=this.renderer.checkbox(o);break}case"html":{e+=this.renderer.html(o);break}case"def":{e+=this.renderer.def(o);break}case"paragraph":{e+=this.renderer.paragraph(o);break}case"text":{e+=this.renderer.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return e}parseInline(t,e=this.renderer){var i,n;let s="";for(let a=0;a<t.length;a++){let o=t[a];if((n=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&n[o.type]){let c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=c||"";continue}}let l=o;switch(l.type){case"escape":{s+=e.text(l);break}case"html":{s+=e.html(l);break}case"link":{s+=e.link(l);break}case"image":{s+=e.image(l);break}case"checkbox":{s+=e.checkbox(l);break}case"strong":{s+=e.strong(l);break}case"em":{s+=e.em(l);break}case"codespan":{s+=e.codespan(l);break}case"br":{s+=e.br(l);break}case"del":{s+=e.del(l);break}case"text":{s+=e.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},ot,Te=(ot=class{constructor(r){h(this,"options");h(this,"block");this.options=r||fe}preprocess(r){return r}postprocess(r){return r}processAllTokens(r){return r}emStrongMask(r){return r}provideLexer(){return this.block?N.lex:N.lexInline}provideParser(){return this.block?H.parse:H.parseInline}},h(ot,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),h(ot,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),ot),Ia=class{constructor(...r){h(this,"defaults",$r());h(this,"options",this.setOptions);h(this,"parse",this.parseMarkdown(!0));h(this,"parseInline",this.parseMarkdown(!1));h(this,"Parser",H);h(this,"Renderer",St);h(this,"TextRenderer",Lr);h(this,"Lexer",N);h(this,"Tokenizer",yt);h(this,"Hooks",Te);this.use(...r)}walkTokens(r,t){var s,i;let e=[];for(let n of r)switch(e=e.concat(t.call(this,n)),n.type){case"table":{let a=n;for(let o of a.header)e=e.concat(this.walkTokens(o.tokens,t));for(let o of a.rows)for(let l of o)e=e.concat(this.walkTokens(l.tokens,t));break}case"list":{let a=n;e=e.concat(this.walkTokens(a.items,t));break}default:{let a=n;(i=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&i[a.type]?this.defaults.extensions.childTokens[a.type].forEach(o=>{let l=a[o].flat(1/0);e=e.concat(this.walkTokens(l,t))}):a.tokens&&(e=e.concat(this.walkTokens(a.tokens,t)))}}return e}use(...r){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return r.forEach(e=>{let s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let n=t.renderers[i.name];n?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===!1&&(o=n.apply(this,a)),o}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let n=t[i.level];n?n.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),e.renderer){let i=this.defaults.renderer||new St(this.defaults);for(let n in e.renderer){if(!(n in i))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let a=n,o=e.renderer[a],l=i[a];i[a]=(...c)=>{let u=o.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}s.renderer=i}if(e.tokenizer){let i=this.defaults.tokenizer||new yt(this.defaults);for(let n in e.tokenizer){if(!(n in i))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let a=n,o=e.tokenizer[a],l=i[a];i[a]=(...c)=>{let u=o.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.tokenizer=i}if(e.hooks){let i=this.defaults.hooks||new Te;for(let n in e.hooks){if(!(n in i))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let a=n,o=e.hooks[a],l=i[a];Te.passThroughHooks.has(n)?i[a]=c=>{if(this.defaults.async&&Te.passThroughHooksRespectAsync.has(n))return(async()=>{let d=await o.call(i,c);return l.call(i,d)})();let u=o.call(i,c);return l.call(i,u)}:i[a]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(i,c);return d===!1&&(d=await l.apply(i,c)),d})();let u=o.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}s.hooks=i}if(e.walkTokens){let i=this.defaults.walkTokens,n=e.walkTokens;s.walkTokens=function(a){let o=[];return o.push(n.call(this,a)),i&&(o=o.concat(i.call(this,a))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(r){return this.defaults={...this.defaults,...r},this}lexer(r,t){return N.lex(r,t??this.defaults)}parser(r,t){return H.parse(r,t??this.defaults)}parseMarkdown(r){return(t,e)=>{let s={...e},i={...this.defaults,...s},n=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return n(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return n(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return n(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=r),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(t):t,o=await(i.hooks?await i.hooks.provideLexer():r?N.lex:N.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(o):o;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser():r?H.parse:H.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(n);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer():r?N.lex:N.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let o=(i.hooks?i.hooks.provideParser():r?H.parse:H.parseInline)(a,i);return i.hooks&&(o=i.hooks.postprocess(o)),o}catch(a){return n(a)}}}onError(r,t){return e=>{if(e.message+=`
|
|
149
|
+
Please report this to https://github.com/markedjs/marked.`,r){let s="<p>An error occurred:</p><pre>"+U(e.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(e);throw e}}},de=new Ia;function S(r,t){return de.parse(r,t)}S.options=S.setOptions=function(r){return de.setOptions(r),S.defaults=de.defaults,Ys(S.defaults),S};S.getDefaults=$r;S.defaults=fe;S.use=function(...r){return de.use(...r),S.defaults=de.defaults,Ys(S.defaults),S};S.walkTokens=function(r,t){return de.walkTokens(r,t)};S.parseInline=de.parseInline;S.Parser=H;S.parser=H.parse;S.Renderer=St;S.TextRenderer=Lr;S.Lexer=N;S.lexer=N.lex;S.Tokenizer=yt;S.Hooks=Te;S.parse=S;S.options;S.setOptions;S.use;S.walkTokens;S.parseInline;H.parse;N.lex;class ci extends Event{constructor(e){super("close-artifact",{bubbles:!0,composed:!0});h(this,"id");this.id=e}}function La(r){return S.parse(r,{async:!1})}class Ma extends HTMLElement{constructor(){super(...arguments);h(this,"_artifact",null)}set artifact(e){this._artifact=e,this.render()}get artifact(){return this._artifact}handleClose(){this._artifact&&this.dispatchEvent(new ci(this._artifact.id))}template(){const e=this._artifact;return v`
|
|
150
|
+
<header class="artifact-title-bar" drag-handle>
|
|
151
|
+
<span class="artifact-title">${e.title}</span>
|
|
152
|
+
<button
|
|
153
|
+
class="artifact-close-btn"
|
|
154
|
+
@click=${()=>this.handleClose()}
|
|
155
|
+
aria-label="Close"
|
|
156
|
+
>${zs({size:14})}</button>
|
|
157
|
+
</header>
|
|
158
|
+
<div class="artifact-content">
|
|
159
|
+
${this.renderContent(e)}
|
|
160
|
+
</div>
|
|
161
|
+
`}renderContent(e){switch(e.type){case"markdown":return v`<div class="markdown-body">${Ln(La(e.content))}</div>`;default:return v`<pre>${e.content}</pre>`}}render(){this._artifact&&D(this.template(),this)}}customElements.define("artifact-view",Ma);const ps=1/3;function Wa(r,t,e,s,i){if(e.length===0)return{index:0};for(let n=0;n<e.length;n+=1){const a=e[n],o=a.right-a.left,l=n<i?a.right-o*ps:a.left+o*ps;if(r<l)return{index:n}}return{index:e.length}}const xt=6,hi=2,fs=hi,Oa=hi,za=xt;function Na(r,t,e){var s;if(e.cols>t||e.rows>xt)return null;for(let i=0;i<=xt-e.rows;i+=1)for(let n=0;n<=t-e.cols;n+=1){let a=!0;for(let o=i;o<i+e.rows&&a;o+=1)for(let l=n;l<n+e.cols;l+=1)if((s=r[o])!=null&&s[l]){a=!1;break}if(a)return{x:n,y:i}}return null}function Ha(r,t){for(let e=t.y;e<t.y+t.rows;e+=1)for(let s=t.x;s<t.x+t.cols;s+=1)r[e][s]=!0}function at(r,t){const e=Array.from({length:xt},()=>Array.from({length:t},()=>!1)),s=[];for(const i of r){const n=Na(e,t,i);if(!n)return null;const a={cardIndex:i.cardIndex,x:n.x,y:n.y,cols:i.cols,rows:i.rows};Ha(e,a),s.push(a)}return s}function Pt(r){const t=r.map((l,c)=>({cardIndex:c,cols:we(l.cols),rows:ft(l.rows)})),e=[];let s=null;for(const l of t){if(!s){const b=l.cols,A=at([l],b);if(!A)continue;s={width:b,cardIndexes:[l.cardIndex],localPlacements:A};continue}const u=[...s.cardIndexes.map(b=>t[b]),l];let d=at(u,s.width),g=s.width;if(!d&&s.width<fs&&l.cols>s.width&&(g=fs,d=at(u,g)),d){s={width:g,cardIndexes:u.map(b=>b.cardIndex),localPlacements:d};continue}e.push(s);const p=l.cols,w=at([l],p);w&&(s={width:p,cardIndexes:[l.cardIndex],localPlacements:w})}s&&e.push(s);const i=Array.from({length:r.length},(l,c)=>{var u,d;return{cardIndex:c,bandIndex:0,x:0,y:0,cols:we(((u=r[c])==null?void 0:u.cols)??Oa),rows:ft(((d=r[c])==null?void 0:d.rows)??za)}}),n=Array.from({length:r.length},()=>0),a=[];let o=0;for(let l=0;l<e.length;l+=1){const c=e[l];a.push({index:l,startCol:o,width:c.width,cardIndexes:[...c.cardIndexes]});for(const u of c.localPlacements){const d=o+u.x;i[u.cardIndex]={cardIndex:u.cardIndex,bandIndex:l,x:d,y:u.y,cols:u.cols,rows:u.rows},n[u.cardIndex]=d}o+=c.width}return{placements:i,bands:a,totalColumns:o,cardStartColumns:n}}const re=600,se=800,B=16,Fa=800,gs=.85,Ua=.8,Ba=200,qa=500,Xa=5,ms=50,Ga=2,Va=120,Ka=80,Za=60,P=1e-4,ja=1e3;function dt(r,t,e,s){const i=we(r),n=ft(t),a=e<Fa,o=a?e*gs:re,l=a?s*gs:se,c=s*Ua,u=Math.min(l,c);return{cols:i,rows:n,width:o*(i/L),height:u*(n/X)}}function It(r,t){return dt(1,X,r,t).width}function ks(r,t){const e=It(r,t);return Math.max(1,Math.floor((r+B)/(e+B)))}function ws(r,t){return r.length===0||!r.every(s=>we(s.cols)===L)||t<L?t:Math.max(L,Math.floor(t/L)*L)}function Ya(r){return Pt(r).totalColumns}function Qa(r,t){return Math.max(0,Ya(r)-t)}function Lt(r){const t=Pt(r);return[...new Set([0,...t.cardStartColumns,t.totalColumns])].sort((s,i)=>s-i)}function bs(r,t){return t.some(e=>Math.abs(e-r)<P)}function vs(r,t){const e=Lt(r);for(const s of e)if(s>t+P)return s;return e[e.length-1]??0}function Ja(r,t){const e=Lt(r);let s=e[0]??0;for(const i of e){if(i<=t+P){s=i;continue}break}return s}function eo(r,t){const e=Lt(r);let s=e[0]??0;for(const i of e){if(i<t-P){s=i;continue}break}return s}function ys(r,t,e,s,i="start"){const n=r.totalColumns;if(n<=0)return 0;const a=It(e,s),o=u=>u<=0?0:u*a+Math.max(0,u-1)*B,l=Math.min(Math.max(0,t),n);let c=0;for(let u=0;u<r.bands.length;u+=1){const d=r.bands[u],g=d.startCol,p=d.startCol+d.width;if(l<p-P){const w=Math.max(0,l-g);return c+o(w)}if(Math.abs(l-p)<=P){const w=c+o(d.width);return u===r.bands.length-1?w:i==="start"?w+B:w}c+=o(d.width),u<r.bands.length-1&&(c+=B)}return l<=P?0:Math.abs(l-n)<=P?r.bands[r.bands.length-1]?c:0:c}function to(r,t,e,s,i){const n=Pt(r),a=n.totalColumns,o=Math.max(0,a-i),l=Math.min(Math.max(0,t),o),c=It(e,s),u=l,d=Math.min(l+i,a),g=new Map;let p=0;for(let E=0;E<n.bands.length;E+=1){const V=n.bands[E];g.set(V.index,p),p+=V.width*c+Math.max(0,V.width-1)*B,E<n.bands.length-1&&(p+=B)}const w=n.bands.map(E=>{const V=E.startCol,Mt=E.startCol+E.width,et=g.get(E.index)??0,xe=E.width*c+Math.max(0,E.width-1)*B,Q=et+xe;return{start:V,end:Mt,left:et,right:Q}}).filter(E=>E.start>=u-P&&E.end<=d+P),b=w.length>0?Math.min(...w.map(E=>E.left)):ys(n,u,e,s,"start"),A=w.length>0?Math.max(...w.map(E=>E.right)):ys(n,d,e,s,"end"),G=Math.max(0,A-b);return(e-G)/Ga-b}class ro extends Event{constructor(e){super("scroll",{bubbles:!0,composed:!0});h(this,"scrollPosition");this.scrollPosition=e}}class so extends Event{constructor(e){super("card-order-changed",{bubbles:!0,composed:!0});h(this,"ids");this.ids=e}}class ui extends Event{constructor(e){super("card-layout-resize-requested",{bubbles:!0,composed:!0});h(this,"id");this.id=e}}const Ss="[drag-handle]";class io extends HTMLElement{constructor(){super(...arguments);h(this,"_cards",[]);h(this,"_dragHandleSelector",Ss);h(this,"_scrollPosition",0);h(this,"_trackEl",null);h(this,"resizeObserver",null);h(this,"renderPending",!1);h(this,"animateNextRender",!0);h(this,"awaitingFreshWheelGesture",!1);h(this,"lastWheelEventAt",Number.NEGATIVE_INFINITY);h(this,"lastWheelDeltaX",0);h(this,"dragStatus","idle");h(this,"dragPointerID",null);h(this,"dragCardID",null);h(this,"dragCardIndex",-1);h(this,"dragStartX",0);h(this,"dragStartY",0);h(this,"dragPointerX",0);h(this,"dragPointerY",0);h(this,"dragOffsetX",0);h(this,"dragOffsetY",0);h(this,"dragPlaceholderIndex",0);h(this,"dragHoldTimer",null);h(this,"capturedDragTarget",null);h(this,"autoScrollFrame",null);h(this,"autoScrollDirection",0);h(this,"autoScrollLastFrameAt",null);h(this,"handlePointerMove",e=>{if(e.pointerId===this.dragPointerID){if(this.dragPointerX=e.clientX,this.dragPointerY=e.clientY,this.dragStatus==="pending"){this.getDragDistance()>Xa&&this.startDragging();return}this.dragStatus==="dragging"&&(e.preventDefault(),this.updateDropTargetFromDOM(),this.updateAutoScrollDirection(),this.scheduleRender())}});h(this,"handlePointerUp",e=>{if(e.pointerId===this.dragPointerID){if(this.dragStatus==="dragging"){e.preventDefault(),this.finishDragging();return}this.dragStatus==="pending"&&this.dragCardID!==null&&this.emitCardLayoutResizeRequested(this.dragCardID),this.resetDragState()}});h(this,"handlePointerCancel",e=>{e.pointerId===this.dragPointerID&&this.cancelDragging()});h(this,"stepAutoScroll",e=>{if(this.dragStatus!=="dragging"||this.autoScrollDirection===0){this.stopAutoScroll();return}const s=this.autoScrollLastFrameAt??e,i=e-s;this.autoScrollLastFrameAt=e;const n=Za*i*this.autoScrollDirection/ja/this.getColumnStep(),a=this.clampScrollPosition(this._scrollPosition+n);Math.abs(a-this._scrollPosition)>=P&&(this._scrollPosition=a,this.emitScrollPositionChanged(this._scrollPosition),this.animateNextRender=!1,this.scheduleRender(),queueMicrotask(()=>this.updateDropTargetFromDOM())),this.autoScrollFrame=requestAnimationFrame(this.stepAutoScroll)});h(this,"handleKeyDown",e=>{if(e.key==="Escape"&&this.dragStatus!=="idle"){e.preventDefault(),this.cancelDragging();return}(e.key==="ArrowRight"||e.key==="ArrowLeft")&&(this.awaitingFreshWheelGesture=!0,this.lastWheelEventAt=Date.now()),e.key==="ArrowRight"?(e.preventDefault(),this.shiftWindow(1)):e.key==="ArrowLeft"&&(e.preventDefault(),this.shiftWindow(-1))});h(this,"handleWindowKeyDown",e=>{document.activeElement!==this&&(e.defaultPrevented||e.key!=="ArrowLeft"&&e.key!=="ArrowRight"&&e.key!=="Escape"||e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLElement&&e.target.isContentEditable||this.matches(":hover")&&(this.focus({preventScroll:!0}),this.handleKeyDown(e)))});h(this,"handleWheel",e=>{document.activeElement!==this&&this.focus({preventScroll:!0});const s=e.shiftKey&&e.deltaY!==0?e.deltaY:e.deltaX;if(s===0)return;e.preventDefault();const i=Date.now(),n=i-this.lastWheelEventAt,a=this.lastWheelDeltaX,o=Math.sign(a),l=Math.sign(s),c=o!==0&&l!==0&&o!==l,u=o!==0&&Math.abs(s)>=Math.abs(a)+Ka;if(this.lastWheelEventAt=i,this.lastWheelDeltaX=s,this.awaitingFreshWheelGesture){if(n<Va&&!c&&!u)return;this.awaitingFreshWheelGesture=!1}this._scrollPosition=this.clampScrollPosition(this._scrollPosition+s/this.getColumnStep()),this.emitScrollPositionChanged(this._scrollPosition),this.animateNextRender=!1,this.scheduleRender()})}set cards(e){this._cards=e.filter(s=>s.type==="content"),this._scrollPosition=this.clampScrollPosition(this._scrollPosition),this.scheduleRender()}get cards(){return this._cards}set dragHandleSelector(e){this._dragHandleSelector=e.trim()||Ss,this.scheduleRender()}get dragHandleSelector(){return this._dragHandleSelector}set scrollPosition(e){const s=this.clampScrollPosition(e);Math.abs(s-this._scrollPosition)<P||(this._scrollPosition=s,this.animateNextRender=!1,this.scheduleRender())}get scrollPosition(){return this._scrollPosition}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.focus(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("wheel",this.handleWheel,{passive:!1}),this.addEventListener("pointermove",this.handlePointerMove),this.addEventListener("pointerup",this.handlePointerUp),this.addEventListener("pointercancel",this.handlePointerCancel),window.addEventListener("keydown",this.handleWindowKeyDown),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.renderView()),this.resizeObserver.observe(this)),this.renderView()}disconnectedCallback(){var e;this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("wheel",this.handleWheel),this.removeEventListener("pointermove",this.handlePointerMove),this.removeEventListener("pointerup",this.handlePointerUp),this.removeEventListener("pointercancel",this.handlePointerCancel),window.removeEventListener("keydown",this.handleWindowKeyDown),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=null,this._trackEl=null,this.clearDragHoldTimer(),this.stopAutoScroll()}scheduleRender(){this.renderPending||(this.renderPending=!0,queueMicrotask(()=>{this.renderPending=!1,this.renderView()}))}contentCards(){return this._cards.filter(e=>e.type==="content")}getColumnStep(){const e=this.clientWidth>0?this.clientWidth:re,s=this.clientHeight>0?this.clientHeight:se;return It(e,s)+B}clampScrollPosition(e){const s=this.clientWidth>0?this.clientWidth:re,i=this.clientHeight>0?this.clientHeight:se,n=ws(this.contentCards(),ks(s,i)),a=Qa(this.contentCards(),n);return Math.min(a,Math.max(0,e))}emitScrollPositionChanged(e){this.dispatchEvent(new ro(e))}emitCardOrderChanged(e){this.dispatchEvent(new so(e))}emitCardLayoutResizeRequested(e){this.dispatchEvent(new ui(e))}shiftWindow(e){const s=this.contentCards();if(s.length===0)return;const i=Lt(s);let n=this._scrollPosition;e===1?(bs(n,i)||(n=vs(s,n)),n=vs(s,n+P)):bs(n,i)?n=eo(s,n):n=Ja(s,n),n=this.clampScrollPosition(n),!(Math.abs(n-this._scrollPosition)<P)&&(this._scrollPosition=n,this.emitScrollPositionChanged(this._scrollPosition),this.animateNextRender=!0,this.scheduleRender())}getRestoreScrollPositionForCard(e){const s=this.contentCards();if(s.length===0||e<0)return this._scrollPosition;let i=0;for(let n=0;n<e&&n<s.length;n+=1)i+=we(s[n].cols);return this.clampScrollPosition(i)}pointerTargetMatchesDragHandle(e){if(!(e instanceof Element))return!1;const s=e.getRootNode();if(!(s instanceof ShadowRoot)&&!(s instanceof Document))return!1;try{return e.closest(this._dragHandleSelector)!==null}catch{return!1}}handleCardPointerDown(e,s){if(e.pointerType==="touch")return;const i=e.target;if(!(i instanceof Element)||i.closest(".artifact-close-btn")||!this.pointerTargetMatchesDragHandle(i))return;const n=e.currentTarget;if(!(n instanceof HTMLElement))return;const a=this.contentCards().findIndex(l=>l.id===s);if(a===-1)return;const o=n.getBoundingClientRect();this.clearDragHoldTimer(),this.stopAutoScroll(),this.dragStatus="pending",this.dragPointerID=e.pointerId,this.dragCardID=s,this.dragCardIndex=a,this.dragStartX=e.clientX,this.dragStartY=e.clientY,this.dragPointerX=e.clientX,this.dragPointerY=e.clientY,this.dragOffsetX=e.clientX-o.left,this.dragOffsetY=e.clientY-o.top,this.dragPlaceholderIndex=a,this.capturedDragTarget=n,n.setPointerCapture(e.pointerId),this.dragHoldTimer=setTimeout(()=>{this.startDragging()},qa)}getDragDistance(){return Math.hypot(this.dragPointerX-this.dragStartX,this.dragPointerY-this.dragStartY)}startDragging(){this.dragStatus!=="pending"||this.dragCardID===null||(this.clearDragHoldTimer(),this.dragStatus="dragging",this.updateAutoScrollDirection(),this.scheduleRender())}finishDragging(){if(this.dragStatus!=="dragging"||this.dragCardID===null){this.resetDragState();return}const e=this.contentCards(),s=[...e],[i]=s.splice(this.dragCardIndex,1);i&&s.splice(this.dragPlaceholderIndex,0,i);const n=s.map(o=>o.id),a=n.some((o,l)=>{var c;return o!==((c=e[l])==null?void 0:c.id)});this.resetDragState(),a&&this.emitCardOrderChanged(n),this.scheduleRender()}cancelDragging(){this.resetDragState(),this.scheduleRender()}resetDragState(){this.clearDragHoldTimer(),this.stopAutoScroll(),this.capturedDragTarget&&this.dragPointerID!==null&&this.capturedDragTarget.hasPointerCapture(this.dragPointerID)&&this.capturedDragTarget.releasePointerCapture(this.dragPointerID),this.dragStatus="idle",this.dragPointerID=null,this.dragCardID=null,this.dragCardIndex=-1,this.dragPlaceholderIndex=0,this.capturedDragTarget=null}clearDragHoldTimer(){this.dragHoldTimer!==null&&(clearTimeout(this.dragHoldTimer),this.dragHoldTimer=null)}updateDropTargetFromDOM(){if(this.dragStatus!=="dragging"||this.dragCardID===null)return;const e=this.contentCards().find(n=>n.id===this.dragCardID);e&&dt(e.cols,e.rows,this.clientWidth||re,this.clientHeight||se);const s=[...this.querySelectorAll(".track .card-slot[data-layout-card-id]")].filter(n=>n instanceof HTMLElement&&n.getAttribute("data-layout-card-id")!==this.dragCardID).map(n=>{const a=n.getBoundingClientRect();return{left:a.left,right:a.right,top:a.top,bottom:a.bottom}}),{index:i}=Wa(this.dragPointerX,this.dragPointerY,s,{},this.dragPlaceholderIndex);i!==this.dragPlaceholderIndex&&(this.dragPlaceholderIndex=i,this.scheduleRender())}updateAutoScrollDirection(){if(this.dragStatus!=="dragging"){this.stopAutoScroll();return}let e=0;if(this.dragPointerX<=ms?e=-1:window.innerWidth-this.dragPointerX<=ms&&(e=1),e===0){this.stopAutoScroll();return}this.autoScrollFrame!==null&&this.autoScrollDirection===e||(this.stopAutoScroll(),this.autoScrollDirection=e,this.autoScrollLastFrameAt=null,this.autoScrollFrame=requestAnimationFrame(this.stepAutoScroll))}stopAutoScroll(){this.autoScrollFrame!==null&&(cancelAnimationFrame(this.autoScrollFrame),this.autoScrollFrame=null),this.autoScrollDirection=0,this.autoScrollLastFrameAt=null}getRenderableCards(){const e=this.contentCards();if(this.dragStatus!=="dragging"||this.dragCardID===null)return e.map(l=>({type:"content",card:l}));const s=e.find(l=>l.id===this.dragCardID),i=(s==null?void 0:s.cols)??L,n=(s==null?void 0:s.rows)??X,o=e.filter(l=>l.id!==this.dragCardID).map(l=>({type:"content",card:l}));return o.splice(this.dragPlaceholderIndex,0,{type:"placeholder",cols:i,rows:n}),o}getDraggedCard(){return this.dragCardID===null?null:this.contentCards().find(e=>e.id===this.dragCardID)??null}getBaseLayoutDimensions(){const e=this.clientWidth>0?this.clientWidth:re,s=this.clientHeight>0?this.clientHeight:se,i=dt(L,X,e,s);return{cardWidth:i.width,cardHeight:i.height,colWidth:i.width/L,rowHeight:i.height/X}}calculateTranslateX(){const e=this.contentCards(),s=this.clientWidth>0?this.clientWidth:re,i=this.clientHeight>0?this.clientHeight:se,n=ws(e,ks(s,i));return to(e,this._scrollPosition,s,i,n)}template(){const e=this.clientWidth>0?this.clientWidth:re,s=this.clientHeight>0?this.clientHeight:se,i=this.getRenderableCards(),n=this.getDraggedCard(),a=Pt(i.map(l=>l.type==="content"?{cols:l.card.cols,rows:l.card.rows}:{cols:l.cols,rows:l.rows})),o=new Map;for(let l=0;l<i.length;l+=1){const c=i[l],u=a.placements[l];if(!u)continue;const d=o.get(u.bandIndex)??[];d.push({item:c,placement:u}),o.set(u.bandIndex,d)}return v`
|
|
162
|
+
<div class="track">
|
|
163
|
+
${a.bands.map(l=>{const c=o.get(l.index)??[];return v`
|
|
164
|
+
<div class="band" layout-band=${String(l.index)} layout-band-cols=${String(l.width)}>
|
|
165
|
+
${c.map(({item:u,placement:d})=>{const g=`grid-column: ${d.x-l.startCol+1} / span ${d.cols}; grid-row: ${d.y+1} / span ${d.rows};`;if(u.type==="placeholder")return v`
|
|
166
|
+
<div
|
|
167
|
+
class="card-slot placeholder"
|
|
168
|
+
layout-cols=${String(u.cols)}
|
|
169
|
+
layout-rows=${String(u.rows)}
|
|
170
|
+
layout-band=${String(d.bandIndex)}
|
|
171
|
+
style=${g}
|
|
172
|
+
></div>
|
|
173
|
+
`;const{card:p}=u;return v`
|
|
174
|
+
<div
|
|
175
|
+
class="card-slot"
|
|
176
|
+
data-layout-card-id=${p.id}
|
|
177
|
+
layout-cols=${String(p.cols)}
|
|
178
|
+
layout-rows=${String(p.rows)}
|
|
179
|
+
layout-band=${String(d.bandIndex)}
|
|
180
|
+
style=${g}
|
|
181
|
+
@pointerdown=${w=>this.handleCardPointerDown(w,p.id)}
|
|
182
|
+
>
|
|
183
|
+
${p.render()}
|
|
184
|
+
</div>
|
|
185
|
+
`})}
|
|
186
|
+
</div>
|
|
187
|
+
`})}
|
|
188
|
+
</div>
|
|
189
|
+
${this.dragStatus==="dragging"&&n?(()=>{const l=dt(n.cols,n.rows,e,s);return v`
|
|
190
|
+
<div
|
|
191
|
+
class="card-slot dragging"
|
|
192
|
+
data-layout-card-id=${n.id}
|
|
193
|
+
layout-cols=${String(l.cols)}
|
|
194
|
+
layout-rows=${String(l.rows)}
|
|
195
|
+
style="
|
|
196
|
+
width: ${l.width}px;
|
|
197
|
+
height: ${l.height}px;
|
|
198
|
+
left: ${this.dragPointerX-this.dragOffsetX}px;
|
|
199
|
+
top: ${this.dragPointerY-this.dragOffsetY}px;
|
|
200
|
+
"
|
|
201
|
+
>
|
|
202
|
+
${n.render()}
|
|
203
|
+
</div>
|
|
204
|
+
`})():null}
|
|
205
|
+
`}updateTrackPosition(e){if(!this._trackEl)return;this._trackEl.style.transition=e?`transform ${Ba}ms ease`:"none";const s=this.calculateTranslateX();this._trackEl.style.transform=`translateX(${s}px)`}renderView(){const e=this.animateNextRender;this.animateNextRender=!0,this._scrollPosition=this.clampScrollPosition(this._scrollPosition);const s=this.getBaseLayoutDimensions();this.style.setProperty("--layout-col-width",`${s.colWidth}px`),this.style.setProperty("--layout-row-height",`${s.rowHeight}px`),this.style.setProperty("--layout-gap",`${B}px`),D(this.template(),this),this._trackEl||(this._trackEl=this.querySelector(".track")),this.updateTrackPosition(e)}}customElements.define("layout-stream",io);class no extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",O.resolve("WorkspaceService"));h(this,"subscriptions",new Qe);h(this,"handleCloseArtifact",e=>{e instanceof ci&&this.workspaceService.removeArtifact(e.id)});h(this,"handleResizeArtifactLayout",e=>{e instanceof ui&&this.workspaceService.cycleArtifactLayout(e.id)});h(this,"handleScrollPositionChanged",e=>{const s=e;typeof s.scrollPosition=="number"&&Number.isFinite(s.scrollPosition)&&this.workspaceService.setScrollPosition(s.scrollPosition)});h(this,"handleCardOrderChanged",e=>{const s=e;Array.isArray(s.ids)&&s.ids.length>0&&this.workspaceService.reorderLayout(s.ids)})}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}buildLayoutCards(){const e=this.workspaceService.activeWorkspace;if(!e)return[];const s=new Map(this.workspaceService.activeArtifacts.map(i=>[i.id,i]));return e.layout.map(i=>{const n=s.get(i.artifactID);return n?{id:i.artifactID,cols:i.cols,rows:i.rows,type:"content",render:()=>v`<artifact-view .artifact=${n}></artifact-view>`}:null}).filter(i=>i!==null)}render(){const e=this.buildLayoutCards();if(e.length===0){D(v`<p data-testid="empty-workspace">No artifacts yet.</p>`,this);return}D(v`
|
|
206
|
+
<layout-stream
|
|
207
|
+
.cards=${e}
|
|
208
|
+
.scrollPosition=${this.workspaceService.scrollPosition}
|
|
209
|
+
@scroll=${this.handleScrollPositionChanged}
|
|
210
|
+
@card-order-changed=${this.handleCardOrderChanged}
|
|
211
|
+
@close-artifact=${this.handleCloseArtifact}
|
|
212
|
+
@card-layout-resize-requested=${this.handleResizeArtifactLayout}
|
|
213
|
+
></layout-stream>
|
|
214
|
+
`,this)}}customElements.define("workspace-view",no);class ao extends Event{constructor(){super("edit-workspace",{bubbles:!0,composed:!0})}}class di extends Event{constructor(e){super("create-workspace",{bubbles:!0,composed:!0});h(this,"serverURL");this.serverURL=e}}class oo extends Event{constructor(){super("delete-workspace",{bubbles:!0,composed:!0})}}class lo extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",O.resolve("WorkspaceService"));h(this,"serverManager",O.has("ServerManager")?O.resolve("ServerManager"):null);h(this,"subscriptions",new Qe)}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render())),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}handleSelect(e){e instanceof Hs&&this.workspaceService.setActiveWorkspace(e.value)}closeDropdown(){var e;(e=this.querySelector("dropdown-menu"))==null||e.close()}handleEditWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new ao))}handleCreateWorkspace(e){this.closeDropdown(),this.dispatchEvent(new di(e))}handleDeleteWorkspace(){this.workspaceService.activeWorkspace&&(this.closeDropdown(),this.dispatchEvent(new oo))}render(){var a;const e=((a=this.workspaceService.activeWorkspace)==null?void 0:a.name)??"No workspaces",s=this.serverManager?this.serverManager.serverRecords.map(o=>({...o,sortedWorkspaces:[...o.workspaces.values()].sort((l,c)=>l.name.localeCompare(c.name,void 0,{sensitivity:"base"}))})):[],i=this.serverManager?[]:[...this.workspaceService.workspaces??[]].sort((o,l)=>o.name.localeCompare(l.name,void 0,{sensitivity:"base"})),n=this.workspaceService.activeWorkspaceServerURL;D(v`
|
|
215
|
+
<dropdown-menu
|
|
216
|
+
title=${e}
|
|
217
|
+
@select=${o=>this.handleSelect(o)}
|
|
218
|
+
>
|
|
219
|
+
<button
|
|
220
|
+
slot="trigger"
|
|
221
|
+
trigger
|
|
222
|
+
type="button"
|
|
223
|
+
aria-label="Choose workspace"
|
|
224
|
+
></button>
|
|
225
|
+
${this.serverManager?s.map(o=>v`
|
|
226
|
+
<dropdown-group>
|
|
227
|
+
<dropdown-label>${o.name}</dropdown-label>
|
|
228
|
+
${o.sortedWorkspaces.map(l=>this.renderWorkspaceItem(l))}
|
|
229
|
+
<dropdown-item action @click=${()=>this.handleCreateWorkspace(o.url)}>
|
|
230
|
+
+ New workspace
|
|
231
|
+
</dropdown-item>
|
|
232
|
+
</dropdown-group>
|
|
233
|
+
`):v`
|
|
234
|
+
<dropdown-group>
|
|
235
|
+
${i.map(o=>this.renderWorkspaceItem(o))}
|
|
236
|
+
${n?v`
|
|
237
|
+
<dropdown-item action @click=${()=>this.handleCreateWorkspace(n)}>
|
|
238
|
+
+ New workspace
|
|
239
|
+
</dropdown-item>
|
|
240
|
+
`:null}
|
|
241
|
+
</dropdown-group>
|
|
242
|
+
`}
|
|
243
|
+
${this.workspaceService.activeWorkspace?v`
|
|
244
|
+
<dropdown-divider></dropdown-divider>
|
|
245
|
+
<dropdown-group>
|
|
246
|
+
<dropdown-item action @click=${()=>this.handleEditWorkspace()}>
|
|
247
|
+
Edit workspace...
|
|
248
|
+
</dropdown-item>
|
|
249
|
+
<dropdown-item action danger @click=${()=>this.handleDeleteWorkspace()}>
|
|
250
|
+
Delete workspace...
|
|
251
|
+
</dropdown-item>
|
|
252
|
+
</dropdown-group>
|
|
253
|
+
`:null}
|
|
254
|
+
</dropdown-menu>
|
|
255
|
+
`,this)}renderWorkspaceItem(e){var i;const s=e.id===this.workspaceService.activeWorkspaceID?((i=this.workspaceService.activeWorkspace)==null?void 0:i.name)??e.name:e.name;return v`
|
|
256
|
+
<dropdown-item
|
|
257
|
+
value=${e.id}
|
|
258
|
+
?selected=${e.id===this.workspaceService.activeWorkspaceID}
|
|
259
|
+
>
|
|
260
|
+
${s}
|
|
261
|
+
</dropdown-item>
|
|
262
|
+
`}}customElements.define("workspace-picker",lo);class pi extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",O.resolve("WorkspaceService"));h(this,"subscriptions",new Qe);h(this,"_mode","edit");h(this,"_targetServerURL");h(this,"createPending",!1)}get open(){return this.hasAttribute("open")}set mode(e){this._mode=e,this.render()}get mode(){return this._mode}set targetServerURL(e){this._targetServerURL=e,this.render()}get targetServerURL(){return this._targetServerURL}attributeChangedCallback(e){e==="open"&&(this.open||(this.createPending=!1),this.render())}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleSubmit(e){e.preventDefault();const s=e.currentTarget,i=new FormData(s),n=String(i.get("name")??"").trim();if(n){if(this._mode==="edit"){this.workspaceService.renameWorkspace(n),this.emitClose();return}if(this._targetServerURL){this.createPending=!0,this.render();try{await this.workspaceService.createWorkspace(this._targetServerURL,n),this.emitClose()}catch{this.createPending=!1,this.render()}}}}render(){var n;const e=this._mode==="edit"?"Edit workspace":"New workspace",s=this._mode==="edit"?"Save":this.createPending?"Creating...":"Create",i=this._mode==="edit"?((n=this.workspaceService.activeWorkspace)==null?void 0:n.name)??"":"";D(v`
|
|
263
|
+
<modal-overlay ?open=${this.open}>
|
|
264
|
+
<section class="workspace-modal">
|
|
265
|
+
<form class="workspace-form" @submit=${a=>void this.handleSubmit(a)}>
|
|
266
|
+
<h2 class="workspace-modal-title">${e}</h2>
|
|
267
|
+
<label class="settings-field">
|
|
268
|
+
<span>Name</span>
|
|
269
|
+
<input type="text" name="name" .value=${i} required />
|
|
270
|
+
</label>
|
|
271
|
+
<div class="workspace-form-actions">
|
|
272
|
+
<button type="submit" class="settings-submit-button" ?disabled=${this.createPending}>
|
|
273
|
+
${s}
|
|
274
|
+
</button>
|
|
275
|
+
<button type="button" class="settings-cancel-button" @click=${()=>this.emitClose()}>
|
|
276
|
+
Cancel
|
|
277
|
+
</button>
|
|
278
|
+
</div>
|
|
279
|
+
</form>
|
|
280
|
+
</section>
|
|
281
|
+
</modal-overlay>
|
|
282
|
+
`,this)}}h(pi,"observedAttributes",["open"]);customElements.define("workspace-form-modal",pi);class fi extends HTMLElement{constructor(){super(...arguments);h(this,"workspaceService",O.resolve("WorkspaceService"));h(this,"serverManager",O.has("ServerManager")?O.resolve("ServerManager"):null);h(this,"subscriptions",new Qe);h(this,"deletePending",!1);h(this,"deleteError",null)}get open(){return this.hasAttribute("open")}attributeChangedCallback(e,s,i){e==="open"&&(i!==null&&s===null&&(this.deletePending=!1,this.deleteError=null),this.render())}connectedCallback(){this.render(),this.subscriptions.add(this.workspaceService.on("change",()=>this.render())),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}async handleDeleteWorkspace(){this.deletePending=!0,this.deleteError=null,this.render();try{await this.workspaceService.deleteWorkspace(),this.emitClose()}catch(e){this.deletePending=!1,this.deleteError=e instanceof Error?e.message:String(e),this.render()}}render(){var s;const e=this.workspaceService.activeWorkspaceServerURL!==null&&this.serverManager!==null&&this.workspaceService.activeWorkspaceServerURL!==this.serverManager.localServerURL;D(v`
|
|
283
|
+
<modal-overlay ?open=${this.open}>
|
|
284
|
+
<section class="workspace-modal workspace-delete-modal">
|
|
285
|
+
<div class="workspace-form">
|
|
286
|
+
<h2 class="workspace-modal-title">Delete workspace</h2>
|
|
287
|
+
<p class="workspace-delete-copy">
|
|
288
|
+
Delete <strong>${((s=this.workspaceService.activeWorkspace)==null?void 0:s.name)??""}</strong>?
|
|
289
|
+
</p>
|
|
290
|
+
${e?v`<p class="workspace-delete-warning">This will delete it for everyone.</p>`:null}
|
|
291
|
+
${this.deleteError?v`<p class="workspace-delete-error">${this.deleteError}</p>`:null}
|
|
292
|
+
<div class="workspace-form-actions">
|
|
293
|
+
<button
|
|
294
|
+
type="button"
|
|
295
|
+
class="settings-server-remove-button"
|
|
296
|
+
?disabled=${this.deletePending}
|
|
297
|
+
@click=${()=>void this.handleDeleteWorkspace()}
|
|
298
|
+
>
|
|
299
|
+
${this.deletePending?"Deleting...":"Delete"}
|
|
300
|
+
</button>
|
|
301
|
+
<button
|
|
302
|
+
type="button"
|
|
303
|
+
class="settings-cancel-button"
|
|
304
|
+
?disabled=${this.deletePending}
|
|
305
|
+
@click=${()=>this.emitClose()}
|
|
306
|
+
>
|
|
307
|
+
Cancel
|
|
308
|
+
</button>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</section>
|
|
312
|
+
</modal-overlay>
|
|
313
|
+
`,this)}}h(fi,"observedAttributes",["open"]);customElements.define("workspace-delete-modal",fi);class gi extends HTMLElement{constructor(){super(...arguments);h(this,"serverManager",O.has("ServerManager")?O.resolve("ServerManager"):null);h(this,"subscriptions",new Qe);h(this,"addServerFormOpen",!1)}get open(){return this.hasAttribute("open")}attributeChangedCallback(e){e==="open"&&(this.open||(this.addServerFormOpen=!1),this.render())}connectedCallback(){this.render(),this.serverManager&&this.subscriptions.add(this.serverManager.on("change",()=>this.render()))}disconnectedCallback(){this.subscriptions.dispose()}emitClose(){this.dispatchEvent(new Event("close",{bubbles:!0}))}openAddServerForm(){this.addServerFormOpen=!0,this.render()}closeAddServerForm(){this.addServerFormOpen&&(this.addServerFormOpen=!1,this.render())}handleAddServer(e){if(!this.serverManager)return;e.preventDefault();const s=e.currentTarget,i=new FormData(s),n=String(i.get("name")??"").trim(),a=String(i.get("url")??"").trim();!n||!a||(this.serverManager.addServer(a,n),this.addServerFormOpen=!1,s.reset(),this.render())}render(){var i;const e=((i=this.serverManager)==null?void 0:i.serverRecords)??[],s=this.serverManager!==null;D(v`
|
|
314
|
+
<modal-overlay ?open=${this.open}>
|
|
315
|
+
<section class="settings-panel">
|
|
316
|
+
<panel-view closable @close=${n=>n instanceof Vs&&this.emitClose()}>
|
|
317
|
+
<panel-page id="main" title="Settings">
|
|
318
|
+
<div class="settings-section">
|
|
319
|
+
${s?v`
|
|
320
|
+
<h3 class="settings-section-title">Servers</h3>
|
|
321
|
+
<div class="settings-server-list">
|
|
322
|
+
${e.map(n=>{var a;return v`
|
|
323
|
+
<div class="settings-card settings-server">
|
|
324
|
+
<div class="settings-server-details">
|
|
325
|
+
<div class="settings-server-name">${n.name}</div>
|
|
326
|
+
<div class="settings-server-url">${n.url}</div>
|
|
327
|
+
</div>
|
|
328
|
+
${n.url!==((a=this.serverManager)==null?void 0:a.localServerURL)?v`
|
|
329
|
+
<button
|
|
330
|
+
type="button"
|
|
331
|
+
class="settings-server-remove-button"
|
|
332
|
+
aria-label=${`Remove ${n.name}`}
|
|
333
|
+
@click=${()=>{var o;return(o=this.serverManager)==null?void 0:o.removeServer(n.url)}}
|
|
334
|
+
>
|
|
335
|
+
Remove
|
|
336
|
+
</button>
|
|
337
|
+
`:null}
|
|
338
|
+
</div>
|
|
339
|
+
`})}
|
|
340
|
+
</div>
|
|
341
|
+
${this.addServerFormOpen?v`
|
|
342
|
+
<form class="settings-card settings-add-server-form" @submit=${n=>this.handleAddServer(n)}>
|
|
343
|
+
<label class="settings-field">
|
|
344
|
+
<span>Name</span>
|
|
345
|
+
<input type="text" name="name" required />
|
|
346
|
+
</label>
|
|
347
|
+
<label class="settings-field">
|
|
348
|
+
<span>URL</span>
|
|
349
|
+
<input type="url" name="url" required />
|
|
350
|
+
</label>
|
|
351
|
+
<div class="settings-form-actions">
|
|
352
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
353
|
+
<button
|
|
354
|
+
type="button"
|
|
355
|
+
class="settings-cancel-button"
|
|
356
|
+
data-action="cancel-connect-form"
|
|
357
|
+
@click=${()=>this.closeAddServerForm()}
|
|
358
|
+
>
|
|
359
|
+
Cancel
|
|
360
|
+
</button>
|
|
361
|
+
</div>
|
|
362
|
+
</form>
|
|
363
|
+
`:v`
|
|
364
|
+
<button
|
|
365
|
+
type="button"
|
|
366
|
+
class="settings-submit-button settings-connect-button"
|
|
367
|
+
data-action="show-connect-form"
|
|
368
|
+
@click=${()=>this.openAddServerForm()}
|
|
369
|
+
>
|
|
370
|
+
+ Connect to server
|
|
371
|
+
</button>
|
|
372
|
+
`}
|
|
373
|
+
`:v`<p class="settings-copy">No additional settings yet.</p>`}
|
|
374
|
+
</div>
|
|
375
|
+
</panel-page>
|
|
376
|
+
</panel-view>
|
|
377
|
+
</section>
|
|
378
|
+
</modal-overlay>
|
|
379
|
+
`,this)}}h(gi,"observedAttributes",["open"]);customElements.define("settings-modal",gi);class mi extends Event{constructor(e){super("auth-submit",{bubbles:!0,composed:!0});h(this,"token");this.token=e}}class co extends HTMLElement{constructor(){super(...arguments);h(this,"_invalid",!1);h(this,"_tokenValue","")}set invalid(e){this._invalid=e,this.render()}get invalid(){return this._invalid}set tokenValue(e){this._tokenValue=e,this.render()}get tokenValue(){return this._tokenValue}connectedCallback(){this.render()}handleInput(e){const s=e.currentTarget;this._tokenValue=s.value}handleSubmit(e){e.preventDefault();const s=this._tokenValue.trim();s&&this.dispatchEvent(new mi(s))}render(){D(v`
|
|
380
|
+
<modal-overlay open>
|
|
381
|
+
<section class="auth-modal">
|
|
382
|
+
<form class="auth-form" @submit=${e=>this.handleSubmit(e)}>
|
|
383
|
+
<h2 class="auth-modal-title">Enter access token</h2>
|
|
384
|
+
<p class="auth-modal-copy">This Television server requires a token.</p>
|
|
385
|
+
<label class="settings-field">
|
|
386
|
+
<span>Token</span>
|
|
387
|
+
<input
|
|
388
|
+
class=${this.invalid?"auth-token-input-invalid":""}
|
|
389
|
+
type="password"
|
|
390
|
+
name="token"
|
|
391
|
+
.value=${this.tokenValue}
|
|
392
|
+
@input=${e=>this.handleInput(e)}
|
|
393
|
+
required
|
|
394
|
+
/>
|
|
395
|
+
</label>
|
|
396
|
+
<button type="submit" class="settings-submit-button">Connect</button>
|
|
397
|
+
</form>
|
|
398
|
+
</section>
|
|
399
|
+
</modal-overlay>
|
|
400
|
+
`,this)}}customElements.get("auth-modal")||customElements.define("auth-modal",co);class ho extends HTMLElement{constructor(){super(...arguments);h(this,"modals",{workspaceForm:{open:!1,mode:"edit"},deleteWorkspace:{open:!1},settings:{open:!1}});h(this,"_authRequired",!1);h(this,"_authInvalid",!1);h(this,"_authToken","");h(this,"_authError",null)}set authRequired(e){this._authRequired=e,this.render()}get authRequired(){return this._authRequired}set authInvalid(e){this._authInvalid=e,this.render()}get authInvalid(){return this._authInvalid}set authToken(e){this._authToken=e,this.render()}get authToken(){return this._authToken}set authError(e){this._authError=e,this.render()}get authError(){return this._authError}connectedCallback(){this.render()}render(){if(this.authRequired){D(v`
|
|
401
|
+
<main class="auth-gate">
|
|
402
|
+
<auth-modal
|
|
403
|
+
.invalid=${this.authInvalid}
|
|
404
|
+
.tokenValue=${this.authToken}
|
|
405
|
+
></auth-modal>
|
|
406
|
+
</main>
|
|
407
|
+
`,this);return}const e=v`
|
|
408
|
+
<header>
|
|
409
|
+
<nav>
|
|
410
|
+
<workspace-picker
|
|
411
|
+
@edit-workspace=${()=>{this.modals.workspaceForm={open:!0,mode:"edit"},this.render()}}
|
|
412
|
+
@create-workspace=${s=>{s instanceof di&&(this.modals.workspaceForm={open:!0,mode:"create",targetServerURL:s.serverURL},this.render())}}
|
|
413
|
+
@delete-workspace=${()=>{this.modals.deleteWorkspace={open:!0},this.render()}}
|
|
414
|
+
></workspace-picker>
|
|
415
|
+
</nav>
|
|
416
|
+
<button
|
|
417
|
+
type="button"
|
|
418
|
+
variant="toolbar"
|
|
419
|
+
size="sm"
|
|
420
|
+
aria-label="Settings"
|
|
421
|
+
@click=${()=>{this.modals.settings={open:!this.modals.settings.open},this.render()}}
|
|
422
|
+
>
|
|
423
|
+
${Nn({size:16,weight:"bold"})}
|
|
424
|
+
</button>
|
|
425
|
+
</header>
|
|
426
|
+
<main>
|
|
427
|
+
${this.authError?v`<p data-testid="auth-error">${this.authError}</p>`:v`<workspace-view></workspace-view>`}
|
|
428
|
+
</main>
|
|
429
|
+
<workspace-form-modal
|
|
430
|
+
?open=${this.modals.workspaceForm.open}
|
|
431
|
+
.mode=${this.modals.workspaceForm.mode}
|
|
432
|
+
.targetServerURL=${this.modals.workspaceForm.targetServerURL}
|
|
433
|
+
@close=${()=>{this.modals.workspaceForm={open:!1,mode:"edit"},this.render()}}
|
|
434
|
+
></workspace-form-modal>
|
|
435
|
+
<workspace-delete-modal
|
|
436
|
+
?open=${this.modals.deleteWorkspace.open}
|
|
437
|
+
@close=${()=>{this.modals.deleteWorkspace={open:!1},this.render()}}
|
|
438
|
+
></workspace-delete-modal>
|
|
439
|
+
<settings-modal
|
|
440
|
+
?open=${this.modals.settings.open}
|
|
441
|
+
@close=${()=>{this.modals.settings={open:!1},this.render()}}
|
|
442
|
+
></settings-modal>
|
|
443
|
+
`;D(e,this)}}customElements.define("television-app",ho);const Mr=Sn(),mr=vn(),uo=yn(),ki=on(Mr?"television-electron":"television-browser",mr),kr=new Map,wr=new Oi({clientStore:ki,servers:kr}),ie=document.createElement("television-app");O.register("WorkspaceService",()=>wr);if(Mr){const r=new gn({clientStore:ki,servers:kr,workspaceService:wr,localServerURL:mr});O.register("ServerManager",()=>r),r.connectConfiguredServers()}else{let r=null;const t=(i,n,a)=>{ie.authRequired=i,ie.authInvalid=n,ie.authToken=a},e=i=>{const n=new URL(window.location.href);n.searchParams.set("token",i),window.history.replaceState({},"",`${n.pathname}${n.search}${n.hash}`)},s=i=>{r==null||r.disconnect();const n=new Ts({url:mr,name:"Server",token:i,servers:kr});r=n,n.on("serverEvent",({serverURL:a,event:o})=>{r===n&&(ie.authError=null,t(!1,!1,i??""),wr.handleServerEvent(a,o))}),n.on("auth-failed",()=>{r===n&&t(!0,i!==null,i??"")}),n.connect()};ie.addEventListener("auth-submit",i=>{var a;const n=i instanceof mi?i.token:i instanceof CustomEvent&&typeof((a=i.detail)==null?void 0:a.token)=="string"?i.detail.token:null;n&&(ie.authError=null,t(!0,!1,n),e(n),s(n))}),s(uo)}Mr&&document.body.classList.add("electron");document.body.appendChild(ie);
|