@clepit/core 0.6.0-beta.415 → 0.6.0-beta.416
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/CHANGELOG.md +2 -0
- package/dist/core/renderer/page.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,r as a,t as o}from"./highlight-C4NcTcIm.mjs";var i=e=>{let t;const n=/* @__PURE__ */new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var r,s,l,c=(l?i(l):i)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((r=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},seedBlocks:(n,a)=>{const o=t().instances[n];o&&e(e=>({instances:{...e.instances,[n]:{...o,data:{...o.data,blocks:a}}}}))},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),s={name:"clepit-store",version:0},(e,t,n)=>{const a=s.version??0,o=s.storage??("undefined"==typeof localStorage?void 0:localStorage),i=s.merge??((e,t)=>Object.assign({},t,e)),l=r(e,t,n);if(o){try{const e=o.getItem(s.name);if(e){const t=JSON.parse(e),n=t.version===a?t.state:s.migrate?s.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(l,i(n,l))}}catch{}n.subscribe(e=>{try{o.setItem(s.name,JSON.stringify({state:s.partialize?s.partialize(e):e,version:a}))}catch{}})}return l})))),d=["http:","https:"],p=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],u=["file","design","board","proto","slides","deck"],m=["document","spreadsheets","presentation"],h=/^[0-9a-f]{32}$/,g=/^[A-Za-z0-9]+$/,b={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function f(e,t){const n=b[e];return void 0!==n&&(t??[]).includes(n)}var y=(e,t="link")=>({embedUrl:null,provider:t,url:e});function v(e,t){return e===t||e.endsWith(`.${t}`)}function x(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(p.includes(n)){const t=function(e){if(v(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:y(a,"youtube")}if(v(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&u.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:y(a,"figma")}if(v(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:y(a,"miro")}if(v(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&g.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:y(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:y(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&m.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:y(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&h.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:y(a,"githubGist")}if(v(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:y(a,"airtable")}if(v(n,"diagrams.net")||v(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(v(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:y(a,"googleMaps")}return y(a)}function k(e,t){const n=function(e){try{const t=new URL(e);return d.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=x(n,t);return f(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function w(e,t,n,a){const o=c.getState().getInstance(e)?.config,i=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?ss.replaceBlock(e,t,i):ss.insertBlock(i,e,t+1);const r=ss.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return r&&o?.resolveLink&&await C(e,r,o.resolveLink),r}async function C(e,t,n){if(!n)return;const a=ss.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;ss.updateBlockData(t,{...r,...o,url:a.url},e)}catch{ss.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var S={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(91, 91, 255, 0.14)",codeString:"#0a7c3e",codeText:"#0a0a0a",codeType:"#953800",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",marker:"#ffe047",primary:"#5b5bff",primaryBg:"rgba(91, 91, 255, 0.08)",primaryHover:"#4747e6",selectionBg:"rgba(91, 91, 255, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},A={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",error:"--clepit-error",errorBg:"--clepit-error-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",marker:"--clepit-marker",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},E=(e,t,n)=>{const a=[];for(const o of Object.keys(A)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const r=A[o];void 0!==n&&void 0!==i?a.push(` ${r}: light-dark(${n}, ${i});`):a.push(` ${r}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},N=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(e,t){if(document.getElementById(e))return!1;const n=document.createElement("style");return n.id=e,n.textContent=t,document.head.appendChild(n),!0}static{this.themeRegistry=/* @__PURE__ */new Map}static{this.themeSubscribers=/* @__PURE__ */new Set}static registerEditor(t,n,a){const o=document.getElementById(t);o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute();const i=document.getElementById(`clepit-overrides-${t}`);if(i&&i.remove(),a){const n=E(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){const n=document.getElementById(`clepit-overrides-${t}`);n&&n.remove();const a=document.getElementById(t);a&&(a.removeAttribute("data-clepit-theme"),a.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},L="\n.clepit-embed {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",B=L,$=L,I=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=e}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},T={create:e=>new I(document.createElement(e)),createNS:(e,t)=>new I(document.createElementNS(e,t))},M=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),_=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),D=e=>e.replace(/&/g,"&").replace(/"/g,"""),q=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=/* @__PURE__ */new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(_(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(_(e))}toString(){const e=[...this.classes.length>0?[`class="${D(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${D(t)}"`)],t=[this.tag,...e].join(" ");return M.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},j=e=>({create:t=>new q(t,e),createNS:(t,n)=>new q(n,e)}),z=e=>String(e),H=e=>{if(!(e instanceof I))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function O(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function P(e,t){return`${e}-${t}`}function R(e){return!e||!e.trim()||"<br>"===e}function F(e){if(!e||R(e))return"";const t=document.createElement("div");t.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return e.cloneNode(!0);if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes)a.includes(e.name.toLowerCase())&&r.setAttribute(e.name,e.value);"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function U(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}function V(){N.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=O("div","clepit-invalid-data"),t=O("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var W={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function K(e){return W[e]||"Unknown"}var G=Object.fromEntries(Object.keys(n).map(e=>[e,{name:K(e)}])),J=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${N.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: 6px;\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${N.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${N.classNames.block.code.editor} .clepit-code-highlight,\n.${N.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre;\n overflow: auto;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${N.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${N.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${N.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${N.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${N.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,X="clepit-code-output-styles",Z="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n overflow-x: auto;\n white-space: pre;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",Y=(e,t,n)=>c.getState().getInstance(e)?.config.blockToolbarLabels?.[t]||n,Q={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function ee(e){return Q[e]||"Unknown"}var te=Object.fromEntries(Object.keys(Q).map(e=>[e,{name:ee(e),theme:null}])),ne=`\n/* Custom Switch Container */\n.${N.classNames.switch.container} {\n --switch-blue: #0D7EFF;\n --switch-red: #FF0D0D;\n --switch-text: var(--clepit-bg);\n --switch-white: var(--clepit-bg);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.${N.classNames.switch.container} .tgl {\n display: none;\n}\n\n.${N.classNames.switch.container} .tgl,\n.${N.classNames.switch.container} .tgl:after,\n.${N.classNames.switch.container} .tgl:before,\n.${N.classNames.switch.container} .tgl *,\n.${N.classNames.switch.container} .tgl *:after,\n.${N.classNames.switch.container} .tgl *:before,\n.${N.classNames.switch.container} .tgl + .tgl-btn {\n box-sizing: border-box;\n}\n\n.${N.classNames.switch.container} .tgl::selection,\n.${N.classNames.switch.container} .tgl:after::selection,\n.${N.classNames.switch.container} .tgl:before::selection,\n.${N.classNames.switch.container} .tgl *::selection,\n.${N.classNames.switch.container} .tgl *:after::selection,\n.${N.classNames.switch.container} .tgl *:before::selection,\n.${N.classNames.switch.container} .tgl + .tgl-btn::selection {\n background: none;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn {\n outline: 0;\n display: block;\n width: 57px;\n height: 27px;\n position: relative;\n cursor: pointer;\n user-select: none;\n font-size: 12px;\n font-weight: 400;\n color: var(--switch-white);\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:after,\n.${N.classNames.switch.container} .tgl + .tgl-btn:before {\n position: relative;\n display: block;\n content: "";\n width: 44%;\n height: 100%;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:after {\n left: 0;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:before {\n display: inline;\n position: absolute;\n top: 3px;\n}\n\n.${N.classNames.switch.container} .tgl:checked + .tgl-btn:after {\n left: 56.5%;\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn {\n background: var(--switch-red);\n border-radius: 20rem;\n padding: 2px;\n transition: all 0.4s ease;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:after {\n border-radius: 2em;\n background: var(--switch-white);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:before {\n content: "No";\n left: 30px;\n color: var(--switch-text);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:active:after {\n padding-right: 0.4em;\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn {\n background: var(--switch-blue);\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active:after {\n margin-left: -0.4em;\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:before {\n content: "Yes";\n left: 6px;\n color: var(--switch-white);\n}\n\n.clepit-switch-label-text {\n font-size: 13px;\n display: flex;\n align-items: center;\n}\n`,ae=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,id:r=`switch-${Math.random().toString(36).substring(2,11)}`}=e;N.injectStyles("clepit-custom-switch-styles",ne);const s=N.createStyledElement("div",N.classNames.switch.container,{classNames:a?.container,styles:o?.container}),l=N.createStyledElement("input","tgl tgl-ios",{classNames:a?.input,styles:o?.input});l.type="checkbox",l.id=r,l.checked=t;const c=N.createStyledElement("label","tgl-btn",{classNames:a?.label,styles:o?.label});if(c.setAttribute("for",r),n&&l.addEventListener("change",e=>{const t=e.target;n(t.checked)}),s.appendChild(l),s.appendChild(c),i){const e=N.createStyledElement("span","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.textContent=i,s.appendChild(e)}return s}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t)}},oe=class e{static{this.placeholder="Enter code..."}static{this.supportedLanguages=G}static{this.supportedThemes=te}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=/* @__PURE__ */new WeakMap}static{this.dataMap=/* @__PURE__ */new WeakMap}static save(t){const n=t.querySelector(`.${N.classNames.block.code.container}`),a=n.querySelector(`.${N.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||e.defaultLanguage,i=n?.getAttribute("data-theme")||e.defaultTheme,r=!!a&&ae.getState(a),s=e.inputMap.get(n);if(s){const t=s.value,a=e.dataMap.get(n),l={code:t.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),e.dataMap.set(n,l),l}return{...e.dataMap.get(n)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(t,n,a,o){N.injectStyles("clepit-code-input-styles",J);const i={code:"",language:o?.language||e.defaultLanguage,showCopy:!0,theme:o?.theme||e.defaultTheme},r=n?{...i,...n}:i,s=N.createStyledElement("div",N.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});s.setAttribute("data-language",r.language||e.defaultLanguage),s.setAttribute("data-theme",r.theme||e.defaultTheme);const l=N.createStyledElement("div",N.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=N.createStyledElement("div",N.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=G[r.language]?.name||K(e.defaultLanguage),u=te[r.theme]?.name||ee(e.defaultTheme);d.textContent=e.getHeaderText(p,u);const m=N.createStyledElement("div",N.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});m.setAttribute("data-placeholder",Y(t,"codeHint",e.placeholder));const h=t?c.getState().getInstance(t):null,g=h?.config.classNames?.switch,b=h?.config.styles?.switch,f=ae.create({checked:r.showCopy||!1,classNames:g,label:"Allow copy",onToggle:t=>{const n=e.dataMap.get(s)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme};e.dataMap.set(s,{...n,showCopy:t}),ss.saveBlockData(s)},styles:b});return l.appendChild(d),l.appendChild(f),s.appendChild(l),s.appendChild(m),e.mountEditor(s,m,r),s}static mountEditor(t,n,a){const o=a.language??e.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${K(o)} code`),s.placeholder=n.getAttribute("data-placeholder")||e.placeholder,n.replaceChildren(i,s),e.inputMap.set(t,s),e.dataMap.set(t,a),e.paint(t,r,s.value),s.addEventListener("input",()=>{e.paint(t,r,s.value);const n=e.dataMap.get(t)??{code:"",language:t.getAttribute("data-language")||e.defaultLanguage,theme:t.getAttribute("data-theme")||e.defaultTheme};e.dataMap.set(t,{...n,code:s.value}),ss.saveBlockData(t)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>e.handleKeydown(t,s,n))}static paint(t,n,a){const i=t.getAttribute("data-language")||e.defaultLanguage;n.replaceChildren(...o(a.endsWith("\n")?`${a} `:a,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(t,n){const a=t.querySelector(`.${N.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${N.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${N.classNames.block.code.header}`),r=a.getAttribute("data-theme")||e.defaultTheme,s=ee(r),l=K(n);i&&(i.textContent=e.getHeaderText(l,s));const c=e.inputMap.get(a);c&&e.mountEditor(a,o,{code:c.value,language:n,theme:r}),ss.saveBlockData(a)}static updateTheme(t,n){const a=t.querySelector(`.${N.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${N.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${N.classNames.block.code.header}`),r=a.getAttribute("data-language")||e.defaultLanguage,s=K(r),l=ee(n);i&&(i.textContent=e.getHeaderText(s,l));const c=e.inputMap.get(a);c&&e.mountEditor(a,o,{code:c.value,language:r,theme:n}),ss.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${N.classNames.block.container}`);if(!a)return;const o=ss.getEditorId(a);if(!o)return;const i=ss.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void ss.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?ss.moveBlock(o,i,i-1):ss.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?ss.moveBlock(o,i,i+1):ss.focusBlock(a.nextElementSibling))):void ss.removeBlock(o,i):(n.preventDefault(),void ss.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(t){const n=t.querySelector(`.${N.classNames.block.code.container}`);if(!n)return!0;const a=e.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return R(e.code)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",t);n.querySelectorAll(`.${N.classNames.block.code.container}`).forEach(t=>{e.inputMap.delete(t),e.dataMap.delete(t)})}},ie=".clepit-output-code-container",re=(e,n)=>[`${e} { background: ${n.background}; color: ${n.text}; }`,...t.map(t=>`${e} .clepit-code-${t} { color: ${n[t]};${(e=>"comment"===e?" font-style: italic;":"")(t)} }`)].join("\n"),se=()=>[re(ie,e()),...Object.entries(a).map(([e,t])=>re(`${ie}[data-theme='${e}']`,t))].join("\n"),le="clepit:code-variant-sync",ce=e=>`clepit.code-variant.${e}`,de=(e,t)=>e.label?e.label:e.language?W[e.language]??e.language:`Tab ${t+1}`,pe=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>de(e,n)===t);return-1===n?0:n},ue=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(ce(e))}catch{return null}};function me(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;N.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,N.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,N.applyStyling(s,{styles:o?.content});const c=document.createElement("div");c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,N.applyStyling(c,{styles:o?.arrow}),s.appendChild(c),i.appendChild(s),document.body.appendChild(i);const d=e.getBoundingClientRect(),p=s.offsetWidth,u=s.offsetHeight;let m,h=d.left+d.width/2-p/2;h=Math.max(8,Math.min(h,window.innerWidth-p-8));let g=n;"below"===n?(m=d.bottom+6+2,m+u>window.innerHeight-8&&(m=d.top-u-6-2,g="above")):(m=d.top-u-6-2,m<8&&(m=d.bottom+6+2,g="below")),c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${g} ${a?.arrow||""}`,i.style.left=`${h}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-u-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(l(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},l=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",l),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",l),l()}}var he="http://www.w3.org/2000/svg",ge=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],be=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static draw(t,n=T,a){if(!e.validate(t)||oe.isEmptyData(t))return null;const i=ge(t),r=i.length>1,s=Math.min(Math.max(a?.activeVariant??0,0),i.length-1),l=n.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",t.theme??oe.defaultTheme),t.syncKey&&l.setAttribute("data-sync-key",t.syncKey);const c=n.create("div");if(c.addClass("clepit-output-code-header"),r){const e=n.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,a)=>{const o=n.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",a===s?"true":"false"),o.setAttribute("tabindex",a===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${a}`),o.setText(de(t,a)),e.append(o)}),c.append(e)}else{const e=n.create("span");e.setText(W[t.language??"typescript"]??"TypeScript"),c.append(e)}if(t.showCopy){const e=n.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(he,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(he,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(n)),c.append(e)}l.append(c);const d=n.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((e,a)=>{const i=n.create("pre");i.addClass("clepit-output-code-pane"),i.setAttribute("data-variant-index",String(a)),a!==s&&i.setAttribute("hidden","");const r=n.create("code");for(const s of o(e.code??t.code,e.language??t.language??"plaintext")){const e=n.create("span");s.classes&&e.addClass(...s.classes.split(" ")),e.setText(s.text),r.append(e)}i.append(r),d.append(i)}),l.append(d),l}static render(t,n,a,o,i){if(N.injectStyles(X,Z),N.injectStyles(`${X}-theme`,se()),!e.validate(t))return V();if(oe.isEmptyData(t))return document.createElement("div");const r=ge(t),s=r.length>1?pe(r,ue(t.syncKey)):0,l=H(e.draw(t,T,{activeVariant:s}));o?.container&&l.classList.add(o.container),a?.container&&Object.assign(l.style,a.container);const c=l.querySelector(".clepit-output-code-header");return c&&o?.header?.text&&c.classList.add(o.header.text),c&&a?.header?.text&&Object.assign(c.style,a.header.text),e.attach(l,t,s,i),l}static activate(t,n){if(!e.validate(n)||oe.isEmptyData(n))return()=>{};const a=ge(n),o=a.length>1?pe(a,ue(n.syncKey)):0;return e.attach(t,n,o,void 0,!0)}static activateFromMarkup(t){const n=[...t.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...t.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=t.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==t.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?pe(o,ue(i)):0;return e.attach(t,r,s,void 0,!0)}static attach(t,n,a,o,i=!1){const r=ge(n),s=o?document.getElementById(o):null,l=[...t.querySelectorAll(".clepit-output-code-tab")],d=[...t.querySelectorAll(".clepit-output-code-pane")];let p=a;const u=[];let m;const h=(t,n,a)=>{if(t.addEventListener(n,a),u.push({event:n,handler:a,target:t}),s){const o=e.eventListenersMap.get(s)??[];o.push({element:t,event:n,handler:a}),e.eventListenersMap.set(s,o)}},g=(e,t)=>{if(e<0||e>=r.length)return;if(p=e,l.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),d.forEach((t,n)=>{t.hidden=n!==e}),!t||!n.syncKey)return;const a=de(r[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(ce(e),t)}catch{return}})(n.syncKey,a),window.dispatchEvent(new CustomEvent(le,{detail:{label:a,syncKey:n.syncKey}}))};if(l.forEach((e,t)=>{h(e,"click",()=>g(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?r.length-1:0===a?-1:(t+a+r.length)%r.length;-1!==o&&(e.preventDefault(),g(o,!0),l[o]?.focus())})}),l.length>1&&n.syncKey){const t=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=r.findIndex((e,n)=>de(e,n)===t.label);-1!==a&&a!==p&&g(a,!1)};if(window.addEventListener(le,t),u.push({event:le,handler:t,target:window}),s){const n=e.eventListenersMap.get(s)??[];n.push({element:window,event:le,handler:t}),e.eventListenersMap.set(s,n)}}const b=()=>{for(const{event:e,handler:t,target:n}of u)n.removeEventListener(e,t);m?.()};i&&g(a,!1);const f=t.querySelector(".clepit-output-code-copy-btn");if(!f)return b;h(f,"click",()=>{e.copyCodeToClipboard(r[p]?.code??n.code),e.animateCopyButton(f)});const y=o?c.getState().getInstance(o):null;return m=me(f,"Copy code","above",y?.config.classNames?.tooltips,y?.config.styles?.tooltips),b}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},fe="inline-issue",ye='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5b5bff);\n background: var(--clepit-primary-bg, rgba(91, 91, 255, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',ve={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},xe={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},ke={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function we(e,t,n={}){let a=e?.[t]??ve[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Ce=e=>xe[e]??e,Se="clepit-issue",Ae=["todo","started","done","cancelled"],Ee=["connect_tool","no_access","provider_unreachable"],Ne={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},Le=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),Be=(e,t)=>e.reason?we(t,Ne[e.reason],{tool:Ce(e.tool)}):null,$e=(e,t)=>e.stateName||we(t,ke[e.category]),Ie=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),Te=class e{static build(t,n,a=T){const o=a.create("a");o.addClass(Se),t.reason&&o.addClass(`${Se}--reason`),o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${Se}__key`),i.setText(t.key||(t.title?"":Ce(t.tool))),!t.key&&t.title||o.append(i);const r=Be(t,n);if(r){const e=a.create("span");return e.addClass(`${Se}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${Se}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${Se}__state`),e.setAttribute("data-issue-category",t.category),e.setText($e(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${Se}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(Le(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return z(e.build(t,n,j(a)))}static create(t,n){return N.injectStyles(fe,ye),H(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:Ae.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Ee.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||e.getAttribute("href")||""}}static collect(e){return Array.from(e.querySelectorAll(`a.${Se}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Me=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,_e=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/"/g,'"').replace(/&/g,"&"),De=e=>{const t=t=>_e(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:Ae.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Ee.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||_e(e,"href")}},qe=e=>Array.from(e.matchAll(Me),e=>De(e[0])),je=(e,t,n,a,o)=>t||n?e.replace(Me,e=>{const i=De(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Te.markup(r,a,o)}):e,ze=class e{static render(t,n){return N.injectStyles(fe,ye),H(e.draw(t,T,n,!0))}static draw(t,n,a,o){const i=Be(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText($e(t,a)),s.append(c),r.append(s);const d=n.create("span");d.addClass("clepit-issue-card__meta");const p=n.create("span");if(p.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(Le(t.assigneeName)),p.append(e),p.appendText(t.assigneeName)}else p.setText(we(a,"unassigned"));if(d.append(p),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText(we(a,"updatedRelative",{when:(u=t.updatedAt,u.length>=10?u.slice(0,10):u)})),d.append(e)}var u;return r.append(d),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||Ce(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText(we(a,"connectAction")),l.append(t)}return i.append(l),i}},He="allow-scripts allow-same-origin allow-presentation allow-forms",Oe={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},Pe={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function Re(e,t,n={}){let a=e?.[t]??Oe[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Fe=new Set(Object.keys(W)),Ue={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function Ve(e){if(!e)return;const t=e.toLowerCase(),n=Ue[t];return n||(Fe.has(t)?t:void 0)}var We={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},Ke={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function Ge(e,t){const n=Pe[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var Je=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,Xe=class e{static render(t,n,a,o){if(N.injectStyles("embed-output",$),!e.validate(t))return V();if(t.issue)return ze.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=k(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return V();if(!Je(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=Ge(t,i);if(!s)return r;const l=N.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),l.appendChild(r);const c=document.createElement("span");c.className="clepit-embed-card__reason",c.setAttribute("data-testid","embed-reason");const d=document.createElement("span");if(d.textContent=Re(n?.embedLabels,We[s.reason],{tool:s.tool}),c.appendChild(d),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=Re(n?.embedLabels,Ke[s.action]),c.appendChild(e)}return l.appendChild(c),l}static draw(t,n=T,a){if(!e.validate(t))return null;if(t.issue)return ze.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=k(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!Je(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=Ge(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(Re(a?.embedLabels,We[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(Re(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(Re(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=be.draw({code:i.content,language:Ve(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",He),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=N.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=N.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",He),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=N.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},Ze=/^[A-Z][A-Z0-9_]*-\d+$/,Ye=/^\d+$/,Qe=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),et=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function tt(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&Ze.test(t)?et("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&Ye.test(a)?et("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&Ye.test(t[0])&&Ye.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&Ye.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&Ye.test(t[2]))?et("asana",""):null}if(Qe(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&Ze.test(o[1]))return et("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&Ze.test(t)?et("jira",t,e):null}return null}var nt=/* @__PURE__ */new WeakMap,at=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?nt.get(t):void 0)??{url:""}}static render(t,n,a){N.injectStyles("embed-input",B);const o=n??{url:""},i=c.getState().getInstance(t)?.config,r=Xe.render(o,{disabledEmbedProviders:i?.disabledEmbedProviders,embedLabels:i?.embedLabels},a?.styles,a?.classNames);return r.classList.add("clepit-embed--input"),r.setAttribute("contenteditable","false"),nt.set(r,o),e.listenForActions(t,r),r}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),i=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=i;return ss.updateBlockData(o,t,a)}case"embedShowCard":return ss.updateBlockData(o,{...i,display:"card"},a);case"embedShowLink":{const e=ss.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=i.url,t.textContent=i.url,ss.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(i.url);case"embedShowChip":{const e=ss.getBlockIndex(a,o);if(-1===e)return;const t=c.getState().getInstance(a)?.config,n=tt(i.url,t?.jiraSites),r=i.issue??Ie(i.url,n?.tool??"",n?.key??""),s=Te.create({...r,url:i.url},t?.issueLabels);return ss.replaceBlock(a,e,{data:{html:`${s.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const i=t.querySelector(`.${N.classNames.block.content}`);if(!i)return;const r=c.getState().getInstance(n),s={classNames:r?.config.classNames?.blocks?.embed,styles:r?.config.styles?.blocks?.embed};i.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},s))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void c.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const i=o.getAttribute("data-embed-action"),r=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");if(!r)return;const s=c.getState().getInstance(t)?.config;"retry"===i?C(t,r,s?.resolveLink):s?.onEmbedAction?.(i,r)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function ot(e,t){const n=c.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=tt(a,n.jiraSites);e[a]={...Ie(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function it(e,t,n,a,o,i){const r=c.getState().getInstance(e)?.config,s=Ie(o,i.tool,i.key);if(a&&"on"===r?.issueCards){const t={data:{issue:s,url:o},type:"embed"};ss.replaceBlock(e,n,t);const a=ss.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await ot(e,[n]))[n];if(!a)return;const o=ss.getBlock(t);if(!o)return;const i=at.save(o);ss.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const l=Te.insertAtCaret(s,r?.issueLabels);if(!l)return;const d=l.closest('[contenteditable="true"]');d&&ss.saveBlockData(d),await async function(e,t,n){const a=(await ot(e,[n]))[n];if(!a||!t.isConnected)return;const o=c.getState().getInstance(e)?.config;Te.refresh(t,a,o?.issueLabels);const i=t.closest('[contenteditable="true"]');i&&ss.saveBlockData(i)}(e,l,o)}function rt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function st(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function lt(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function ct(e){return e.toLowerCase().includes("vimeo.com")}function dt(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=lt(t),a=ct(t);return{isImage:rt(t),isUrl:!0,isVideo:st(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var pt=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),ut=(e,t)=>{const n=dt(t);if(!n.isUrl)return null;if(n.isImage)return pt(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return pt(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,tt(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!pt(e,"embed"))return null;const r=function(e,t){const n=k(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null};function mt(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function ht(){return"mac"===mt()?"⌘":"Ctrl"}function gt(e){return"mac"===mt()?e.join(""):e.join(" + ")}var bt=e=>gt([ht(),e]),ft=e=>gt([ht(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),yt=()=>gt([ht(),"B"]),vt=()=>gt([ht(),"⌫"]),xt=()=>gt([ht(),"⌦"]),kt=()=>gt([ht(),"I"]),wt=()=>gt([ht(),"K"]),Ct=e=>gt([ht(),"⇧",e]),St=e=>gt([ht(),"⇧",{down:"↓",left:"←",right:"→",up:"↑"}[e]]),At=()=>gt([ht(),"U"]),Et=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=yt()}static apply(e){N.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},Nt=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=bt("`")}static apply(e,t,n){N.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&N.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),ss.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&N.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},Lt=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=kt()}static apply(e){N.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Bt="clepit-link-styles",$t=`\n/* Link styles - simple and clean */\n.${N.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${N.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n`,It="clepit-dialogs-styles",Tt="\n/* Dialog Overlay */\n/* A native <dialog>. showModal() puts it in the top layer and paints a real\n * ::backdrop, so the full-screen scrim, the z-index and the manual centring are\n * the browser's job now. The non-modal branch below keeps the old flex overlay\n * for a DOM without showModal, where the element is an ordinary block. */\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(2px);\n}\n\n/* Fallback: no showModal, so the element is not in the top layer and paints no\n * backdrop of its own. */\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n backdrop-filter: blur(2px);\n}\n\n/* Dialog Container */\n.clepit-dialog {\n background: var(--clepit-bg);\n border-radius: 8px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);\n padding: 24px;\n min-width: 400px;\n max-width: 500px;\n max-height: 80vh;\n overflow-y: auto;\n position: relative;\n transform: scale(0.95);\n opacity: 0;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.95);\n opacity: 0;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n/* Dialog Title */\n.clepit-dialog-title {\n margin: 0 0 20px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--clepit-text);\n text-align: center;\n}\n\n/* Dialog Group */\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n/* Dialog Label */\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 14px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n/* Dialog Input */\n.clepit-dialog-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n font-size: 14px;\n color: var(--clepit-text);\n background: var(--clepit-bg);\n transition: border-color 0.2s ease, box-shadow 0.2s ease;\n box-sizing: border-box;\n}\n\n.clepit-dialog-input:focus {\n outline: none;\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Dialog Buttons */\n.clepit-dialog-buttons {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n/* Dialog Button */\n.clepit-dialog-button {\n padding: 10px 20px;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease;\n min-width: 80px;\n}\n\n.clepit-dialog-button--cancel {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-border);\n border-color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: white;\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n/* Responsive */\n@media (max-width: 640px) {\n .clepit-dialog {\n min-width: 320px;\n max-width: 90vw;\n margin: 20px;\n }\n\n .clepit-dialog-buttons {\n flex-direction: column;\n }\n\n .clepit-dialog-button {\n width: 100%;\n }\n}\n",Mt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.textInput?.value.trim()||"",t=this.urlInput?.value.trim()||"";e&&t&&(this.options.onConfirm(e,t),this.hide())}},this.options=e}show(){this.overlay||e.isOpen||(N.injectStyles(It,Tt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="link-dialog-title",e.textContent=this.word("insertLink","Insert Link"),this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup(this.word("textField","Text"),this.word("linkTextPlaceholder","Link text"),this.options.text,"text","link-dialog-text");this.textInput=t.querySelector("input");const n=this.createInputGroup(this.word("urlField","URL"),this.word("urlPlaceholder","https://example.com"),this.options.url,"url","link-dialog-url");this.urlInput=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none")}createInputGroup(e,t,n,a,o){const i=O("div","clepit-dialog-group");this.applyStyles(i,this.options.styles?.group),this.applyClassNames(i,this.options.classNames?.group);const r=O("label","clepit-dialog-label");r.dataset.testid=`${o}-label`,r.textContent=e,this.applyStyles(r,this.options.styles?.label),this.applyClassNames(r,this.options.classNames?.label);const s=O("input","clepit-dialog-input");return s.type="url"===a?"url":"text",s.value=n,s.dataset.testid=`${o}-input`,s.placeholder=t,this.applyStyles(s,this.options.styles?.input),this.applyClassNames(s,this.options.classNames?.input),i.appendChild(r),i.appendChild(s),i}createButtonGroup(){const e=O("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=O("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="link-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=O("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="link-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.textInput?.value.trim()||"",this.urlInput?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.textInput&&this.textInput.addEventListener("keydown",this.handleInputKeyDown),this.urlInput&&this.urlInput.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.urlInput&&(this.urlInput.focus(),this.urlInput.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{void 0!==n&&e.style.setProperty(t,String(n))})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){document.removeEventListener("keydown",this.handleKeyDown),this.hide(),e.isOpen=!1}},_t=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=wt()}static apply(t,n,a,o){N.injectStyles(Bt,$t);const i=t.toString().trim(),r=e.findLinkElement(t.commonAncestorContainer);let s=i,l="";r&&(s=r.textContent||i,l=r.href||"");const c=t.cloneRange();new Mt({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(c))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(a){if(a.removeAllRanges(),a.addRange(c),!n.trim())return void e.remove(c);if(t!==i){c.deleteContents();const e=document.createTextNode(t);c.insertNode(e),c.selectNode(e)}const o=N.createStyledElement("a",N.classNames.block.link);o.href=n,o.target="_blank",o.rel="noopener noreferrer";try{c.surroundContents(o)}catch{const e=c.extractContents();o.appendChild(e),c.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');if(s){const e=new Event("input",{bubbles:!0});s.dispatchEvent(e)}}}catch(a){console.error("Failed to apply link:",a)}},styles:a,text:s||"Link text",url:l}).show(),ss.updateStateFromRange(t)}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},Dt="clepit-marker-styles",qt="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",jt=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static{this.shortcut=Ct("M")}static apply(t,n,a){N.injectStyles(Dt,qt);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),ss.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}ss.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(N.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(N.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&N.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${N.classNames.editor.content}, .${N.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${N.classNames.block.content}`);if(!s)return;const l=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(l&&"initial"!==l&&"inherit"!==l){const t=e.createStrokeSVG(l);return void(n.style.background=t)}const c=window.getComputedStyle(s).backgroundColor;if(c&&"rgba(0, 0, 0, 0)"!==c&&"transparent"!==c){const t=e.createStrokeSVG(c);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},zt="clepit-inline-status-styles",Ht='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',Ot=["info","success","warning","error","plain"],Pt={error:"statusError",info:"statusInfo",plain:"statusPlain",success:"statusSuccess",warning:"statusWarning"},Rt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(N.injectStyles(It,Tt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="status-dialog-title",e.textContent=this.word("inlineStatus","Inline status"),this.applyStyles(e,this.options.styles?.title),this.dialog.appendChild(e);const t=O("label","clepit-dialog-label");t.dataset.testid="status-dialog-text-label",t.textContent=this.word("statusLabelField","Label"),this.applyStyles(t,this.options.styles?.label),this.dialog.appendChild(t),this.textInput=O("input","clepit-dialog-input"),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.dataset.testid="status-dialog-text-input",this.textInput.placeholder=this.word("statusLabelPlaceholder","Status label"),this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const n=O("label","clepit-dialog-label");n.dataset.testid="status-dialog-variant-label",n.textContent=this.word("statusVariantField","Variant"),this.applyStyles(n,this.options.styles?.label),this.dialog.appendChild(n);const a=O("div","clepit-status-dialog-variants");for(const c of Ot){const e=O("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${c}`);e.type="button",e.dataset.variant=c,e.dataset.testid=`status-dialog-variant-${c}`,e.textContent=this.word(Pt[c],c),e.dataset.selected=String(c===this.variant),e.addEventListener("click",()=>{this.variant=c;for(const e of Array.from(a.children))e.dataset.selected=String(e.dataset.variant===c)}),a.appendChild(e)}this.dialog.appendChild(a);const o=O("div","clepit-dialog-buttons");this.applyStyles(o,this.options.styles?.buttons);const i=O("button","clepit-dialog-button clepit-dialog-button--cancel");i.type="button",i.dataset.testid="status-dialog-cancel",i.textContent=this.word("cancel","Cancel"),i.addEventListener("click",()=>this.handleCancel()),this.applyStyles(i,this.options.styles?.cancelButton),o.appendChild(i);const r=O("button","clepit-dialog-button clepit-dialog-button--save");r.type="button",r.dataset.testid="status-dialog-apply",r.textContent=this.word("apply","Apply"),r.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(r,this.options.styles?.saveButton),o.appendChild(r),this.dialog.appendChild(o),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const s=this.overlay;"function"==typeof s.showModal?s.showModal():s.style.display="flex";const l=document.querySelector(".clepit-toolbar");l&&(l.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},Ft="clepit-status",Ut=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a,o){N.injectStyles(zt,Ht);const i=t.toString().trim(),r=e.findStatusElement(t.commonAncestorContainer),s=r?r.textContent??i:i,l=r?e.readVariant(r):"info",c=t.cloneRange();new Rt({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(c))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(c),!t.trim())return void e.remove(c);if(e.unwrap(c),t!==i){c.deleteContents();const e=document.createTextNode(t);c.insertNode(e),c.selectNode(e)}const o=document.createElement("span");o.className=(e=>`${Ft} ${Ft}--${e}`)(n),o.dataset.statusVariant=n;try{c.surroundContents(o)}catch{const e=c.extractContents();o.appendChild(e),c.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:s||"status",variant:l}).show(),ss.updateStateFromRange(t)}static remove(t){e.unwrap(t),ss.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${Ft}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${Ft}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(Ft))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${Ft}--${n}`))return n;return"info"}},Vt=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static{this.shortcut=Ct("X")}static apply(e){N.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},Wt="clepit-tooltip-styles",Kt=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${N.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${N.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,Gt=class{constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(N.injectStyles(It,Tt),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="tooltip-dialog-title",e.textContent=this.word("insertTooltip","Insert Tooltip"),this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup(this.word("textField","Text"),this.word("textPlaceholder","Text"),this.options.text,"text","tooltip-dialog-text");this.inputText=t.querySelector("input");const n=this.createInputGroup(this.word("tooltipField","Tooltip"),this.word("tooltipPlaceholder","Tooltip text"),this.options.tooltip,"text","tooltip-dialog-tooltip");this.inputTooltip=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n,a,o){const i=O("div","clepit-dialog-group");this.applyStyles(i,this.options.styles?.group),this.applyClassNames(i,this.options.classNames?.group);const r=O("label","clepit-dialog-label");r.dataset.testid=`${o}-label`,r.textContent=e,this.applyStyles(r,this.options.styles?.label),this.applyClassNames(r,this.options.classNames?.label);const s=O("input","clepit-dialog-input");return s.type="url"===a?"url":"text",s.value=n,s.dataset.testid=`${o}-input`,s.placeholder=t,this.applyStyles(s,this.options.styles?.input),this.applyClassNames(s,this.options.classNames?.input),i.appendChild(r),i.appendChild(s),i}createButtonGroup(){const e=O("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=O("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="tooltip-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=O("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="tooltip-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},Jt=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static{this.shortcut=Ct("T")}static apply(t,n,a,o){N.injectStyles(Wt,Kt);const i=t.toString(),r=t.cloneRange();let s="",l=i;const c=e.findTooltipSpan(t.commonAncestorContainer);c&&(s=c.getAttribute("data-tooltip")||"",l=c.textContent||""),new Gt({classNames:n.classNames,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(r))},onConfirm:(t,o)=>{const i=window.getSelection();if(!i)return;if(i.removeAllRanges(),i.addRange(r),!o.trim())return e.remove(r),void(t!==l&&(r.deleteContents(),r.insertNode(document.createTextNode(t))));if(c){const e=c.parentElement;if(e){const t=document.createTextNode(c.textContent||"");e.insertBefore(t,c),e.removeChild(c),r.selectNode(t)}}if(t!==l){r.deleteContents();const e=document.createTextNode(t);r.insertNode(e),r.selectNode(e)}const s=N.createStyledElement("span",N.classNames.block.tooltip);s.setAttribute("data-tooltip",o),a.classNames&&N.applyClassNames(s,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);s.style.setProperty(n,String(t))}});try{r.surroundContents(s)}catch{const e=r.extractContents();s.appendChild(e),r.insertNode(s)}t!==l&&s.textContent!==t&&(s.textContent=t),me(s,o,"above",n.classNames,n.styles);const d=s.closest('[contenteditable="true"]');d&&d.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:l,tooltip:s}).show(),ss.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${N.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${N.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&N.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(me(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(N.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},Xt=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=At()}static apply(e){N.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},Zt=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],Yt=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Qt=["asana","github_issues","jira","linear"],en=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],tn=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],nn=["editView","previewView","jsonView","copyJson","downloadJson","clearEditor"],an=["insertLink","insertTooltip","inlineStatus","textField","urlField","tooltipField","statusLabelField","statusVariantField","urlPlaceholder","linkTextPlaceholder","textPlaceholder","tooltipPlaceholder","statusLabelPlaceholder","cancel","apply","statusInfo","statusSuccess","statusWarning","statusError","statusPlain"],on=["improve","shorten","lengthen","simplify","fix_grammar"],rn=()=>[Et,Lt,Xt,Vt,Nt,jt,Ut,_t,Jt],sn="inline-toolbar",ln=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.hideTimeoutMap=/* @__PURE__ */new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=c.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),N.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 8px;\n padding: 8px;\n box-shadow: var(--clepit-toolbar-shadow, 0 2px 8px rgba(0, 0, 0, 0.1));\n backdrop-filter: blur(8px);\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 0px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 14px;\n height: 14px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n transform: scale(1.05);\n}\n\n.clepit-toolbar-button:active {\n transform: scale(0.95);\n transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar-button.active {\n background: var(--clepit-toolbar-active-bg, var(--clepit-primary-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n font-weight: bold;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-bg);\n background-color: var(--clepit-text);\n padding: 6px 10px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-text);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), top 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=O("div","clepit-toolbar");o.id=`${t}-${sn}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),N.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=c.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);if(!e.getElementFromContainerId(t))return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t);const o=((n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${N.classNames.block.container}`))?.getAttribute("data-tool"),i=e.getFilteredTools(o,a.config);i.forEach(a=>e.addButton(t,a,n)),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const r=n.getBoundingClientRect(),s=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!s)return;const l=((e=!1,t=rn().length)=>({height:40,width:24*(t+(e?1:0))+16}))(Boolean(a.config.onInlineRewrite),i.length),d=r.left-s.left+r.width/2-l.width/2;let p=r.top-s.top-l.height-8;p<0&&(p=r.bottom-s.top+8),e.show(a.config.containerId,d,p)}static addRewriteButton(t,n){const a=c.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const i=e.getElementFromContainerId(t),r=document.getElementById(t);if(!i||!r)return;const s=O("button","clepit-toolbar-button",{type:"button"});s.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',s.setAttribute("data-tool","rewrite"),N.applyStyling(s,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const l=O("div","clepit-toolbar-rewrite-menu");l.style.display="none",l.setAttribute("data-rewrite-menu","true");for(const c of on){const t=O("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[c]??c,t.setAttribute("data-rewrite-action",c),e.addEventListener(r,t,"mousedown",e=>e.preventDefault()),e.addEventListener(r,t,"click",()=>{l.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,i=a.toString();i.trim()&&(s.classList.add("busy"),o(i,c).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),r.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(()=>{}).finally(()=>s.classList.remove("busy")))}),l.appendChild(t)}e.addEventListener(r,s,"mousedown",e=>e.preventDefault()),e.addEventListener(r,s,"click",()=>{l.style.display="none"===l.style.display?"flex":"none"}),i.appendChild(s),e.createTooltip(i,s,a.config.inlineRewriteTooltip??"rewrite"),i.appendChild(l)}static addButton(t,n,a){const o=c.getState().getInstance(t);if(!o)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const i=e.getElementFromContainerId(t);if(!i)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const r=O("button","clepit-toolbar-button",{type:"button"});r.innerHTML=n.icon,N.applyStyling(r,{classNames:o.config.classNames?.inlineToolbar?.button,styles:o.config.styles?.inlineToolbar?.button}),n.isActive(a)&&r.classList.add("active"),r.setAttribute("data-tool",n.label.toLowerCase());const s=document.getElementById(t);s&&(e.addEventListener(s,r,"mousedown",e=>e.preventDefault()),e.addEventListener(s,r,"click",()=>{try{const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,i=t&&!t.collapsed?t:a;if(i&&n.isActive(i))n.remove(i),r.classList.remove("active");else if(i){switch(n.label){case"italic":Lt.apply(i);break;case"bold":Et.apply(i);break;case"underline":Xt.apply(i);break;case"strikethrough":Vt.apply(i);break;case"inlineCode":Nt.apply(i,o.config.classNames?.blocks?.["inline-code"],o.config.styles?.blocks?.["inline-code"]);break;case"marker":jt.apply(i,o.config.classNames?.blocks?.marker,o.config.styles?.blocks?.marker);break;case"status":Ut.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs,o.config.dialogLabels);break;case"link":_t.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs,o.config.dialogLabels);break;case"tooltip":Jt.apply(i,{classNames:o.config.classNames?.tooltips,styles:o.config.styles?.tooltips},{classNames:o.config.classNames?.blocks?.tooltip,styles:o.config.styles?.blocks?.tooltip},o.config.dialogLabels)}r.classList.add("active")}}catch(e){console.warn("Error applying inline tool:",e)}})),i.appendChild(r),e.createTooltip(i,r,n.label)}static createTooltip(t,n,a){const o=O("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=O("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=O("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.querySelectorAll(".clepit-toolbar-button").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-tooltip").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-rewrite-menu").forEach(e=>e.remove())}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden"),o.classList.add("clepit-toolbar--visible"),o.classList.contains("clepit-toolbar--visible")){const e=parseFloat(o.style.left)||0,t=parseFloat(o.style.top)||0;(Math.abs(e-n)>1||Math.abs(t-a)>1)&&o.classList.add("clepit-toolbar--position-animation")}else o.classList.add("clepit-toolbar--show-animation");o.style.left=`${n}px`,o.style.top=`${a}px`,requestAnimationFrame(()=>{o.classList.add("clepit-toolbar--visible")})}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${sn}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=rn().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${sn}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},cn={},dn={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of cn[e]??[])n.removeEventListener(a,o,t);cn[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){dn.dismiss(e);const o=window.getSelection(),i=o?.rangeCount?o.getRangeAt(0):null;if(!i)return;i.deleteContents();const r=document.createTextNode(n);i.insertNode(r),i.setStartAfter(r),i.collapse(!0),o?.removeAllRanges(),o?.addRange(i);const s=document.getElementById(e);if(!s)return;const l=c.getState().getInstance(e)?.config,d=Pe[a.provider]??a.provider,p=document.createElement("div");p.className="clepit-embed-offer",p.setAttribute("data-testid","embed-offer"),p.setAttribute("data-embed-offer-for",e);const u=document.createElement("span");u.textContent=Re(l?.embedLabels,"offerShowLive",{tool:d}).replace(" · Show live",""),p.appendChild(u);const m=document.createElement("button");m.type="button",m.setAttribute("data-testid","embed-offer-accept"),m.textContent=Re(l?.embedLabels,"offerShowLive",{tool:d}).split(" · ").pop()??"Show live",p.appendChild(m);const h=i.getBoundingClientRect(),g=s.getBoundingClientRect();p.style.left=`${Math.max(0,h.left-g.left)}px`,p.style.top=h.bottom-g.top+6+"px",s.appendChild(p);const b=()=>{const a=t.getAttribute("data-id"),o=ss.getBlockIndex(e,a);dn.dismiss(e),-1!==o&&w(e,o,!0,n)},f=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void b();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&dn.dismiss(e)},y=t=>{p.contains(t.target)||dn.dismiss(e)};m.addEventListener("click",b),document.addEventListener("keydown",f,!0),document.addEventListener("mousedown",y),cn[e]=[{element:m,event:"click",handler:b},{capture:!0,element:document,event:"keydown",handler:f},{element:document,event:"mousedown",handler:y}]}},pn={},un={dismiss(e){for(const{element:t,event:n,handler:a}of pn[e]??[])t.removeEventListener(n,a);pn[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){un.dismiss(e),N.injectStyles(fe,ye);const n=document.getElementById(e);if(!n)return;const a=c.getState().getInstance(e)?.config,o=Te.read(t),i=Ce(o.tool),r=document.createElement("div");r.className="clepit-issue-menu",r.setAttribute("data-testid","issue-menu"),r.setAttribute("data-issue-menu-for",e);const s=Be(o,a?.issueLabels);if(s){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=s,r.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=we(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{un.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),r.appendChild(t)}}const l=document.createElement("a");l.href=o.url,l.target="_blank",l.rel="noopener noreferrer",l.setAttribute("data-testid","issue-open"),l.textContent=we(a?.issueLabels,"openInTool",{tool:i}),l.addEventListener("click",()=>un.dismiss(e)),r.appendChild(l);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=we(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{un.dismiss(e),un.showAsCard(e,t)}),r.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();r.style.left=`${Math.max(0,p.left-u.left)}px`,r.style.top=p.bottom-u.top+6+"px",n.appendChild(r);const m=t=>{"Escape"===t.key&&un.dismiss(e)},h=n=>{r.contains(n.target)||t.contains(n.target)||un.dismiss(e)};document.addEventListener("keydown",m),document.addEventListener("mousedown",h),pn[e]=[{element:document,event:"keydown",handler:m},{element:document,event:"mousedown",handler:h}]},showAsCard(e,t){const n=Te.read(t),a=t.closest(`.${N.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=ss.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};ss.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?ss.replaceBlock(e,i,s):(r&&ss.saveBlockData(r),ss.insertBlock(s,e,i+1))}},mn=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick))}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${N.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const i=c.getState().getInstance(o);return i?{instance:i,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${Se}`);if(a){if("edit"!==c.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void un.show(t.id,a)}const o=n.closest(`.${N.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=c.getState().getInstance(t.id);return void(n&&_t.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs,n.config.dialogLabels))}const i=n.closest(`.${N.classNames.block.tooltip}`);if(i){const e=document.createRange();e.selectNodeContents(i);const n=c.getState().getInstance(t.id);return void(n&&Jt.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip},n.config.dialogLabels))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView){try{ln.hide(a.instance.config.containerId)}catch{}return}if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();if(o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed)try{ln.repaint(a.instance.config.containerId,n)}catch{}else try{ln.hide(a.instance.config.containerId)}catch{}}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${N.classNames.block.container}`);if(!a)return;const o=a.closest(`.${N.classNames.editor.container}`);if(!o)return;const i=c.getState().getInstance(o.id)?.config,r=ut(i,t);if(!r)return;const s=a.getAttribute("data-id"),l=ss.getBlockIndex(o.id,s);if(-1===l)return;const d=ss.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==r.kind)if("embed"!==r.kind)if("image"===r.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:r.url},type:"image"};p?ss.replaceBlock(o.id,l,e):ss.insertBlock(e,o.id,l+1)}else{let e=r.url;r.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(r.url)||r.url:r.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(r.url)||r.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?ss.replaceBlock(o.id,l,t):ss.insertBlock(t,o.id,l+1)}else"offer"===(i?.pasteEmbeds??"live")?dn.show(o.id,a,t,r.embed):w(o.id,l,p,t);else it(o.id,0,l,p,t,r.issue)}},hn="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",gn=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:F(t.innerHTML),variant:n}}static render(t,n,a){N.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=N.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(t,"alertTextHint",e.placeholder)),i.html?r.innerHTML=i.html:r.innerHTML="",e.addEventListener(t,r,"keydown",ss.handleKeydown),e.addEventListener(t,r,"input",ss.handleInput),r}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i=t.innerHTML||"",r={html:i.trim()&&"<br>"!==i.trim()?i:"",variant:n},s={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},l=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,r,s);t.replaceWith(d),c.getState().updateBlockData(a,l,r)}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},bn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-alert-output-styles",hn),!e.validate(t))return V();if(gn.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.variant,s=N.createStyledElement("div",`clepit-output-alert clepit-output-alert--${r}`,{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=T){if(!e.validate(t)||gn.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},fn={icon:"!",get input(){return gn},label:"Alert",get output(){return bn},shortcut:Ct("A"),testId:"block-type-alert",type:"alert"},yn=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${N.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${N.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${N.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${N.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,vn="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",xn=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${N.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${N.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:F(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){N.injectStyles("clepit-audio-input-styles",yn);const i=a||{alt:"",caption:"",url:""},r=N.createStyledElement("div",N.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=N.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const l=N.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});l.classList.add("clepit-audio-caption-container");const c=N.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n.caption||"",e.addEventListener(o,c,"keydown",ss.handleKeydown),e.addEventListener(o,c,"input",ss.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="♪";const s=N.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const l=N.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});l.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=N.createStyledElement("button",`${N.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(l),i.appendChild(d);const p=a?c.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;me(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(r){console.error("Audio upload error:",r),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=N.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${N.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},kn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-audio-output-styles",vn),!e.validate(t))return V();if(xn.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=N.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":c.classList.add("clepit-output-audio-wrapper--left");break;case"center":c.classList.add("clepit-output-audio-wrapper--center");break;case"right":c.classList.add("clepit-output-audio-wrapper--right")}const d=O("audio","clepit-output-audio");if(d.src=i,d.controls=!0,d.preload="metadata",t.alt&&d.setAttribute("alt",t.alt),c.appendChild(d),l.appendChild(c),r){const e=N.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=T){if(!e.validate(t)||xn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},wn={icon:"♪",get input(){return xn},label:"Audio",get output(){return kn},shortcut:Ct("O"),testId:"block-type-audio",type:"audio"},Cn=`\n/* Checklist input block styles */\n.${N.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${N.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${N.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${N.classNames.block.checklist.text}::before,\n.${N.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${N.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${N.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${N.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${N.classNames.block.checklist.checkbox}::before,\n.${N.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${N.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${N.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${N.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${N.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,Sn='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',An=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${N.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${N.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:F(a.innerHTML)})}),{items:t}}static render(t,n,a){N.injectStyles("clepit-checklist-input-styles",Cn);const o={items:[]},i=n?{...o,...n}:o,r=N.createStyledElement("div",N.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=N.createStyledElement("div",N.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=N.createStyledElement("input",N.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=N.createStyledElement("div",N.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(a,"checklistItemHint",e.placeholder)),s.innerHTML=t.text?.trim()||"",e.addEventListener(a,r,"change",()=>ss.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,l=n.closest(`.${N.classNames.block.container}`);if(!l)return;const c=ss.getBlockIndex(a,l.getAttribute("data-id")),d=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&ss.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=ss.getBlocks(a);e&&c<e.length-1&&ss.moveBlock(a,c,c+1)}else if(d)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),ss.removeBlock(a,c)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),R(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;const o=ss.getBlockIndex(a,t.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(R(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${N.classNames.block.container}`);if(!e)return;const t=ss.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;ss.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{ss.ensureActiveBlock(a);const e=ss.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(c>0){const t=e[c-1];t&&ss.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${N.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(c<e.length-1){const t=e[c+1];t&&ss.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${N.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",ss.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${N.classNames.block.checklist.item}`)),n=t.filter(e=>R(e.querySelector(`.${N.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${N.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>R(e.querySelector(`.${N.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>R(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},En=class e{static render(t,n,a,o){if(N.injectStyles("clepit-checklist-output-styles",Sn),!e.validate(t))return V();if(An.isEmptyData(t))return document.createElement("div");const i=t.items,r=N.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=N.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=N.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=N.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});e.text&&e.text.trim()&&(s.innerHTML=e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=T){if(!e.validate(t)||An.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},Nn={icon:"☑",get input(){return An},label:"Checklist",get output(){return En},shortcut:Ct("K"),testId:"block-type-checklist",type:"checklist"},Ln={icon:"𝕔",get input(){return oe},label:"Code",get output(){return be},shortcut:Ct("C"),testId:"block-type-code",type:"code"},Bn="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",$n=`${Bn}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,In=Bn,Tn=/* @__PURE__ */new WeakMap;var Mn=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=Tn.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:F(n?.innerHTML),open:a}}static render(t,n,a){N.injectStyles("collapsible-input",$n);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=N.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,Tn.set(r,[...i.children??[]]);const s=document.createElement("summary"),l=document.createElement("span");l.className="clepit-collapsible__title",l.setAttribute("contenteditable","true"),l.setAttribute("data-placeholder",Y(t,"collapsibleTitleHint",e.placeholder)),i.html&&(l.innerHTML=F(i.html)),s.appendChild(l),r.appendChild(s);const c=document.createElement("div");return c.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{c.appendChild(e.renderChild(t,n))}),r.appendChild(c),e.addEventListener(t,l,"keydown",ss.handleKeydown),e.addEventListener(t,l,"input",ss.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=ss.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return R(n?.innerHTML)&&!a}static isEmptyData(e){return R(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},_n="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Dn=_n,qn=_n,jn=class e{static render(t,n,a,o){if(N.injectStyles("collection-output",qn),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},zn="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",Hn=`${zn}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,On=zn,Pn=class e{static render(t,n,a,o){if(N.injectStyles("columns-output",On),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=N.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=Zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=er(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},Rn="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",Fn=`${Rn}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,Un=Rn,Vn=/^(\d{4})-(\d{2})-(\d{2})$/;function Wn(e){const t=Vn.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var Kn=class e{static render(t,n,a,o){N.injectStyles("date-output",Un);const i=e.validate(t)?Wn(t.date):null;if(!i)return V();const r=N.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=T){const a=e.validate(t)?Wn(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},Gn='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',Jn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){N.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=N.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=N.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=N.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${N.classNames.block.container}`);if(!a)return;const o=ss.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&ss.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=ss.getBlocks(t);n&&o<n.length-1&&ss.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),ss.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),ss.removeBlock(t,o);else{ss.ensureActiveBlock(t);const a=ss.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&ss.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&ss.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i={variant:n},r={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Xn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-delimiter-output-styles",Gn),!e.validate(t))return V();if(Jn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=N.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=T){if(!e.validate(t)||Jn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},Zn="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",Yn=Zn,Qn=Zn,ea=class e{static render(t,n,a,o){if(N.injectStyles("doc-card-output",Qn),!e.validate(t))return V();const i=N.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),l=document.createElement("span");if(l.className="clepit-doc-card__title",l.textContent=t.title||"Untitled",s.appendChild(l),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},ta="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",na=`${ta}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,aa=ta;function oa(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var ia=class e{static render(t,n,a,o){if(N.injectStyles("file-output",aa),!e.validate(t))return V();const i=N.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=oa(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=oa(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},ra='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',sa="At a glance",la=class e{static render(t,n,a,o){if(N.injectStyles("clepit-glance-output-styles",ra),!e.validate(t))return V();if(0===t.rows.length)return document.createElement("div");const i=N.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=O("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:sa,i.appendChild(r);const s=O("dl","clepit-glance-rows");for(const e of t.rows){const t=O("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=O("dd","clepit-glance-value");n.innerHTML=F(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=T){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:sa),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},ca="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",da=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:F(t?.innerHTML),level:n}}static render(t,n,a){N.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=N.createStyledElement(r,N.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(t,"headerHint",e.placeholder)),i.html?s.innerHTML=i.html:s.innerHTML="",e.addEventListener(t,s,"keydown",ss.handleKeydown),e.addEventListener(t,s,"input",ss.handleInput),s}static changeLevel(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const i={html:t.innerHTML,level:n},r={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},pa=class e{static render(t,n,a,o){if(N.injectStyles("clepit-header-output-styles",ca),!e.validate(t))return V();if(da.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.level||"h1",s=N.createStyledElement(r,"clepit-output-header",{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=T){if(!e.validate(t)||da.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ua=`\n/* Image block styles */\n.${N.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${N.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${N.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${N.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${N.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n.clepit-image-refusal {\n display: flex;\n flex-direction: column;\n gap: 6px;\n align-items: center;\n margin: 16px 0;\n padding: 14px 12px;\n text-align: center;\n border: 1px dashed var(--clepit-border);\n border-radius: 8px;\n}\n\n.clepit-image-refusal-title {\n font-size: 14.5px;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\n.clepit-image-refusal-body {\n max-width: 44ch;\n font-size: 13px;\n line-height: 1.5;\n color: var(--clepit-text-muted);\n}\n\n.clepit-image-refusal-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n justify-content: center;\n}\n\n.clepit-image-refusal-action {\n display: inline-flex;\n align-items: center;\n height: 26px;\n padding: 0 10px;\n font-size: 12px;\n font-weight: 550;\n color: var(--clepit-bg);\n white-space: nowrap;\n text-decoration: none;\n background: var(--clepit-primary);\n border-radius: 6px;\n}\n\n.clepit-image-refusal-action:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-image-refusal-remove {\n display: inline-flex;\n align-items: center;\n height: 28px;\n padding: 0 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n color: var(--clepit-text);\n white-space: nowrap;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n\n.clepit-image-refusal-remove:hover {\n background: var(--clepit-block-highlight-bg);\n}\n\n/* Image delete button */\n.${N.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${N.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${N.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,ma="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",ha=class extends Error{constructor(e){super(e.title),this.notice=e,this.name="UploadRefusal"}},ga=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${N.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:F(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){N.injectStyles("clepit-image-input-styles",ua);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=N.createStyledElement("div",N.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=N.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const l=N.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});l.classList.add("clepit-image-caption-container");const c=N.createStyledElement("div",N.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n?.caption||"",e.addEventListener(o,c,"keydown",ss.handleKeydown),e.addEventListener(o,c,"input",ss.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.setAttribute("data-testid","image-drop"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="📷";const s=N.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text}),l=document.createElement("strong");l.setAttribute("data-testid","image-drop-title"),l.textContent=Y(a,"imageDropTitle","Drop an image here");const d=document.createElement("span");d.className="clepit-image-click-text",d.setAttribute("data-testid","image-drop-action"),d.textContent=Y(a,"imageDropAction","or click to select"),s.append(l,document.createElement("br"),d);const p=N.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});p.setAttribute("data-testid","image-drop-formats"),p.textContent=Y(a,"imageDropFormats","Supports JPEG, PNG, GIF, WebP, SVG, and other image formats");const u=N.createStyledElement("button",`${N.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});u.type="button",u.textContent="✕",u.setAttribute("data-testid","image-drop-delete");const m=Y(a,"delete","Delete block");u.setAttribute("aria-label",m),i.appendChild(r),i.appendChild(s),i.appendChild(p),i.appendChild(u);const h=c.getState().getInstance(a),g=h?.config.classNames?.tooltips,b=h?.config.styles?.tooltips;me(u,m,"below",g,b),e.addEventListener(a,u,"click",e=>{e.preventDefault(),e.stopPropagation();const t=u.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showInvalidType(n,o)}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showInvalidType(t,a)}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,i){e.showLoading(n,Y(o,"imageUploading","Uploading image..."));try{let r=await a(t);if(r){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showUploadFailed(n,o)}catch(r){if(r instanceof ha)return void e.showRefusal(n,o,r.notice);console.error("Image upload error:",r),e.showUploadFailed(n,o)}}static showRefusal(t,n,a){t.innerHTML="";const o=N.createStyledElement("div","clepit-image-refusal",void 0);o.setAttribute("data-testid","image-refusal"),o.setAttribute("role","status");const i=document.createElement("span");i.className="clepit-image-refusal-title",i.setAttribute("data-testid","image-refusal-title"),i.textContent=a.title;const r=document.createElement("span");r.className="clepit-image-refusal-body",r.setAttribute("data-testid","image-refusal-body"),r.textContent=a.body;const s=document.createElement("span");if(s.className="clepit-image-refusal-actions",a.action&&/^https?:\/\//i.test(a.action.href)){const e=document.createElement("a");e.className="clepit-image-refusal-action",e.setAttribute("data-testid","image-refusal-action"),e.setAttribute("href",a.action.href),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"),e.textContent=a.action.label,s.appendChild(e)}const l=document.createElement("button");l.type="button",l.className="clepit-image-refusal-remove",l.setAttribute("data-testid","image-refusal-remove"),l.textContent=a.remove,e.addEventListener(n,l,"click",e=>{e.preventDefault(),e.stopPropagation();const t=l.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(n,ss.getBlockIndex(n,t))}),s.appendChild(l),o.append(i,r,s),t.appendChild(o)}static showLoading(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-image-loading",void 0);n.setAttribute("data-testid","image-uploading"),n.textContent=t,e.appendChild(n)}static showUploadFailed(t,n){e.showError(t,Y(n,"imageUploadFailed","Failed to upload image. Please try again."),"image-upload-failed")}static showInvalidType(t,n){e.showError(t,Y(n,"imageInvalidType","Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)"),"image-invalid-type")}static showError(e,t,n){e.innerHTML="";const a=N.createStyledElement("div","clepit-image-error",void 0);a.setAttribute("data-testid",n),a.textContent=t,e.appendChild(a)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.image.wrapper} img`),n=e.querySelector(`.${N.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ba=class e{static render(t,n,a,o){if(N.injectStyles("clepit-image-output-styles",ma),!e.validate(t))return V();if(ga.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",l=N.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":c.classList.add("clepit-output-image-wrapper--left");break;case"center":c.classList.add("clepit-output-image-wrapper--center");break;case"right":c.classList.add("clepit-output-image-wrapper--right")}const d=O("img","clepit-output-image");if(d.src=i,d.alt=s,c.appendChild(d),l.appendChild(c),r){const e=N.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}return l}static draw(t,n=T){if(!e.validate(t)||ga.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},fa=ye,ya=ye,va=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)va(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))va(e,t)}}else e.includes("clepit-issue")&&t.push(...qe(e))},xa=class e{static collect(e,t){const n=[];va(e??[],n);const a=/* @__PURE__ */new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){N.injectStyles("issues-output",ya);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=N.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=we(n?.issueLabels,"linkedIssuesEmpty"),e}const r=H(e.table(i,T,n?.issueLabels));return N.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=T,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText(we(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText($e(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||we(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},ka="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",wa=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(F(e.innerHTML))),{items:a,type:n}}static render(t,n,a){N.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=N.createStyledElement(r,N.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const l=a?.classNames?.[i.type]?.item,c=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,l,c)):e.createAndAppendListItem("",s,t,l,c),s}static createAndAppendListItem(t,n,a,o,i){const r=N.createStyledElement("li",N.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=t,r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(a,"listItemHint",e.placeholder)),e.addEventListener(a,r,"keydown",t=>{const s=t,l=n.closest(`.${N.classNames.block.container}`);if(!l)return;const c=ss.getBlockIndex(a,l.getAttribute("data-id")),d=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&ss.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=ss.getBlocks(a);e&&c<e.length-1&&ss.moveBlock(a,c,c+1)}else if(d)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),ss.removeBlock(a,c)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),R(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;const o=ss.getBlockIndex(a,t.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(R(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${N.classNames.block.container}`);if(!e)return;const t=ss.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;ss.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{ss.ensureActiveBlock(a);const e=ss.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${N.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(c>0){const t=e[c-1];t&&ss.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${N.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(c<e.length-1){const t=e[c+1];t&&ss.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",ss.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const i={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},r={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>R(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${N.classNames.block.list.item}`);return!t||Array.from(t).every(e=>R(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>R(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ca=class e{static render(t,n,a,o){if(N.injectStyles("clepit-list-output-styles",ka),!e.validate(t))return V();if(wa.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=N.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=e,i=N.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n&&n.trim()&&(i.innerHTML=n),s.appendChild(i)}),s}static draw(t,n=T){if(!e.validate(t)||wa.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},Sa="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav — approved 2026-08-06\n * (direction 2B, \"Eyebrow\"). */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen — approved 2026-08-06 (direction 1B, \"Panel\"). */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip — approved 2026-08-06\n * (direction 1B, \"Tabbed\"). */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",Aa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ea=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!Aa(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=Ea(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>Ea(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=Ea(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!Aa(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=Ea(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},Na=(e,t)=>Ea(e,{schemas:t,stack:/* @__PURE__ */new Set}),La=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ba=e=>{if(!La(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},$a=e=>{if(!La(e)||!La(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=Ba(a);return t},Ia=e=>e.security[0],Ta=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},Ma={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${Ta(e,t)}"`],a=Ia(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=$a(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=$a(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${Ta(e,t)}'),`],i=[],r=Ia(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=$a(e.request),a=e.method.toLowerCase(),o=[` "${Ta(e,t)}",`],i=Ia(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=$a(e.request),a=[],o=Ia(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${Ta(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},_a=["bash","typescript","dart","python"],Da=["get","post","put","patch","delete"],qa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ja=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),za=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),Ha=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(qa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),Oa=e=>qa(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=qa(t)?t:{},a=qa(n.content)?n.content:void 0,o=a&&qa(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],Pa=e=>{if(!qa(e.requestBody))return;const t=qa(e.requestBody.content)?e.requestBody.content:void 0;return(t&&qa(t["application/json"])?t["application/json"]:void 0)?.schema},Ra=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(qa);return t?Object.keys(t):[]},Fa=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(qa);return"string"==typeof t?.url?t.url:void 0},Ua=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",Va=(e,t)=>{const n=qa(e)?e:{},a=qa(n.info)?n.info:{},o=qa(n.components)?n.components:{},i={groups:[],schemas:qa(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(qa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=qa(n.paths)?n.paths:{},s=/* @__PURE__ */new Map;for(const[l,c]of Object.entries(r))if(qa(c))for(const e of Da){const n=c[e];if(!qa(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(za(t.exclude,a,l))continue;if(t.include&&!i&&!za(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:ja(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:Ha(n),path:l,...void 0===Pa(n)?{}:{request:Pa(n)},responses:Oa(n),security:Ra(n),...void 0===Fa(n)?{}:{server:Fa(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=Ua(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:ja(d),operations:[r],title:d})}return i.groups=[...s.values()],i},Wa=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},Ka=(e,t)=>{const n=Wa(e,"div","clepit-openapi-table-scroll");return n.append(t),n},Ga=(e,t,n,a)=>{const o=Wa(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},Ja=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},Xa=(e,t=0)=>t>6?Ja(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,Xa(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,Xa(e,t+1)])):Ja(e),Za=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},Ya=(e,t,n,a)=>{const o=Wa(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=Wa(e,"div","clepit-openapi-operation-head"),s=Wa(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=Wa(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=Wa(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=Wa(e,"div","clepit-openapi-operation-body"),d=Wa(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(Wa(e,"p","clepit-openapi-description",t.description));const p=Wa(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(Wa(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(Wa(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=Wa(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(Wa(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=Wa(e,"td","clepit-openapi-name",i.name);i.required&&o.append(Wa(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(Wa(e,"td","clepit-openapi-cell",i.in)),t.append(Wa(e,"td","clepit-openapi-type",Ja(Na(i.schema,n.schemas)))),t.append(Wa(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(Ga(e,"Parameters","parameters",t.id)),c.append(Ka(e,u))),void 0!==t.request){const a=Na(t.request,n.schemas);if(a.children.length>0){c.append(Ga(e,"Body","body",t.id));const n=Wa(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=be.draw({code:JSON.stringify(Xa(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(Ga(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=Wa(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=Wa(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=Wa(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=Wa(e,"p","clepit-openapi-response-description");if(r){const t=Wa(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",Za(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=Na(a.schema,n.schemas);if(t.children.length>0){const n=be.draw({code:JSON.stringify(Xa(t),null,2),language:"json",showCopy:!0},e);n&&l.append(n)}}i.push(l);const d=Wa(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",Za(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const m=((e,t,n)=>n.flatMap(n=>{const a=Ma[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??_a);if(m.length>0){c.append(Ga(e,"Try it","try-it",t.id));const n=be.draw({code:m[0].code,language:m[0].language,showCopy:!0,syncKey:"api-reference",variants:m},e);n&&c.append(n)}return o.append(c),o},Qa=class e{static draw(t,n=T){if(!e.validate(t))return null;const a=Va(t.spec,t),o=Wa(n,"div","clepit-openapi");if(a.servers.length>0){const e=Wa(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(Wa(n,"th","clepit-openapi-th","Host")),t.append(Wa(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(Wa(n,"td","clepit-openapi-name",o.url)),t.append(Wa(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(Ka(n,e))}for(const e of a.groups){const i=Wa(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=Wa(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(Ya(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(N.injectStyles("clepit-openapi-output-styles",Sa),!e.validate(t))return V();const i=H(e.draw(t,T));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])be.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(be.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const a of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...a.querySelectorAll(".clepit-openapi-response-tab")],t=[...a.querySelectorAll(".clepit-openapi-response")],o=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n})};e.forEach((t,a)=>{n(t,"click",()=>o(a)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(a+i+e.length)%e.length;-1!==r&&(t.preventDefault(),o(r),e[r]?.focus())})})}return()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},eo="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",to=class e{static{this.placeholder="Start writing..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:F(e.querySelector(`.${N.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){N.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=N.createStyledElement("div",N.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",c.getState().getInstance(t)?.config.placeholder||e.placeholder),o.innerHTML=n?.html||"",e.addEventListener(t,o,"keydown",ss.handleKeydown),e.addEventListener(t,o,"input",ss.handleInput),o}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},no=class e{static render(t,n,a,o){if(N.injectStyles("clepit-paragraph-output-styles",eo),!e.validate(t))return V();const i=N.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});if(to.isEmptyData(t))return i.appendChild(document.createElement("br")),i;const r=t.html;return r&&(i.innerHTML=r),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),to.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ao=`\n/* Quote block styles */\n.${N.classNames.block.quote.container} {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${N.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${N.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${N.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${N.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${N.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${N.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${N.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${N.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,oo="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",io=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.quote.text}`),n=e.querySelector(`.${N.classNames.block.quote.author}`);return{author:F(n?.innerHTML),html:F(t?.innerHTML)}}static render(t,n,a){N.injectStyles("clepit-quote-input-styles",ao);const o=n||{author:"",html:""},i=N.createStyledElement("div",N.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=N.createStyledElement("div",N.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=N.createStyledElement("div",N.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=o.html||"",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(t,"quoteBodyHint",e.placeholder)),s.innerHTML=o.author||"",s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(t,"quoteAuthorHint",e.authorPlaceholder)),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",ss.handleInput),i.appendChild(r),o.author){const e=N.createStyledElement("div",N.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${N.classNames.block.container}`),o=ss.getEditorId(a);if(!o)return;const i=ss.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${N.classNames.block.quote.text}`),s=a.querySelector(`.${N.classNames.block.quote.author}`),l=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&ss.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=ss.getBlocks(o);t&&i<t.length-1&&ss.moveBlock(o,i,i+1)}else if(l)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),ss.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!R(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?ss.removeBlock(o,i):n===s&&(R(r.innerHTML)?ss.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&ss.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&ss.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${N.classNames.block.container}`),o=ss.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${N.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=ss.getBlockIndex(o,a.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.quote.text}`),n=e.querySelector(`.${N.classNames.block.quote.author}`);let a=!1,o=!1;return t?R(t.innerHTML)&&(a=!0):a=!0,n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return R(e.html)&&R(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ro=class e{static render(t,n,a,o){if(N.injectStyles("clepit-quote-output-styles",oo),!e.validate(t))return V();if(io.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.author||"",s=N.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),l=N.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=O("div","clepit-output-quote-content");if(i&&i.trim()&&(c.innerHTML=i),l.appendChild(c),s.appendChild(l),r){const e=N.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});s.appendChild(e);const t=N.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${r}`,s.appendChild(t)}return s.querySelectorAll(`span.${N.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(me(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),s}static draw(t,n=T){if(!e.validate(t)||io.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},so="\n.clepit-sketch {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",lo=so,co=so,po="http://www.w3.org/2000/svg";function uo(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function mo(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var ho=class e{static render(t,n,a,o){if(N.injectStyles("sketch-output",co),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(po,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=mo(s.points??[]);if(!t)continue;const n=document.createElementNS(po,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",uo(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(po,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=mo(i.points??[]);if(!t)continue;const a=n.createNS(po,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",uo(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},go=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: 8px;\n border: 1px solid var(--clepit-border);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${N.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${N.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${N.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${N.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${N.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${N.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${N.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${N.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${N.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Row handle cell */\n.clepit-table-row-handle {\n position: absolute;\n left: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-handle {\n position: absolute;\n top: -22px;\n left: 50%;\n transform: translateX(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-row-delete {\n position: absolute;\n right: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-delete {\n right: -22px;\n top: calc(50% + 18px);\n transform: translateY(-50%);\n}\n\n/* Show handles on hover/active */\n.clepit-table-row:hover .clepit-row-handle,\n.${N.classNames.block.table.headerCell}:hover .clepit-col-handle,\n.clepit-table-row:hover .clepit-row-delete,\n.${N.classNames.block.table.headerCell}:hover .clepit-col-delete {\n display: flex;\n}\n\n/* Hover/active states like toolbar buttons */\n.clepit-row-handle:hover, .clepit-col-handle:hover,\n.clepit-row-delete:hover, .clepit-col-delete:hover {\n color: var(--clepit-primary);\n}\n\n/* Table menu buttons */\n.clepit-table-row-menu-btn,\n.clepit-table-col-menu-btn {\n position: absolute;\n background: var(--clepit-bg);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 4px 8px;\n font-size: 12px;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 1002;\n}\n\n.clepit-table-row-menu-btn:hover,\n.clepit-table-col-menu-btn:hover {\n color: var(--clepit-primary);\n background: var(--clepit-bg);\n border-color: var(--clepit-border);\n}\n\n.clepit-table-row-menu-btn--visible,\n.clepit-table-col-menu-btn--visible {\n display: flex;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,bo="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n overflow: hidden;\n background: var(--clepit-bg);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border-radius: 4px;\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-top: none;\n border-radius: 0 0 8px 8px;\n}\n",fo=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${N.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-col-handle, .clepit-col-delete").forEach(e=>e.remove()),r.push(F(t.innerHTML))}i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),n=[];for(const e of t){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-row-handle, .clepit-row-delete").forEach(e=>e.remove()),n.push(F(t.innerHTML))}i.push(n)}const l=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:F(t.querySelector(`.${N.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:l}}static render(t,n,a){N.injectStyles("clepit-table-input-styles",go);const o=n?{...e.defaultData,...n}:e.defaultData,i=N.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=N.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),s=N.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),l=e.createRow(t,o.data[0],!0);s.appendChild(l),r.appendChild(s);const d=N.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let c=1;c<o.data.length;c++){const n=e.createRow(t,o.data[c]);d.appendChild(n)}r.appendChild(d);const p=N.createStyledElement("div","clepit-table-scroll-container");p.appendChild(r),i.appendChild(p);const u=N.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",i.appendChild(u);const m=N.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});m.style.position="absolute",m.style.display="none",m.style.zIndex="1000",m.textContent="⋯",i.appendChild(m);let h=null,g=-1,b=null;e.addEventListener(t,i,"mouseleave",()=>(u.style.display="none",m.style.display="none",void(b&&(b.remove(),b=null))));const f=e=>{h=e;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(g=Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)).indexOf(e),g<0)return;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;m.style.left=`${a}px`,m.style.top=`${Math.max(4,o)}px`,m.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&f(t)}),e.addEventListener(t,s,"mouseover",e=>{const t=e.target.closest(`.${N.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${N.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)[a];e&&y(e)}f(n)});const v=()=>{h&&"none"!==u.style.display&&f(h);const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)[g];e&&"none"!==m.style.display&&y(e)};e.addEventListener(t,window,"scroll",v,{passive:!0}),e.addEventListener(t,p,"scroll",v,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!h)return;const o=Array.from(d.querySelectorAll("tr")),r=o.indexOf(h),s=u.getBoundingClientRect(),c=i.getBoundingClientRect();e.createMenu(t,i,u,m,[{label:"Move up",onClick:()=>{r>0&&(d.insertBefore(h,o[r-1]),ss.saveBlockData(h))},shortcut:ft("up")},{label:"Move down",onClick:()=>{r>=0&&r<o.length-1&&(d.insertBefore(o[r+1],h),ss.saveBlockData(h))},shortcut:ft("down")},{label:"Insert above",onClick:()=>{const n=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,h),ss.saveBlockData(h)},shortcut:St("up")},{label:"Insert below",onClick:()=>{const n=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));h.nextSibling?d.insertBefore(a,h.nextSibling):d.appendChild(a),ss.saveBlockData(h)},shortcut:St("down")},{label:"Delete",onClick:()=>{o.length>1&&(h.remove(),ss.saveBlockData(h))},shortcut:vt()}],s.left-c.left,s.bottom-c.top+4,a,b)}),e.addEventListener(t,m,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),g<0)return;const o=Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)),r=m.getBoundingClientRect(),s=i.getBoundingClientRect();e.createMenu(t,i,u,m,[{label:"Move left",onClick:()=>{if(g<=0)return;const e=g,t=o[e-1],n=o[e];t&&n&&l.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),g=e-1,ss.saveBlockData(l)},shortcut:ft("left")},{label:"Move right",onClick:()=>{const e=g;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&l.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),g=e+1,ss.saveBlockData(l)},shortcut:ft("right")},{label:"Insert left",onClick:()=>{const n=g,a=e.createHeaderCell(t,"");l.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${N.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),ss.saveBlockData(l)},shortcut:St("left")},{label:"Insert right",onClick:()=>{const n=g+1,a=o[g]?.nextSibling||null,i=e.createHeaderCell(t,"");l.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${N.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),ss.saveBlockData(l)},shortcut:St("right")},{label:"Delete",onClick:()=>{const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`);if(g<0||e.length<=1)return;const t=e[g];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${N.classNames.block.table.cell}`);t[g]&&t[g].parentElement?.removeChild(t[g])}),ss.saveBlockData(l)},shortcut:xt()}],r.left-s.left,r.bottom-s.top+4,a,b)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>f(n))})(n)),Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const x=N.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});x.style.display="flex",x.style.alignItems="center",x.style.gap="8px",x.style.marginTop="8px";const k=N.createStyledElement("div",`${N.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});k.contentEditable="true",k.setAttribute("tabindex","0"),k.setAttribute("data-placeholder",Y(t,"tableCaptionHint",e.captionPlaceholder)),k.style.flex="1",k.style.minWidth="0",k.innerHTML=F(o.caption),e.addEventListener(t,k,"input",ss.handleInput),e.addEventListener(t,k,"keydown",e.handleKeydown),e.addEventListener(t,k,"click",e.handleClick),x.appendChild(k);const w=N.createStyledElement("div",`${N.classNames.block.table.downloadSwitch}`);w.style.flexShrink="0";const C=ae.create({checked:o.showDownload||!1,label:"Allow download",onToggle:e=>{const n=i.closest(`.${N.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&c.getState().partialUpdateBlockData(t,ss.getBlockIndex(t,a),{showDownload:e})}}});w.appendChild(C),x.appendChild(w),i.appendChild(x);return e.addEventListener(t,i,"focusin",()=>{const e=document.activeElement;if(e&&i.contains(e))if(e.classList.contains(N.classNames.block.table.cell)){const t=e.closest("tr");t&&(h=t,f(t))}else e.classList.contains(N.classNames.block.table.headerCell)&&y(e)}),i}static createRow(t,n,a){const o=c.getState().getInstance(t),i=o?.config.classNames?.blocks?.table?.row,r=o?.config.styles?.blocks?.table?.row,s=N.createStyledElement("tr",a?`${N.classNames.block.table.headerRow}`:`${N.classNames.block.table.row}`,{classNames:i,styles:r});for(let l=0;l<n.length;l++)s.appendChild(a?e.createHeaderCell(t,n[l]):e.createCell(t,n[l]));return s.querySelector(`.${N.classNames.block.table.cell}`)?.focus(),s}static createCell(t,n){const a=c.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,i=a?.config.styles?.blocks?.table?.cell,r=N.createStyledElement("td",`${N.classNames.block.table.cell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",Y(t,"tableCellHint",e.cellPlaceholder)),r.innerHTML=F(n),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static createHeaderCell(t,n){const a=c.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,i=a?.config.styles?.blocks?.table?.header,r=N.createStyledElement("th",`${N.classNames.block.table.headerCell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",Y(t,"tableHeaderHint",e.headerPlaceholder)),r.innerHTML=F(n),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=ss.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=ss.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,l,c){c&&(c.remove(),c=null);const d=N.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:l?.classNames?.menu,styles:l?.styles?.menu});d.classList.add("clepit-block-operations-menu--visible"),d.style.position="absolute",d.style.zIndex="20",d.style.left=`${r}px`,d.style.top=`${s}px`,d.style.minWidth="180px",i.forEach(n=>{const a="delete"===n.label.toLowerCase(),o=N.createStyledElement("div","clepit-menu-item"+(a?" clepit-menu-item--danger":""),{classNames:l?.classNames?.menuItem,styles:l?.styles?.menuItem});o.style.fontSize="14px";const i=N.createStyledElement("span","clepit-menu-icon"),r=n.label.toLowerCase();r.includes("move up")?i.textContent="↑":r.includes("move down")?i.textContent="↓":r.includes("move left")?i.textContent="←":r.includes("move right")?i.textContent="→":r.includes("insert")?i.textContent="+":r.includes("delete")?i.textContent="×":i.textContent="•";const s=N.createStyledElement("span","clepit-menu-text");if(s.textContent=n.label,o.appendChild(i),o.appendChild(s),n.shortcut){const e=N.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,o.appendChild(e)}e.addEventListener(t,o,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),c&&(c.remove(),c=null)}),d.appendChild(o)}),n.appendChild(d),c=d;const p=e=>{d.contains(e.target)||e.target===a||e.target===o||(d.remove(),c=null,document.removeEventListener("click",p))};return setTimeout(()=>document.addEventListener("click",p),0),d}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${N.classNames.block.container}`);t&&ss.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=ss.getEditorId(n);if(!a)return;const o=n.closest(`.${N.classNames.block.container}`);if(!o)return;const i=ss.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&ss.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=ss.getBlocks(a);t&&i<t.length-1&&ss.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),ss.saveBlockData(t);const i=t.querySelectorAll(`.${N.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),ss.saveBlockData(t);const i=t.querySelectorAll(`.${N.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const l=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))t=l.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=l[a-1],r=l[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${N.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}ss.saveBlockData(s)}break;case"ArrowRight":let c=-1;const d=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))c=d.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");c=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(c<d.length-1){e.preventDefault(),e.stopPropagation();const t=c,a=d[t],i=d[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${N.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}ss.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),ss.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i);break;case"Delete":let p=-1;const u=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))p=u.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");p=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(p>=0&&u.length>1){e.preventDefault(),e.stopPropagation();const t=u[p];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${N.classNames.block.table.cell}`);t[p]&&t[p].parentElement?.removeChild(t[p])}),ss.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell},.${N.classNames.block.table.headerCell}`)).every(e=>R(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i))}else{ss.ensureActiveBlock(a);const o=ss.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(N.classNames.block.table.caption)){const e=n.closest(`.${N.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&ss.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(N.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&ss.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const l=n.closest("tr"),c=Array.from(l?.cells||[]).indexOf(n);if("THEAD"===l?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[c])return void e.cells[c].focus()}if(l?.nextElementSibling){const e=l.nextElementSibling.cells[c];e&&e.focus()}else{if("TBODY"===l?.parentElement?.tagName&&l===l.parentElement.lastElementChild){const e=s.closest(`.${N.classNames.block.container}`)?.querySelector(`.${N.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&ss.focusBlock(e)}}return;case"ArrowLeft":if(!U(n,"left"))return;e.preventDefault(),e.stopPropagation();const d=n.closest("table");if(!d)return;const p=n.closest("tr"),u=Array.from(p?.cells||[]).indexOf(n);if(u>0){const e=p?.cells[u-1];e&&e.focus()}else{if("TBODY"===p?.parentElement?.tagName&&p===p.parentElement.firstElementChild){const e=d.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(p?.previousElementSibling){const e=p.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!U(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const h=n.closest("tr"),g=Array.from(h?.cells||[]).indexOf(n);if(g<(h?.cells.length||0)-1){const e=h?.cells[g+1];e&&e.focus()}else{if("THEAD"===h?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(h?.nextElementSibling){const e=h.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.table.caption}`),n=e.querySelectorAll(`.${N.classNames.block.table.cell},.${N.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?R(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>R(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return R(e.caption)&&e.data.every(e=>e.every(e=>R(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},yo="http://www.w3.org/2000/svg",vo=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],xo=/^[=+@\t\r-]/,ko=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static render(t,n,a,o,i){if(N.injectStyles("clepit-table-output-styles",bo),!e.validate(t))return V();if(fo.isEmptyData(t))return document.createElement("div");const r=e.draw(t,T);if(!r)return document.createElement("div");const s=H(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const l=s.querySelector(".clepit-output-table-caption");l&&o?.caption&&l.classList.add(o.caption),l&&a?.caption&&Object.assign(l.style,a.caption);const c=s.querySelector(".clepit-output-table-footer-container");return c&&o?.footerContainer&&c.classList.add(o.footerContainer),c&&a?.footerContainer&&Object.assign(c.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||fo.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,i){const r=t.querySelector(".clepit-output-table-download-btn");if(!r)return()=>{};o?.downloadButton&&r.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(r.style,a.downloadButton);const s=()=>e.downloadTableAsCSV(n);r.addEventListener("click",s);const l=i?document.getElementById(i):null;if(l){const t=e.eventListenersMap.get(l)??[];t.push({element:r,event:"click",handler:s}),e.eventListenersMap.set(l,t)}const d=i?c.getState().getInstance(i):null,p=me(r,"Download CSV","above",d?.config.classNames?.tooltips,d?.config.styles?.tooltips);return()=>{r.removeEventListener("click",s),p()}}static draw(t,n=T){if(!e.validate(t)||fo.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(yo,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of vo){const a=e.createNS(yo,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>xo.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},wo="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",Co=wo,So=wo,Ao={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},Eo=class{static render(e,t,n,a){N.injectStyles("toc-output",So);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=N.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents — headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=N.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=Ao[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=F(o.html),i.appendChild(r)}),i}static draw(e,t=T,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*Ao[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},No="\n.clepit-typeset {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",Lo=No,Bo=No,$o=.55,Io=.52,To=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function Mo(e,t=18){switch(e.kind){case"atom":return _o(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=Mo(r,t);n.push(...To(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=Mo(e.base,t),a=Do(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=Mo(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...To(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=Mo(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...To(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=Mo(e.numerator,t),a=Mo(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...To(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...To(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=Mo(e.radicand,t),a=.6*t,o=null===e.index?null:Mo(e.index,Do(Do(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...To(n,i+.12*t,0)];null!==o&&s.push(...To(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=_o(e.symbol,"upright",n),o=Do(t),i=null===e.upper?null:Mo(e.upper,o),r=null===e.lower?null:Mo(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...To(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...To(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...To(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=Mo(e.base,t),a=_o(e.over,"upright",Do(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...To(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=Mo(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:_o(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:_o(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...To(i,0,s(i)),...To(n,i.width,0),...To(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>Mo(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let v=0;v<a;v+=1)o.push(Math.max(...n.map(e=>e[v]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[v,x]of n.entries()){u+=i[v]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...To(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[v]??0)+l}const[m,h]=qo[e.style],g=Math.max(t,.62*d),b=""===m?{depth:0,draw:[],height:0,width:0}:_o(m,"upright",g),f=""===h?{depth:0,draw:[],height:0,width:0}:_o(h,"upright",g),y=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...To(b,0,y(b)),...p.map(e=>({...e,x:e.x+b.width})),...To(f,b.width+c,y(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function _o(e,t,n){const a="italic"===t?$o:Io;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function Do(e){return Math.max(9,.7*e)}var qo={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var jo={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},zo={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},Ho={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},Oo=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],Po={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},Ro={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},Fo={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},Uo=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],Vo={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},Wo=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,Ko=/[A-Za-z]/,Go=/[0-9]/,Jo={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},Xo=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!Ko.test(this.peek()))return this.take();let e="";for(;Ko.test(this.peek());)e+=this.take();return e}},Zo=class extends Error{};function Yo(e){const t=new Xo(e);try{const e=Qo(t,null);if(ti(t))throw new Zo("a \\right appears without a matching \\left");if(!t.done)throw new Zo(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof Zo)return{ok:!1,reason:n.message};throw n}}function Qo(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!ei(e)&&!ni(e))&&!ti(e);){const t=ai(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function ei(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function ti(e){return!!e.source.startsWith("\\right",e.at)&&!Ko.test(e.peek(6))}function ni(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function ai(e){const t=oi(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=oi(e);if(null===o)throw new Zo(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new Zo("a term carries two superscripts");a=o}else{if(null!==n)throw new Zo("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function oi(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=Qo(e,"}");if("}"!==e.peek())throw new Zo("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if(Uo.includes(t))throw new Zo(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new Zo("a row break appears outside a matrix");if("begin"===t)return function(e){const t=ri(e),n=Vo[t];if(void 0===n)throw new Zo(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(Qo(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!ei(e)){if(ni(e)){e.at+=4;const i=ri(e);if(i!==t)throw new Zo(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new Zo(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new Zo(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new Zo("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=ii(e);return{denominator:ii(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=Qo(e,"]"),"]"!==e.peek())throw new Zo("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:ii(e)}}(e);if("left"===t)return function(e){const t=si(e,"left"),n=Qo(e,null);if(!ti(e))throw new Zo("a \\left has no matching \\right");return e.at+=6,{body:n,close:si(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new Zo("a \\right appears without a matching \\left");const n=Jo[t];if(void 0!==n)return{kind:"atom",style:n,text:ri(e)};const a=Po[t];if(void 0!==a)return{base:ii(e),kind:"accent",over:a};if("overline"===t)return{base:ii(e),kind:"accent",over:"‾"};if("underline"===t)return{base:ii(e),kind:"accent",over:"_"};const o=Ho[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=jo[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=zo[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(Oo.includes(t))return{kind:"atom",style:"upright",text:t};const s=Ro[t];if(void 0!==s)return{kind:"space",width:s};const l=Fo[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new Zo(`"\\${t}" is not supported yet`)}(e);if(Wo.test(t))return e.take(),{kind:"atom",style:Go.test(t)?"upright":"italic",text:t};throw new Zo(`"${t}" is not a character this engine understands`)}function ii(e){if(e.skipSpace(),"{"!==e.peek()){const t=oi(e);if(null===t)throw new Zo("a command is missing its argument");return t}e.take();const t=Qo(e,"}");if("}"!==e.peek())throw new Zo("a { group is never closed");return e.take(),t}function ri(e){if(e.skipSpace(),"{"!==e.peek())throw new Zo("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new Zo("a text command’s { group is never closed")}function si(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=Fo[`\\${t}`];if(void 0===n)throw new Zo(`"\\${t}" is not a delimiter this engine understands`);return n}const a=Fo[n];if(void 0===a)throw new Zo(`\\${t} is missing a delimiter`);return e.take(),a}var li={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function ci(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function di(e,t=T){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=ci("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=li[r.style],n=ci("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(pi(r,o,t)):i.append(ci("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function pi(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return ci("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var ui=72,mi=40,hi=28,gi=16;function bi(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=/* @__PURE__ */new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=/* @__PURE__ */new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=/* @__PURE__ */new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=/* @__PURE__ */new Map;for(const b of e.nodes)o.set(b.id,fi(b.label,ui));const i=/* @__PURE__ */new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*mi+(e.length-1)*hi:e.reduce((e,t)=>e+(o.get(t)??ui),0)+(e.length-1)*hi,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=gi+b*((t?ui:mi)+64);let c=gi+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??ui;i.set(a,{height:mi,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?mi:s)+hi}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,m=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),h=m.some(e=>e.points.length>2),g=t?d:Math.max(d,h?u:0);return{edges:m,height:(t?Math.max(p,h?u:0):p)+gi,kind:"flowchart",nodes:c,width:g+gi}}(e):function(e){const t=[];let n=gi;for(const m of e.participants){const e=fi(m.label,96);t.push({actor:m.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:m.id,label:m.label}),n+=e+hi}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=/* @__PURE__ */new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const m of e.steps){if("activation"===m.kind){m.active?s.set(m.participant,l):c(m.participant,l);continue}if("note"===m.kind){const e=m.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=fi(m.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===m.placement?n-t-hi:"right"===m.placement?o+hi:(n+o)/2-t/2;i.push({height:34,text:m.text,width:t,x:r,y:l}),l+=62;continue}const e=a(m.from),t=a(m.to);null!==e&&null!==t&&(m.activate&&s.set(m.to,l),o.push({end:m.end,fromX:e,line:m.line,selfCall:m.from===m.to,text:m.text,toX:t,y:l}),l+=48,m.deactivate&&c(m.to,l))}const d=l;for(const m of[...s.keys()])c(m,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-hi+gi,p+gi);return{activations:r,height:d+gi,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function fi(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var yi=["BT","LR","RL","TB","TD"],vi=["subgraph","end","click","style","classDef","class","linkStyle","direction"],xi=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],ki=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],wi=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],Ci=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],Si=e=>({ok:!1,reason:e});function Ai(e){return e.split(/[\s(]/,1)[0]??""}function Ei(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return Si("the block is empty");const[n,...a]=t,o=Ai(n??"");return"sequenceDiagram"===o?function(e){const t=/* @__PURE__ */new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=Ai(o);if(xi.includes(e))return Si(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=Ti(o,e);if(null===n)return Si(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!Ii(t))return Si(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=Mi(o);if(null===e)return Si(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=_i(o);if(null===i)return Si(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(Ai(e).length).trim();if(0===n.length)return Si('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=yi.find(e=>e===n);if(void 0===a)return Si(`"${n}" is not a supported direction — use TD, TB, BT, LR or RL`);const o=/* @__PURE__ */new Map,i=[];for(const r of t){const e=Ai(r);if(vi.includes(e))return Si(`"${e}" is not supported yet`);if(r.includes("&"))return Si('"&" fan-out is not supported yet');const t=Ni(r,o,i);if(null!==t)return Si(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):Si(`"${o}" diagrams are not supported yet — only flowchart and sequenceDiagram are`)}function Ni(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=Li(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=$i(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function Li(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=ki.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of ki){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=Bi(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function Bi(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function $i(e){const t=e.trim();if(0===t.length)return null;for(const n of Ci){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(Ii(a))return{id:a,label:o.trim(),shape:n.shape}}return Ii(t)?{id:t,label:t,shape:"rect"}:null}function Ii(e){return/^[A-Za-z_][\w-]*$/.test(e)}function Ti(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!Ii(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function Mi(e){const t=e.slice(Ai(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(Ii)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return Ii(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function _i(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of wi){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(Ii(t)&&Ii(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var Di={dotted:"5 4",solid:"",thick:""},qi={dotted:1.5,solid:1.5,thick:3};function ji(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function zi(e,t,n,a,o){const i=ji("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function Hi(e,t=T){const n=ji("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=ji("defs",{},e),n=ji("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(ji("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)Pi(e,a,n);for(const a of t.nodes)Oi(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(ji("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(ji("rect",o,n)),e.append(zi(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(ji("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)Ri(e,a,n);for(const a of t.notes)e.append(ji("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(zi(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function Oi(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return ji("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return ji("polygon",{...s,points:e},t)}if("stadium"===a)return ji("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return ji("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=ji("g",{},t);return e.append(ji("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(ji("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(ji("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return ji("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(zi(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function Pi(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?ji("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":Di[t.line],"stroke-width":qi[t.line]},n):ji("line",{class:"clepit-typeset__edge","stroke-dasharray":Di[t.line],"stroke-width":qi[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=zi(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function Ri(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":Di[t.line],"stroke-width":qi[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=ji("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(zi(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=ji("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(ji("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(ji("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(zi(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var Fi=class e{static render(t,n,a,o,i){if(N.injectStyles("typeset-output",Bo),!e.validate(n))return V();const r=N.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=Ei(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(H(Hi(bi(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=Yo(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(H(di(Mo(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=T){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=Ei(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(Hi(bi(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=Yo(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(di(Mo(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},Ui=class{static render(e,t,n,a){return Fi.render("LaTeX",e,t,n,a)}static draw(e,t=T){return Fi.draw("LaTeX",e,t)}},Vi=class{static render(e,t,n,a){return Fi.render("Mermaid",e,t,n,a)}static draw(e,t=T){return Fi.draw("Mermaid",e,t)}},Wi="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",Ki=Wi,Gi=Wi,Ji=class{static render(e,t,n,a){N.injectStyles("updates-output",Gi);const o=N.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=T){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},Xi=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${N.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${N.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${N.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Zi="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Yi=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${N.classNames.block.video.captionEditable}`),o=e.querySelector(`.${N.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:F(a?.innerHTML),url:r}}static render(t,n,a,o){N.injectStyles("clepit-video-input-styles",Xi);const i=a||{alt:"",caption:"",url:""},r=N.createStyledElement("div",N.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=lt(n?.url||""),l=ct(n?.url||"");if(s||l){const e=N.createStyledElement("iframe",N.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=N.createStyledElement("video",N.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const c=N.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-video-caption-container");const d=N.createStyledElement("div",N.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=n?.caption||"",e.addEventListener(o,d,"input",ss.handleInput),e.addEventListener(o,d,"keydown",ss.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="🎥";const s=N.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const l=N.createStyledElement("button",`${N.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});l.type="button",l.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(l),e.addEventListener(a,l,"click",e=>{e.preventDefault(),e.stopPropagation();const t=l.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?c.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;me(l,"Delete block","below",p,u),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(r){console.error("Video upload error:",r),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=N.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.video.wrapper} video`),n=e.querySelector(`.${N.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${N.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?R(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Qi=class e{static render(t,n,a,o){if(N.injectStyles("clepit-video-output-styles",Zi),!e.validate(t))return V();if(Yi.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=N.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":c.classList.add("clepit-output-video-wrapper--left");break;case"center":c.classList.add("clepit-output-video-wrapper--center");break;case"right":c.classList.add("clepit-output-video-wrapper--right")}const d=lt(i),p=ct(i);if(d||p){const e=O("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",c.appendChild(e),l.appendChild(c)}else{const e=O("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",c.appendChild(e),l.appendChild(c)}if(r){const e=N.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=T){if(!e.validate(t)||Yi.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},er=(e,t,n)=>{const a=tr(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},tr=(e,t,n)=>{switch(e.type){case"alert":return bn.draw(e.data,t);case"audio":return kn.draw(e.data,t);case"checklist":return En.draw(e.data,t);case"code":return be.draw(e.data,t,n);case"collapsible":return ar.draw(e.data,t,n);case"collection":return jn.draw(e.data,t);case"columns":return Pn.draw(e.data,t,n);case"date":return Kn.draw(e.data,t);case"delimiter":return Xn.draw(e.data,t);case"doc_card":return ea.draw(e.data,t,n);case"embed":return Xe.draw(e.data,t,n);case"file":return ia.draw(e.data,t);case"glance":return la.draw(e.data,t);case"header":return pa.draw(e.data,t);case"image":return ba.draw(e.data,t);case"issues":return xa.draw(e.data,t,n);case"latex":return Ui.draw(e.data,t);case"list":return Ca.draw(e.data,t);case"mermaid":return Vi.draw(e.data,t);case"openapi":return Qa.draw(e.data,t);case"paragraph":return no.draw(e.data,t);case"quote":return ro.draw(e.data,t);case"sketch":return ho.draw(e.data,t);case"table":return ko.draw(e.data,t);case"toc":return Eo.draw(e.data,t,n);case"updates":return Ji.draw(e.data,t);case"video":return Qi.draw(e.data,t);default:return nr(e)}},nr=e=>(console.warn("drawBlock: no drawer for block",e),null),ar=class e{static render(t,n,a,o){if(N.injectStyles("collapsible-output",In),!e.validate(t))return V();const i=N.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=F(t.html),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="clepit-collapsible__children";for(const c of t.children??[])l.appendChild(e.renderChild(c,n));return i.appendChild(l),i}static renderChild(e,t){const n=Zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=er(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},or={icon:"▸",get input(){return Mn},label:"Collapsible section",get output(){return ar},shortcut:Ct("E"),testId:"block-type-collapsible",type:"collapsible"},ir=/* @__PURE__ */new WeakMap,rr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=ir.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){N.injectStyles("collection-input",Dn);const a=t??{collectionId:""},o=jn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),ir.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},sr={icon:"▦",get input(){return rr},label:"Collection",get output(){return jn},shortcut:Ct("G"),testId:"block-type-collection",type:"collection"},lr=/* @__PURE__ */new WeakMap;var cr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=lr.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){N.injectStyles("columns-input",Hn);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=N.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return lr.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=N.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=ss.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},dr={icon:"▥",get input(){return cr},label:"Columns",get output(){return Pn},shortcut:Ct("L"),testId:"block-type-columns",type:"columns"},pr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){N.injectStyles("date-input",Fn);const o=N.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&Wn(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ur={icon:"▤",get input(){return pr},label:"Date",get output(){return Kn},shortcut:Ct("D"),testId:"block-type-date",type:"date"},mr={icon:"—",get input(){return Jn},label:"Delimiter",get output(){return Xn},shortcut:Ct("D"),testId:"block-type-delimiter",type:"delimiter"},hr=/* @__PURE__ */new WeakMap,gr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=hr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){N.injectStyles("doc-card-input",Yn);const a=t??{pageId:"",title:""},o=ea.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),hr.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},br={icon:"🗎",get input(){return gr},label:"Doc card",get output(){return ea},shortcut:Ct("K"),testId:"block-type-doc-card",type:"doc_card"},fr={icon:"🔗",get input(){return at},label:"Embed",get output(){return Xe},shortcut:Ct("M"),testId:"block-type-embed",type:"embed"},yr=/* @__PURE__ */new WeakMap,vr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=yr.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){N.injectStyles("file-input",na);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&yr.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=yr.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=ia.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);yr.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},xr={icon:"📎",get input(){return vr},label:"File",get output(){return ia},shortcut:Ct("F"),testId:"block-type-file",type:"file"},kr={html:"",label:""},wr=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:F(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){N.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[kr]},o=la.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(e,"glanceLabelHint","Label"));for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(e,"glanceValueHint","Value"));return o}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const i=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),r={...e.save(t),variant:n},s={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},l=e.render(a,r,s);t.replaceWith(l),c.getState().updateBlockData(a,i,r)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===F(e.html).trim())}static destroy(e){}},Cr={icon:"≡",get input(){return wr},label:"At a glance",get output(){return la},shortcut:Ct("N"),testId:"block-type-glance",type:"glance"},Sr={icon:"H",get input(){return da},label:"Header",get output(){return pa},shortcut:Ct("H"),testId:"block-type-header",type:"header"},Ar={icon:"𝑖",get input(){return ga},label:"Image",get output(){return ba},shortcut:Ct("I"),testId:"block-type-image",type:"image"},Er={},Nr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){N.injectStyles("issues-input",fa);const a=c.getState().getInstance(e)?.config,o=c.getState().getData(e)?.blocks??[],i=xa.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:Er[e]},n?.styles,n?.classNames);return i.classList.add("clepit-issues--input"),i.setAttribute("contenteditable","false"),i}static refresh(t,n){Er[t]={...Er[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${N.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${N.classNames.block.content}`);if(!n)continue;const a=c.getState().getInstance(t),i={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},i))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete Er[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Lr={icon:"☑",get input(){return Nr},label:"Linked issues",get output(){return xa},shortcut:Ct("J"),testId:"block-type-issues",type:"issues"},Br={icon:"•",get input(){return wa},label:"List",get output(){return Ca},shortcut:Ct("L"),testId:"block-type-list",type:"list"},$r="clepit-openapi__source",Ir=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},Tr=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=/* @__PURE__ */new WeakMap}static render(t,n,a){N.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=O("div","clepit-openapi-input"),i=O("div",$r);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(t,"openApiSourceHint",e.placeholder)),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=O("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(Qa.render(n)),i.addEventListener("input",()=>{const t=Ir(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(Qa.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains($r)?e:e.querySelector(`.${$r}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return Ir(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},Mr={icon:"⇄",get input(){return Tr},label:"API reference",get output(){return Qa},shortcut:Ct("A"),testId:"block-type-openapi",type:"openapi"},_r={icon:"¶",get input(){return to},label:"Paragraph",get output(){return no},shortcut:Ct("P"),testId:"block-type-paragraph",type:"paragraph"},Dr={icon:"“",get input(){return io},label:"Quote",get output(){return ro},shortcut:Ct("Q"),testId:"block-type-quote",type:"quote"},qr=/* @__PURE__ */new WeakMap,jr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?qr.get(t):void 0)??{strokes:[]}}static render(t,n,a){N.injectStyles("sketch-input",lo);const o=n??{strokes:[]},i=ho.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),qr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=qr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=ho.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=qr.get(n)??{strokes:[]};qr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zr={icon:"✏️",get input(){return jr},label:"Sketch",get output(){return ho},shortcut:Ct("W"),testId:"block-type-sketch",type:"sketch"},Hr={icon:"⊞",get input(){return fo},label:"Table",get output(){return ko},shortcut:Ct("T"),testId:"block-type-table",type:"table"},Or=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){N.injectStyles("toc-input",Co);const a=c.getState().getData(e)?.blocks??[],o=Eo.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Pr={icon:"≡",get input(){return Or},label:"Table of contents",get output(){return Eo},shortcut:Ct("T"),testId:"block-type-toc",type:"toc"},Rr={latex:"LaTeX",mermaid:"Mermaid"};function Fr(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function Ur(e,t,n,a){N.injectStyles("typeset-input",Lo);const o=n??{source:""},i=N.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:a?.classNames?.wrapper,styles:a?.styles?.wrapper});i.setAttribute("data-language",e),i.setAttribute("data-rendered","source");const r=O("span","clepit-typeset__kind");r.textContent=Rr[e],i.appendChild(r);const s=O("span","clepit-typeset__title");s.setAttribute("data-testid","typeset-title"),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",t),s.textContent=o.title??"",i.appendChild(s);const l=O("pre","clepit-typeset__source");return l.setAttribute("contenteditable","true"),l.textContent=o.source,i.appendChild(l),i}var Vr=class{static{this.placeholder=""}static save(e){return Fr(e)}static render(e,t,n){return Ur("latex",Y(e,"formulaTitleHint","What does this formula show?"),t,n)}static isEmpty(e){return""===Fr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Wr=class{static{this.placeholder=""}static save(e){return Fr(e)}static render(e,t,n){return Ur("mermaid",Y(e,"diagramTitleHint","What does this diagram show?"),t,n)}static isEmpty(e){return""===Fr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Kr={icon:"∑",get input(){return Vr},label:"LaTeX",get output(){return Ui},shortcut:Ct("X"),testId:"block-type-latex",type:"latex"},Gr={icon:"◈",get input(){return Wr},label:"Mermaid",get output(){return Vi},shortcut:Ct("Y"),testId:"block-type-mermaid",type:"mermaid"},Jr=/* @__PURE__ */new WeakMap,Xr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=Jr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){N.injectStyles("updates-input",Ki);const a=t??{},o=Ji.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),Jr.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Zr=[fn,wn,Nn,Ln,or,sr,{icon:"🕘",get input(){return Xr},label:"Updates",get output(){return Ji},shortcut:Ct("U"),testId:"block-type-updates",type:"updates"},dr,ur,mr,br,fr,xr,Cr,Sr,Ar,Lr,Br,Mr,_r,Dr,zr,Kr,Gr,Hr,Pr,{icon:"▶",get input(){return Yi},label:"Video",get output(){return Qi},shortcut:Ct("V"),testId:"block-type-video",type:"video"}],Yr="clepit-block-type-selector",Qr="clepit-code-language-submenu",es="clepit-code-theme-submenu",ts="clepit-convert-submenu",ns="clepit-block-operations-menu";function as(e){return Yt.includes(e)}function os(e,t,n){return e?.[t]??n}var is,rs=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=c.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const i=void 0!==a.config.audioUploader,r=void 0!==a.config.imageUploader,s=void 0!==a.config.videoUploader,l=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,p=a.config.classNames?.convertSubmenu,u=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,h=a.config.styles?.blockTypeMenu,g=a.config.styles?.convertSubmenu,b=a.config.styles?.operationsMenu;e.remove(n),N.injectStyles("clepit-block-toolbar-styles",'\n/* Block Toolbar */\n.clepit-block-toolbar {\n position: absolute;\n left: 4px;\n top: 4px;\n z-index: 1000;\n display: none;\n gap: 4px;\n flex-shrink: 0;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n transform: translateY(0) !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-block-toolbar-add:active,\n.clepit-block-toolbar-ops:active {\n transform: scale(0.95);\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n z-index: 998;\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const f=O("div",e.defaultClassName);f.id=`${t}-block-toolbar`,f.innerHTML="",N.applyStyling(f,{classNames:l?.container,styles:m?.container});const y=O("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML="+",N.applyStyling(y,{classNames:l?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:i,block:n,classNames:d,containerId:t,imageIsEnabled:r,menuLabels:a.config.blockToolbarLabels,styles:h,toolLabels:a.config.blockToolLabels,videoIsEnabled:s}));const v=O("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});v.innerHTML="⋯",N.applyStyling(v,{classNames:l?.button,styles:m?.button}),e.addEventListener(o,v,"click",()=>e.showOperationsMenu({audioIsEnabled:i,block:n,classNames:u,containerId:t,convertSubmenuClassNames:p,convertSubmenuStyles:g,imageIsEnabled:r,operationLabels:a.config.blockToolbarLabels,styles:b,toolLabels:a.config.blockToolLabels,videoIsEnabled:s})),f.appendChild(y),f.appendChild(v),e.addEventListener(o,f,"click",e=>e.stopPropagation()),n.appendChild(f)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:i,classNames:r,styles:s,menuLabels:l,toolLabels:d}){e.closeAllMenus();const p=document.querySelector(`.${Yr}`);if(p)return p.classList.remove(`${Yr}--visible`),p.classList.add(`${Yr}--hidden`),void setTimeout(()=>p.remove(),200);const u=O("div",Yr);N.applyStyling(u,{classNames:r?.container,styles:s?.container});const m=O("input","",{placeholder:os(l,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),N.applyStyling(m,{classNames:r?.input,styles:s?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=O("div",`${Yr}-items`),b=l=>{g.innerHTML="",l.forEach(l=>{if("image"===l.type&&!a)return;if("video"===l.type&&!o)return;if("audio"===l.type&&!i)return;const c=O("div","clepit-menu-item clepit-block-type-item");c.setAttribute("data-testid",`block-type-${l.type}`),N.applyStyling(c,{classNames:r?.item?.container,styles:s?.item?.container});const p=O("span","clepit-menu-icon "+("image"===l.type?"clepit-menu-icon--italic":""));p.textContent=l.icon,N.applyStyling(p,{classNames:r?.item?.icon,styles:s?.item?.icon}),c.appendChild(p);const m=O("span","clepit-menu-label");if(m.textContent=(as(l.type)?d?.[l.type]:void 0)??l.label,N.applyStyling(m,{classNames:r?.item?.text,styles:s?.item?.text}),c.appendChild(m),l.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=l.shortcut,N.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),c.appendChild(e)}e.addEventListener(h,c,"click",e=>{if(e.stopPropagation(),n){const e=ss.getBlockIndex(t,n.getAttribute("data-id")||"");ss.insertBlock({data:{html:""},type:l.type},t,e+1)}u.hidePopover()}),g.appendChild(c)})},f=((e,t)=>t.filter(t=>pt(e,t.type)))(c.getState().getInstance(t)?.config,Zr);if(b(f),e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",()=>{const e=m.value.toLowerCase(),t=f.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e));if(b(t),0===t.length&&""!==e.trim()){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=os(l,"noBlockTypesFound","No block types found"),g.appendChild(e)}}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.hidePopover()}),u.appendChild(g),u.classList.add(Yr),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Yr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||u.remove()})):u.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:c,operationLabels:d,toolLabels:p}){e.closeAllMenus();const u=O("div",ns);o?.container&&N.applyStyling(u,{classNames:a?.container,styles:o.container}),a?.container&&u.classList.add(a.container);const m=O("input","",{placeholder:os(d,"searchOperations","Search operations..."),type:"text"});m.setAttribute("data-testid","operations-search"),N.applyStyling(m,{classNames:a?.input,styles:o?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=O("div",`${ns}-items`),b=n.getAttribute("data-tool");if(!b)return;const f=(e,t)=>os(d,e,t),y=[{hasSubmenu:!0,icon:"↻",label:f("convert","Convert To"),testId:"operation-convert",value:"convert"},{icon:"↑",label:f("moveUp","Move Up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"},{icon:"↓",label:f("moveDown","Move Down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"},{icon:"×",label:f("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"}],v=[{icon:"←",label:f("alignLeft","Align Left"),testId:"image-align-left",value:"imageAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"image-align-center",value:"imageAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"image-align-right",value:"imageAlignRight"}],x=[{icon:"←",label:f("alignLeft","Align Left"),testId:"video-align-left",value:"videoAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"video-align-center",value:"videoAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"video-align-right",value:"videoAlignRight"}],k=[{icon:"←",label:f("alignLeft","Align Left"),testId:"audio-align-left",value:"audioAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"audio-align-center",value:"audioAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"audio-align-right",value:"audioAlignRight"}],w=[{hasSubmenu:!0,icon:"⌘",label:f("codeLanguage","Language"),testId:"code-language",value:"codeLanguage"},{hasSubmenu:!0,icon:"◆",label:f("codeTheme","Theme"),testId:"code-theme",value:"codeTheme"}],C="embed"===b&&at.save(n).issue?[{icon:"▭",label:f("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:"▣",label:f("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:"▭",label:f("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];y.forEach(m=>{const b=O("div","clepit-menu-item clepit-block-operation-item");b.setAttribute("data-testid",`operation-${m.value}`),N.applyStyling(b,{classNames:a?.item?.container,styles:o?.item?.container}),b.setAttribute("data-testid",m.testId);const f=O("span","clepit-menu-icon");f.textContent=m.icon,N.applyStyling(f,{classNames:a?.item?.icon,styles:o?.item?.icon}),b.appendChild(f);const y=O("span","clepit-menu-label");if(y.textContent=m.label,N.applyStyling(y,{classNames:a?.item?.text,styles:o?.item?.text}),b.appendChild(y),m.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=m.shortcut,N.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),b.appendChild(e)}if(m.hasSubmenu){const e=O("span","clepit-menu-arrow");e.textContent="›",b.appendChild(e)}"delete"===m.value&&(b.classList.add("clepit-block-toolbar--delete-enabled"),1===h.querySelectorAll(".clepit-block").length&&(b.classList.add("clepit-block-toolbar--delete-disabled"),b.title="Cannot delete the last block")),e.addEventListener(h,b,"click",a=>{a.stopPropagation(),m.hasSubmenu?(document.querySelector(`.${Qr}`)?.remove(),document.querySelector(`.${es}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:c,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:d,parentItem:b,parentMenu:u,styles:r,toolLabels:p,videoIsEnabled:l})):(e.handleOperationSelect(m.value,n,t),u.remove())}),g.appendChild(b)});const S=()=>{const e=O("div","clepit-menu-divider");N.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),g.appendChild(e)};if("image"===b&&(S(),v.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("imageAlign")){const e=n.querySelector(".clepit-image-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("imageAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"video"===b&&(S(),x.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("videoAlign")){const e=n.querySelector(".clepit-video-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("videoAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"audio"===b&&(S(),k.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("audioAlign")){const e=n.querySelector(".clepit-audio-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("audioAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"code"===b&&(S(),w.forEach(s=>{const l=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(l,{classNames:a?.item?.container,styles:o?.item?.container}),l.setAttribute("data-testid",s.testId);const c=O("span","clepit-menu-icon");c.textContent=s.icon,N.applyStyling(c,{classNames:a?.item?.icon,styles:o?.item?.icon}),l.appendChild(c);const p=O("span","clepit-menu-label");if(p.textContent=s.label,N.applyStyling(p,{classNames:a?.item?.text,styles:o?.item?.text}),l.appendChild(p),s.hasSubmenu){const e=O("span","clepit-menu-arrow");e.textContent="›",l.appendChild(e)}e.addEventListener(h,l,"click",a=>{a.stopPropagation(),s.hasSubmenu?"codeLanguage"===s.value?e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):"codeTheme"===s.value&&e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):(e.handleOperationSelect(s.value,n,t),u.remove())}),g.appendChild(l)})),"embed"===b&&(S(),C.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"header"===b){S();const i=e.getCurrentHeadingLevel(n);[{icon:"H1",label:f("headingH1","Heading 1"),value:"heading-h1"},{icon:"H2",label:f("headingH2","Heading 2"),value:"heading-h2"},{icon:"H3",label:f("headingH3","Heading 3"),value:"heading-h3"},{icon:"H4",label:f("headingH4","Heading 4"),value:"heading-h4"},{icon:"H5",label:f("headingH5","Heading 5"),value:"heading-h5"},{icon:"H6",label:f("headingH6","Heading 6"),value:"heading-h6"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===`heading-${i}`&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(r.value,n,t),u.remove()}),g.appendChild(s)})}if("list"===b){S();const i=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";[{icon:"•",label:f("listUnordered","Unordered"),value:"unordered"},{icon:"1.",label:f("listOrdered","Ordered"),value:"ordered"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`listType${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("alert"===b){S();const i=n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info";[{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"},{icon:"—",label:f("variantPlain","Plain"),value:"plain"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`alertVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("glance"===b){S();const i=n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain";[{icon:"—",label:f("variantPlain","Plain"),value:"plain"},{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`glanceVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("delimiter"===b){S();const i=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";[{icon:"—",label:f("delimiterLine","Line"),value:"line"},{icon:"***",label:f("delimiterStars","Stars"),value:"stars"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`delimiterVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}const A=g.querySelectorAll(".clepit-block-operation-item"),E=g.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",e=>{(e=>{let t=0;A.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=g.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=f("noOperationsFound","No operations found"),g.appendChild(e)}}else n&&n.remove();E.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.remove()}),u.appendChild(g),u.classList.add(ns),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${ns}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||u.remove()})):u.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:i,styles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:d,menuLabels:p,toolLabels:u}){const m=document.querySelector(`.${ts}`);m&&m.remove();const h=n.getAttribute("data-tool");if(!h)return;const g=O("div",ts);g.classList.add(ts),g.classList.add(`${ts}--hidden`),r?.container&&N.applyStyles(g,r.container),i?.container&&g.classList.add(i.container);const b=O("input","",{placeholder:os(p,"searchConvertOptions","Search convert options..."),type:"text"});b.setAttribute("data-testid","convert-search"),N.applyStyling(b,{classNames:i?.input,styles:r?.input}),g.appendChild(b),setTimeout(()=>b.focus(),10);const f=document.querySelector(`#${t}`),y=O("div",`${ts}-items`),v=e=>(as(e.type)?u?.[e.type]:void 0)??e.label,x=c.getState().getInstance(t)?.config;Zr.filter(e=>e.type!==h&&(!!pt(x,e.type)&&(!("image"===e.type&&!s||"video"===e.type&&!l||"audio"===e.type&&!d)||void 0))).sort((e,t)=>v(e).localeCompare(v(t))).forEach(a=>{const s=O("div","clepit-menu-item clepit-convert-option-item");s.setAttribute("data-testid",a.testId),N.applyStyling(s,{classNames:i?.item?.container,styles:r?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=a.icon,N.applyStyling(l,{classNames:i?.item?.icon,styles:r?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");if(c.textContent=v(a),N.applyStyling(c,{classNames:i?.item?.text,styles:r?.item?.text}),s.appendChild(c),a.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=a.shortcut,N.applyStyling(e,{classNames:i?.item?.shortcut,styles:r?.item?.shortcut}),s.appendChild(e)}e.addEventListener(f,s,"click",e=>{e.stopPropagation();const i=n?.getAttribute("data-tool");if(!i)return;let r;if(n){const e=n.querySelector(".clepit-block-content");"paragraph"===i?r=e.querySelector(".clepit-paragraph")?.innerText||"":"quote"===i?r=e.querySelector(".clepit-quote-text")?.innerText||"":"list"===i?r=Array.from(e.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===i?r=e.querySelector(".clepit-alert")?.innerText||"":"header"===i&&(r=e.querySelector(".clepit-header")?.innerText||"")}const s=n?.getAttribute("data-id");s&&ss.convertBlock(s,a.type,t),setTimeout(()=>{if(!n)return;const e=n.getAttribute("data-tool");if(r&&r.trim()){const t=n.querySelector(".clepit-block-content");if("paragraph"===e){const e=t.querySelector(".clepit-paragraph");e&&(e.innerText=r)}else if("quote"===e){const e=t.querySelector(".clepit-quote-text");e&&(e.innerText=r)}else if("list"===e){const e=t.querySelector(".clepit-list");e&&(e.innerHTML="",r.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===e){const e=t.querySelector(".clepit-alert");e&&(e.innerText=r)}else if("header"===e){const e=t.querySelector(".clepit-header");e&&(e.innerText=r)}}},0),o.remove()}),y.appendChild(s)});const k=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(f,b,"click",e=>e.stopPropagation()),e.addEventListener(f,b,"focus",e=>e.stopPropagation()),e.addEventListener(f,b,"input",e=>{(e=>{let t=0;k.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=os(p,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(f,b,"keydown",t=>{"Escape"===t.key&&e.closeMenu(ts)}),g.appendChild(y);const w="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",w),g.style.setProperty("position-anchor",w),g.classList.remove(`${ts}--hidden`),g.setAttribute("popover","auto"),e.menuHost(t).appendChild(g),g.addEventListener("toggle",e=>{"closed"===e.newState&&g.remove()}),"function"!=typeof g.showPopover?(o.appendChild(g),g.classList.add(`${ts}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;g.contains(t)||a.contains(t)||o.contains(t)||g.remove()})):g.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&ss.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&da.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&wa.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&gn.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&wr.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return Jn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${N.classNames.block.content}`);if(!a)return;return fo.handleAction(n,a)}if(e.startsWith("embed"))return at.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return ga.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Yi.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return xn.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;return oe.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;return oe.updateTheme(t,n)}const o=ss.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":ss.removeBlock(a.id,o);break;case"moveUp":o>0&&ss.moveBlock(a.id,o,o-1);break;case"moveDown":o<ss.getBlocks(a.id).length-1&&ss.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Qr}`);l&&l.remove();const c=document.querySelector(`.${es}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${N.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",u=N.createStyledElement("div",Qr,{classNames:i?.container,styles:s?.container});u.classList.add(ts,"clepit-block-toolbar--submenu-positioned");const m=O("input","",{placeholder:os(r,"searchLanguages","Search languages..."),type:"text"});m.setAttribute("data-testid","language-search"),u.appendChild(m);const h=oe.supportedLanguages;Object.entries(h).forEach(([t,r])=>{const l=N.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-language-${t}`);const c=N.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-language-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Qr}--hidden`),u.classList.add(`${Qr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Qr}--visible`),u.classList.add(`${Qr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${es}`);l&&l.remove();const c=document.querySelector(`.${Qr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${N.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",u=N.createStyledElement("div",es,{classNames:i?.container,styles:s?.container});u.classList.add(ts,"clepit-block-toolbar--submenu-positioned");const m=O("input","",{placeholder:os(r,"searchThemes","Search themes..."),type:"text"});m.setAttribute("data-testid","theme-search"),u.appendChild(m);const h=oe.supportedThemes;Object.entries(h).forEach(([t,r])=>{const l=N.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-theme-${t}`);const c=N.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-theme-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${es}--hidden`),u.classList.add(`${es}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${es}--visible`),u.classList.add(`${es}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${Yr}, .${ns}, .${ts}`)||e.hideAllToolbars(t)}static menuHost(e){return document.getElementById(e)?.closest("dialog")??document.body}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(Yr),e.closeMenu(ns),e.closeMenu(ts)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},ss=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=c.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=O("div",N.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const i={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let r,s;if(i.margins&&(r=i.margins.top,s=i.margins.bottom),void 0===r&&i.styles){const e=i.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?r=parseInt(t.replace("px",""),10):"number"==typeof t&&(r=t)}}if(void 0===s&&i.styles){const e=i.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}void 0===r&&void 0!==a.config.margins?.top&&(r=a.config.margins.top),void 0===s&&void 0!==a.config.margins?.bottom&&(s=a.config.margins.bottom),void 0!==r&&(o.style.marginTop=`${r}px`),void 0!==s&&(o.style.marginBottom=`${s}px`),rs.create({block:o,containerId:n});const l=O("div",N.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(l.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(l),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){e.adoptStartingBlock(n);const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const i=e.getBlockData(o.getAttribute("data-id"));return c.getState().addBlock(n,i,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),c.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const i=c.getState().getData(t);if(!i)return;const r=c.getState().getContentElement(t);if(!r)return;const s=o[n];o.splice(n,1),o.splice(a,0,s),0===a?r.insertBefore(s,r.firstChild):a>=o.length-1?r.appendChild(s):r.insertBefore(s,o[a+1]);const l=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),d={...i,blocks:l};c.getState().setData(t,d),e.focusBlock(s)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${N.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${N.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return Zr.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${N.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=c.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return gn.render(n,t,o);case"audio":return a.config.audioUploader?xn.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return oe.render(n,t,o);case"collapsible":return Mn.render(n,t,o);case"columns":return cr.render(n,t,o);case"date":return pr.render(n,t,o);case"delimiter":return Jn.render(n,t,o);case"collection":return rr.render(n,t,o);case"doc_card":return gr.render(n,t,o);case"embed":return at.render(n,t,o);case"openapi":return Tr.render(n,t,o);case"sketch":return jr.render(n,t,o);case"latex":return Vr.render(n,t,o);case"mermaid":return Wr.render(n,t,o);case"file":return a.config.fileUploader?vr.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"header":return da.render(n,t,o);case"image":return a.config.imageUploader?ga.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return wa.render(n,t,o);case"checklist":return An.render(n,t,o);case"paragraph":return to.render(n,t,o);case"quote":return io.render(n,t,o);case"table":return fo.render(n,t,o);case"toc":return Or.render(n,t,o);case"issues":return Nr.render(n,t,o);case"video":return a.config.videoUploader?Yi.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(N.classNames.block.active);t.classList.add(N.classNames.block.active),rs.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${N.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);e.adoptStartingBlock(a);const i=e.getBlockData(t),r=e.getTool(n);if(!r)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const s=e.getBlockIndex(a,t);let l=i.data;if("list"===n){const e=i.data,t=e.html||e.text||"";l={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=i.data;l={html:e.html||e.text||"",level:"h1"}}const d={data:l,id:t,type:r.type},p=e.createBlockElement(d,a);if(!p)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(p);const u=e.getBlockData(p.getAttribute("data-id"));c.getState().updateBlock(a,s,u),e.focusBlock(p)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=mn.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${N.classNames.block.container}`);if(!a)return;e.adoptStartingBlock(n.instance.config.containerId);const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));c.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),i=c.getState().getContentElement(n);if(!i)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];i.insertBefore(t,e),o.splice(a,0,t)}else i.appendChild(t),o.push(t);else i.appendChild(t),o.push(t);e.focusBlock(t);const r=c.getState().getInstance(n);r&&Jt.initializeElements(t,{classNames:r.config.classNames?.blocks?.tooltip,styles:r.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),c.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static adoptStartingBlock(t){const n=c.getState().getInstance(t)?.data.blocks,a=e.getBlocks(t);!n||n.length>0||1!==a.length||c.getState().seedBlocks(t,[e.getBlockData(a[0].getAttribute("data-id"))])}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();c.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${N.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${N.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!R(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${N.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${N.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;e.adoptStartingBlock(a);const o=n.getAttribute("data-id");c.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){e.adoptStartingBlock(a);const o=e.getBlock(t);if(o){const t=o.querySelector(`.${N.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i)}c.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),Zr.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},ls=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=c.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);N.injectStyles("clepit-action-bar-styles","\n/* View Toggle */\n.clepit-action-bar {\n position: relative;\n z-index: 1000;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: -14px; /* Position buttons so exactly half is inside and half outside */\n pointer-events: none;\n padding: 0 100px;\n}\n\n.clepit-action-bar-group {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-action-bar-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-action-bar-button:active {\n transform: scale(0.95);\n}\n\n.clepit-action-bar-button.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n/* Action Buttons */\n.clepit-view-actions {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-view-action-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-view-action-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-view-action-button:active {\n transform: scale(0.95);\n}\n\n/* Copy button feedback animation */\n.clepit-view-action-button--copy-feedback {\n transform: scale(0.95) !important;\n background-color: var(--clepit-success) !important;\n color: var(--clepit-bg) !important;\n}\n");const a=document.getElementById(t);if(!a)return;const o=!1!==n.config.hasViewSwitcher,i=!1!==n.config.hasDocumentActions;if(!o&&!i)return;const r=n.config.styles?.controls?.group,s=n.config.classNames?.controls?.group,l=n.config.styles?.controls?.button,d=n.config.classNames?.controls?.button,p=n.config.styles?.tooltips,u=n.config.classNames?.tooltips,m=O("div",N.classNames.actionBar.container);e.createButtonGroup(a,m,{buttonClassNames:d,buttonStyles:l,currentView:n.currentView,groupClassNames:s,groupStyles:r,hasDocumentActions:i,hasViewSwitcher:o,labels:n.config.controlLabels,tooltipClassNames:u,tooltipStyles:p}),a.insertBefore(m,a.firstChild)}static createButtonGroup(t,n,a){const o=(e,t)=>a.labels?.[e]||t,i=o("editView","Edit Mode"),r=o("previewView","Preview Mode"),s=o("jsonView","JSON Output"),l=o("copyJson","Copy JSON to Clipboard"),c=o("downloadJson","Download JSON File"),d=o("clearEditor","Clear Editor");if(a.hasViewSwitcher){const o=O("div",N.classNames.actionBar.group);N.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const l=O("button",N.classNames.actionBar.button,{"aria-label":i,"data-testid":"action-bar-edit-button","data-view":"edit",id:P(t.id,N.idSuffixes.actionBar.editButton),type:"button"});l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',N.applyStyling(l,{classNames:a.buttonClassNames,styles:a.buttonStyles});const c=O("button",N.classNames.actionBar.button,{"aria-label":r,"data-testid":"action-bar-preview-button","data-view":"preview",id:P(t.id,N.idSuffixes.actionBar.previewButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',N.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=O("button",N.classNames.actionBar.button,{"aria-label":s,"data-testid":"action-bar-json-button","data-view":"json",id:P(t.id,N.idSuffixes.actionBar.jsonButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14,2 14,8 20,8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10,9 9,9 8,9"/></svg>',N.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles}),"edit"===a.currentView?l.classList.add("active"):"preview"===a.currentView?c.classList.add("active"):"json"===a.currentView&&d.classList.add("active"),e.addEventListener(t.id,l,"click",e.handleViewChange),e.addEventListener(t.id,c,"click",e.handleViewChange),e.addEventListener(t.id,d,"click",e.handleViewChange),o.appendChild(l),o.appendChild(c),o.appendChild(d),n.appendChild(o),me(l,i,"above",a.tooltipClassNames,a.tooltipStyles),me(c,r,"above",a.tooltipClassNames,a.tooltipStyles),me(d,s,"above",a.tooltipClassNames,a.tooltipStyles)}if(a.hasDocumentActions){const o=O("div",N.classNames.actionBar.action);N.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const i=O("button",N.classNames.actionBar.actionButton,{"aria-label":l,"data-testid":"view-copy-button",id:P(t.id,N.idSuffixes.actionBar.copyButton),type:"button"});i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',N.applyStyling(i,{classNames:a.buttonClassNames,styles:a.buttonStyles});const r=O("button",N.classNames.actionBar.actionButton,{"aria-label":c,"data-testid":"view-download-button",id:P(t.id,N.idSuffixes.actionBar.downloadButton),type:"button"});r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',N.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles});const s=O("button",N.classNames.actionBar.actionButton,{"aria-label":d,"data-testid":"view-clear-button",id:P(t.id,N.idSuffixes.actionBar.clearButton),type:"button"});s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',N.applyStyling(s,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,i,"click",e.handleCopyJson),e.addEventListener(t.id,r,"click",e.handleDownloadJson),e.addEventListener(t.id,s,"click",e.handleClearEditor),o.appendChild(i),o.appendChild(r),o.appendChild(s),n.appendChild(o),me(i,l,"above",a.tooltipClassNames,a.tooltipStyles),me(r,c,"above",a.tooltipClassNames,a.tooltipStyles),me(s,d,"above",a.tooltipClassNames,a.tooltipStyles)}}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${N.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${N.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${P(e,N.idSuffixes.actionBar.editButton)}, #${P(e,N.idSuffixes.actionBar.previewButton)}, #${P(e,N.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{e.getAttribute("data-view")===t?e.classList.add("active"):e.classList.remove("active")})}static handleViewChange(t){const n=t.currentTarget,a=ss.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(c.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=c.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(N.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(N.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=c.getState().getInstance(n)?.config.onClearRequest;a?a().then(e=>{e&&ss.resetBlocks(n)},e=>console.error("Clear was not confirmed, the page is unchanged:",e)):ss.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=ss.getBlocks(n).map(e=>ss.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${N.classNames.actionBar.container}`);n&&n.remove()}},cs=`\n/* Editor Container */\n.${N.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${N.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${N.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${N.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${N.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${N.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${N.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${N.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${N.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${N.classNames.editor.container} {\n padding: 8px;\n }\n\n .${N.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,ds=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(c.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=/* @__PURE__ */new Set;for(const a of Te.collect(t))n.add(Te.read(a).url);for(const a of ss.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=at.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await ot(t,n),o=document.getElementById(t),i=c.getState().getInstance(t)?.config;if(o&&i&&0!==Object.keys(a).length){Te.refreshAll(o,a,i.issueLabels);for(const e of ss.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=at.save(e),o=n.issue?a[n.url]:void 0;o&&at.refreshIssue(e,t,o)}Nr.refresh(t,a)}}},ps=class{static render(e){const t=c.getState().getInstance(e);t&&(ln.create(e),N.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block:hover {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block--active {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Default menu item styles - package doesn\'t care about theme */\n.clepit-menu-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n width: 16px;\n height: 16px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n}\n\n.clepit-menu-item:hover {\n background-color: var(--clepit-selection-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n.clepit-menu-item--danger {\n color: var(--clepit-error);\n}\n\n/* Block type menu items - match font size with operations menu */\n.clepit-block-type-item {\n font-size: 14px;\n}\n\n/* Default menu divider styles */\n.clepit-menu-divider {\n height: 1px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 8px 0;\n}\n\n/* Default menu arrow styles */\n.clepit-menu-arrow {\n margin-left: auto;\n font-size: 12px;\n color: var(--clepit-text-muted);\n}\n\n/* Input styles for block type selector */\n.clepit-block-type-selector input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-type-selector input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-type-selector-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-menu-icon {\n font-size: 14px;\n min-width: 20px;\n text-align: center;\n font-weight: bold;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n font-size: 9px;\n color: var(--clepit-text-muted);\n opacity: 0.7;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n margin: 0;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n background: var(--clepit-bg);\n padding: 8px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: block-end span-inline-end;\n margin-block-start: 5px;\n inset: auto;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),ss.renderBlocks(t.data.blocks,e))}},us=class e{static render(t){const n=c.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=N.createStyledElement("pre",N.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(N.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=N.createStyledElement("div",N.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=ss.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=c.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${N.classNames.editor.jsonOutput}`);n&&(n.classList.remove(N.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;c.getState().setData(a,e),"json"===o&&c.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=c.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${N.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(e){const t=e.target,n=t.textContent||"",a=ss.getEditorId(t);if(!a)return;const o=c.getState().getInstance(a);if(o)try{const e=JSON.parse(n);if("object"!=typeof e||null===e)throw new Error("Invalid JSON structure");{e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);try{ln.hide(a),rs.hide(a)}catch{}const t=o.currentView;c.getState().setData(a,e),"json"===t&&c.getState().setCurrentView(a,"json");const n=document.querySelector(`#${o.contentId} .${N.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),o.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),o.config.onChange&&o.config.onChange(e)}}catch{const e=document.querySelector(`#${o.contentId} .${N.classNames.editor.jsonOutput}`);e&&(e.classList.add("clepit-json-error"),e.classList.remove("clepit-json-editable"))}}static destroy(t){const n=c.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${N.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},ms=/* @__PURE__ */new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),hs=(e,t)=>ms.has(`${e}.${t}`),gs=/* @__PURE__ */new Set(["checklist.items","list.items","table.data"]),bs=(e,t)=>gs.has(`${e}.${t}`),fs=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=vs(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},ys=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(bs(e,r)){const t=fs(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!hs(e,r)){i[r]=s;continue}const t=vs(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},vs=(e,t,n)=>{if(void 0===e)return null;if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},xs="clepit-theme-styles",ks=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",ws=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${is=S,Object.keys(A).map(e=>`@property ${A[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${is[e]};\n}`).join("\n\n")}\n\n@layer clepit.tokens {\n${E(S,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"rgba(240, 246, 252, 0.62)",codeSelectionBg:"rgba(124, 124, 255, 0.18)",codeString:"#7ee787",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",marker:"rgba(255, 224, 71, 0.28)",primary:"#7c7cff",primaryBg:"rgba(124, 124, 255, 0.14)",primaryHover:"#9494ff",selectionBg:"rgba(124, 124, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},ks)}\n\n${ks} {\n color-scheme: light;\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,Cs=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Error(`Container element with ID '${t.containerId}' not found`);return N.injectStyles(xs,ws),N.injectStyles(zt,Ht),N.injectStyles(fe,ye),n.classList.add(N.classNames.renderer.content),N.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Te.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Te.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=ys(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=O("div",N.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,l,c=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(c={...c,tooltipClassNames:n.editorClassNames.tooltips}),c?.margins&&(r=c.margins.top,s=c.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":l=bn.render(e.data,c,o,i);break;case"audio":l=kn.render(e.data,c,o,i);break;case"code":l=be.render(e.data,c,o,i);break;case"collapsible":l=ar.render(e.data,c,o,i);break;case"columns":l=Pn.render(e.data,c,o,i);break;case"date":l=Kn.render(e.data,c,o,i);break;case"delimiter":l=Xn.render(e.data,c,o,i);break;case"collection":l=jn.render(e.data,c,o,i);break;case"updates":l=Ji.render(e.data,c,o,i);break;case"glance":l=la.render(e.data,c,o,i);break;case"embed":l=Xe.render(e.data,{...c,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":l=ho.render(e.data,c,o,i);break;case"latex":l=Ui.render(e.data,c,o,i);break;case"mermaid":l=Vi.render(e.data,c,o,i);break;case"openapi":l=Qa.render(e.data,c,o,i);break;case"doc_card":l=ea.render(e.data,c,o,i);break;case"file":l=ia.render(e.data,c,o,i);break;case"header":l=pa.render(e.data,c,o,i);break;case"image":l=ba.render(e.data,c,o,i);break;case"list":l=Ca.render(e.data,c,o,i);break;case"checklist":l=En.render(e.data,c,o,i);break;case"paragraph":l=no.render(e.data,c,o,i);break;case"quote":l=ro.render(e.data,c,o,i);break;case"table":l=ko.render(e.data,c,o,i);break;case"toc":l=Eo.render(e.data,{...c,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":l=xa.render(e.data,{...c,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":l=Qi.render(e.data,c,o,i);break;default:l=null}return l?(a.appendChild(l),Jt.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},Ss=class{static render(e){const t=c.getState().getInstance(e);t&&Cs.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},As=class e{static create(t){return e.teardown(t.containerId),e.initialize(t),ls.create(t.containerId),e.render(t.containerId),mn.addListeners(t.containerId),ds.start(t.containerId),c.getState().setIsReady(t.containerId,!0),c.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>ss.convertBlock(e,n,t.containerId),count:()=>ss.getBlocks(t.containerId).length,get:e=>ss.getBlock(e)?ss.getBlockData(e):null,getAll:()=>ss.getBlocks(t.containerId).map(e=>ss.getBlockData(e.getAttribute("data-id"))),insert:(e,n,a,o)=>ss.insertBlock({data:n,id:o??Math.random().toString(36).substring(2,11),type:e},t.containerId,a),move:(e,n)=>ss.moveBlock(t.containerId,e,n),remove:e=>ss.removeBlock(t.containerId,e),update:(e,n)=>ss.updateBlockData(e,n,t.containerId)},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{c.getState().clearData(t.containerId),ss.destroy(t.containerId)},clearContent:()=>ss.destroy(t.containerId),clearStorage:()=>c.getState().clearData(t.containerId),extract:()=>ss.extractData(t.containerId),set:e=>ss.setBlocks(e.blocks,t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=ss.getBlocks(t.containerId)[0];e&&ss.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>rs.hide(t.containerId),hideToolbar:()=>ln.hide(t.containerId),showBlockMenu:e=>rs.show(t.containerId,e),showToolbar:(e,n)=>ln.show(t.containerId,e,n)},view:{getCurrentView:e=>c.getState().getCurrentView(e),switchView:(e,t)=>c.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;N.injectStyles(xs,ws),N.injectStyles("clepit-editor-container-styles",cs),N.injectStyles(Bt,$t),N.injectStyles(Wt,Kt),N.injectStyles(Dt,qt),N.injectStyles(fe,ye);const a={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t};n.className=N.classNames.editor.container,n.setAttribute("contenteditable","false"),Te.applyParts(n,a.issueChip),N.registerEditor(t.containerId,a.theme??"auto",a.themeOverrides),a.minHeight&&n.style.setProperty("--clepit-min-height",`${a.minHeight}px`),a.maxHeight&&n.style.setProperty("--clepit-max-height",`${a.maxHeight}px`),N.applyStyles(n,a.styles?.container),N.applyClassNames(n,a.classNames?.container),a.margins&&(void 0!==a.margins.top&&n.style.setProperty("--block-margin-top",`${a.margins.top}px`),void 0!==a.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${a.margins.bottom}px`));const o=`${a.containerId}-${N.idSuffixes.editorContent}`,i=O("div",N.classNames.editor.content);i.id=o,i.setAttribute("data-testid","editor-content-container"),i.setAttribute("data-container-id",t.containerId),N.applyStyles(i,a.styles?.editorContent),N.applyClassNames(i,a.classNames?.editorContent),n.appendChild(i),c.getState().addInstance(t.containerId,{config:a,contentId:o,currentView:a.initialView||"edit",data:e.localizeData(a.initialData,a),isReady:!1})}static localizeData(e,t){const n=e||{blocks:[],time:Date.now(),version:"1.0.0"},a=t.locale;if(!a)return n;const o=t.defaultLocale??a;return{...n,blocks:n.blocks.map(e=>{const n=e.data;for(const r of(e=>Array.from(ms).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(e.type)){const i=vs(n[r],a,o);i?.isFallback&&t.onLocaleFallback?.({blockId:e.id??"",field:r,requested:a,showing:i.locale})}const i=ys(e.type,n,a,o);return i===n?e:{...e,data:i}})}}static render(e){const t=c.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(us.destroy(e),n.innerHTML=""),"edit"===t.currentView?ps.render(e):"preview"===t.currentView?Ss.render(e):"json"===t.currentView&&us.render(e),t.config.onReady&&t.config.onReady()}static teardown(e){ds.stop(e),un.dismiss(e),mn.removeListeners(e),ls.destroy(e),rs.destroy(e),ln.destroy(e),ss.destroy(e),N.unregisterEditor(e);const t=document.getElementById(e);t&&(t.innerHTML="")}static destroy(t){e.teardown(t),c.getState().removeInstance(t)}},Es=e=>e.replace(/["\\]/g,"\\$&"),Ns=e=>e.flatMap(e=>"collapsible"===e.type?[e,...Ns(e.data.children??[])]:"columns"===e.type?[e,...Ns(e.data.columns?.flat()??[])]:[e]),Ls=(e,t)=>{const n=[];for(const a of Ns(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${Es(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?be.activate(t,a.data):"openapi"===a.type?Qa.activate(t):ko.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},Bs=/* @__PURE__ */new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),$s=/* @__PURE__ */new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),Is=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Ts=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g,Ms=e=>{const t=/* @__PURE__ */new Map;Ts.lastIndex=0;let n=Ts.exec(e);for(;null!==n;)t.set(n[1].toLowerCase(),n[2]??n[3]??n[4]??""),n=Ts.exec(e);return t},_s=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},Ds=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[],n=/<\/?([a-zA-Z][a-zA-Z0-9-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;let a=0,o=n.exec(e);for(;null!==o;){o.index>a&&t.push({type:"text",value:e.slice(a,o.index)});const i=o[1].toLowerCase();o[0].startsWith("</")?t.push({tag:i,type:"close"}):t.push({attributes:Ms(o[2]??""),selfClosing:(o[2]??"").trimEnd().endsWith("/"),tag:i,type:"open"}),a=o.index+o[0].length,o=n.exec(e)}return a<e.length&&t.push({type:"text",value:e.slice(a)}),t})(e)){if("text"===a.type){t.push(a.value);continue}if("close"===a.type){if(!Bs.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!Bs.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)$s.has(t)&&("href"!==t||_s(n))&&e.push(`${t}="${D(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||Is.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},qs=()=>[ws,hn,vn,Sn,Z,se(),In,qn,On,Un,Gn,Qn,$,aa,ra,ca,ma,ye,ka,Sa,eo,oo,co,bo,So,Bo,Gi,Zi].join("\n"),js=(e,t)=>{const n=j(Ds),a={...t,documentBlocks:t?.documentBlocks??e},o=e.map(e=>er(e,n,a)).filter(e=>null!==e).map(e=>z(e)).join("\n");return je(o,t?.issues,t?.issueChip,t?.issueLabels,Ds)},zs=(e,t)=>{const n=_(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<title>${n}</title>`,e.description?`<meta name="description" content="${D(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${D(e.canonicalUrl)}">`:"",...(e.alternates??[]).map(e=>`<link rel="alternate" hreflang="${D(e.hreflang)}" href="${D(e.href)}">`),`<meta property="og:title" content="${D(e.title)}">`,e.description?`<meta property="og:description" content="${D(e.description)}">`:"",`<style>${qs()}</style>`,e.notice?"<style>.clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}</style>":""].filter(Boolean);return["<!doctype html>",`<html lang="${D(e.locale??"en")}">`,`<head>${a.join("")}</head>`,"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,...e.notice?[`<aside class="clepit-public-page__notice" data-testid="public-page-notice" role="note"><p class="clepit-public-page__notice-title">${_(e.notice.title)}</p><p class="clepit-public-page__notice-body">${_(e.notice.body)}</p></aside>`]:[],js(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")};export{Yt as BLOCK_TOOLS,nn as CONTROL_LABELS,an as DIALOG_LABELS,Oe as EMBED_ENGLISH,tn as EMBED_LABELS,Pe as EMBED_TOOL_NAMES,b as EMBED_WIRE_KEYS,As as Editor,on as INLINE_REWRITE_ACTIONS,Zt as INLINE_TOOLS,ve as ISSUE_ENGLISH,en as ISSUE_LABELS,Qt as ISSUE_TOOLS,xe as ISSUE_TOOL_NAMES,Te as IssueChip,Cs as Renderer,N as StyleManager,ha as UploadRefusal,Ls as activateBlocks,qe as chipsInHtml,tt as classifyIssueUrl,T as domBacking,er as drawBlock,Re as embedLabel,f as isEmbedProviderDisabled,we as issueLabel,Ce as issueToolName,qs as pageStylesheet,Va as parseOpenApi,De as readChipMarkup,je as refreshChipsInHtml,js as renderBlocks,zs as renderPage,z as renderToString,k as resolveEmbed,Ds as sanitizeHtmlWithoutDom,j as stringBacking,H as toDomElement,E as tokensToLightDarkBlock};
|
|
1
|
+
import{a as e,i as t,n,r as a,t as o}from"./highlight-C4NcTcIm.mjs";var i=e=>{let t;const n=/* @__PURE__ */new Set,a=(e,a)=>{const o="function"==typeof e?e(t):e;if(Object.is(o,t))return;const i=t;t=a?o:Object.assign({},t,o);for(const r of n)r(t,i)},o=()=>t,i={getInitialState:()=>r,getState:o,setState:a,subscribe:e=>(n.add(e),()=>{n.delete(e)})},r=t=e(a,o,i);return i};var r,s,l,c=(l?i(l):i)((e=>(t,n,a)=>{const o=a.subscribe;return a.subscribe=(e,t,n)=>{if(!t)return o(e);const i=n?.equalityFn??Object.is;let r=e(a.getState());return n?.fireImmediately&&t(r,r),o(n=>{const a=e(n);if(!i(r,a)){const e=r;t(r=a,e)}})},e(t,n,a)})((e=>(t,n,a)=>e(t,n,a))((r=(e,t)=>({addBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=[...i.data.blocks];void 0===o||o<0||o>r.length?r.push(a):r.splice(o,0,a);const s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},addInstance:(n,a)=>{const o=t().instances;o[n]?o[n].config=a.config:o[n]=a,e({instances:o})},clearData:n=>{const a=t().instances[n];if(!a)return;const o={...a,data:{...a.data,blocks:[]}};e(e=>({instances:{...e.instances,[n]:o}})),a.config.onChange&&a.config.onChange(o.data)},getContentElement:e=>{const n=t().instances[e];return n?document.querySelector(`#${n.contentId}`):null},getCurrentView:e=>t().instances[e]?.currentView||null,getData:e=>t().instances[e]?.data||null,getInstance:e=>t().instances[e]||null,getIsReady:e=>{const n=t().instances[e];return!!n&&n.isReady},instances:{},partialUpdateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:{...e.data,...o}}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},removeBlock:(n,a)=>{const o=t().instances[n];if(!o)return;const i=o.data.blocks.filter((e,t)=>t!==a),r={...o,data:{...o.data,blocks:i}};e(e=>({instances:{...e.instances,[n]:r}})),o.config.onChange&&o.config.onChange(r.data)},removeInstance:t=>{e(e=>{const n={...e.instances};return delete n[t],{instances:n}})},seedBlocks:(n,a)=>{const o=t().instances[n];o&&e(e=>({instances:{...e.instances,[n]:{...o,data:{...o.data,blocks:a}}}}))},setCurrentView:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,currentView:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},setData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(a)},setIsReady:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,isReady:a};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateBlock:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,...o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateBlockData:(n,a,o)=>{const i=t().instances[n];if(!i)return;const r=i.data.blocks.map((e,t)=>t===a?{...e,data:o}:e),s={...i,data:{...i.data,blocks:r}};e(e=>({instances:{...e.instances,[n]:s}})),i.config.onChange&&i.config.onChange(s.data)},updateData:(n,a)=>{const o=t().instances[n];if(!o)return;const i={...o,data:{...o.data,...a}};e(e=>({instances:{...e.instances,[n]:i}})),o.config.onChange&&o.config.onChange(i.data)},updateInstance:(n,a)=>{const o=t().instances;o[n]&&(o[n].data=a.data,e({instances:o}))}}),s={name:"clepit-store",version:0},(e,t,n)=>{const a=s.version??0,o=s.storage??("undefined"==typeof localStorage?void 0:localStorage),i=s.merge??((e,t)=>Object.assign({},t,e)),l=r(e,t,n);if(o){try{const e=o.getItem(s.name);if(e){const t=JSON.parse(e),n=t.version===a?t.state:s.migrate?s.migrate(t.state,t.version??0):void 0;void 0!==n&&Object.assign(l,i(n,l))}}catch{}n.subscribe(e=>{try{o.setItem(s.name,JSON.stringify({state:s.partialize?s.partialize(e):e,version:a}))}catch{}})}return l})))),d=["http:","https:"],p=["youtube.com","www.youtube.com","m.youtube.com","youtu.be"],u=["file","design","board","proto","slides","deck"],m=["document","spreadsheets","presentation"],h=/^[0-9a-f]{32}$/,g=/^[A-Za-z0-9]+$/,b={figma:"figma",githubGist:"github_gist",googleDrive:"google_drive",loom:"loom",miro:"miro"};function f(e,t){const n=b[e];return void 0!==n&&(t??[]).includes(n)}var y=(e,t="link")=>({embedUrl:null,provider:t,url:e});function v(e,t){return e===t||e.endsWith(`.${t}`)}function x(e,t){const n=e.hostname.toLowerCase(),a=e.toString();if(p.includes(n)){const t=function(e){if(v(e.hostname,"youtu.be"))return e.pathname.slice(1).split("/")[0]||null;if("/watch"===e.pathname)return e.searchParams.get("v");const t=e.pathname.match(/^\/(?:embed|shorts|live)\/([^/]+)/);return t?t[1]:null}(e);return t?{aspect:16/9,embedUrl:`https://www.youtube.com/embed/${encodeURIComponent(t)}`,provider:"youtube",url:a}:y(a,"youtube")}if(v(n,"figma.com")){const[,t,n]=e.pathname.split("/");return t&&n&&u.includes(t)?{aspect:4/3,embedUrl:`https://embed.figma.com/${"file"===t?"design":t}/${encodeURIComponent(n)}?embed-host=clepit`,provider:"figma",url:a}:y(a,"figma")}if(v(n,"miro.com")){const t=e.pathname.match(/^\/app\/board\/([^/]+)/);return t?{aspect:16/9,embedUrl:`https://miro.com/app/live-embed/${encodeURIComponent(t[1])}`,provider:"miro",url:a}:y(a,"miro")}if(v(n,"loom.com")){const[,t,n]=e.pathname.split("/");return("share"===t||"embed"===t)&&n&&g.test(n)?{aspect:16/9,embedUrl:`https://www.loom.com/embed/${encodeURIComponent(n)}?hide_share=true`,provider:"loom",url:a}:y(a,"loom")}if("drive.google.com"===n){const t=e.pathname.match(/^\/file\/d\/([^/]+)/),n="/open"===e.pathname?e.searchParams.get("id"):null,o=t?.[1]??n;return o?{aspect:4/3,embedUrl:`https://drive.google.com/file/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:y(a,"googleDrive")}if("docs.google.com"===n){const[,t,n,o]=e.pathname.split("/");return t&&m.includes(t)&&"d"===n&&o?{aspect:4/3,embedUrl:`https://docs.google.com/${t}/d/${encodeURIComponent(o)}/preview`,provider:"googleDrive",url:a}:y(a,"googleDrive")}if("gist.github.com"===n){const[,t,n]=e.pathname.split("/");return t&&n&&h.test(n)?{embedUrl:null,gist:{id:n,owner:t},provider:"githubGist",url:a}:y(a,"githubGist")}if(v(n,"airtable.com")){const t=e.pathname.match(/^\/embed\/([^/]+)/),n=e.pathname.match(/^\/(shr[^/]+)/),o=t?.[1]??n?.[1];return o?{aspect:4/3,embedUrl:`https://airtable.com/embed/${encodeURIComponent(o)}`,provider:"airtable",url:a}:y(a,"airtable")}if(v(n,"diagrams.net")||v(n,"drawio.com"))return{aspect:4/3,embedUrl:`https://viewer.diagrams.net/?edit=_blank&layers=1&nav=1#U${encodeURIComponent(a)}`,provider:"drawio",url:a};if(v(n,"google.com")&&e.pathname.startsWith("/maps")){const n=t?.mapsEmbedKey,o=e.searchParams.get("q");return n&&o?{aspect:4/3,embedUrl:`https://www.google.com/maps/embed/v1/place?key=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,provider:"googleMaps",url:a}:y(a,"googleMaps")}return y(a)}function k(e,t){const n=function(e){try{const t=new URL(e);return d.includes(t.protocol)?t:null}catch{return null}}(e);if(!n)return{embedUrl:null,provider:"invalid",url:e};const a=x(n,t);return f(a.provider,t?.disabledProviders)?{embedUrl:null,provider:a.provider,switchedOff:!0,url:a.url}:a}async function w(e,t,n,a){const o=c.getState().getInstance(e)?.config,i=function(e,t){return{data:"card"===t?{display:"card",url:e}:{url:e},type:"embed"}}(a,"card"===(o?.pasteEmbeds??"live")?"card":"live");n?ss.replaceBlock(e,t,i):ss.insertBlock(i,e,t+1);const r=ss.getBlocks(e)[n?t:t+1]?.getAttribute("data-id")??null;return r&&o?.resolveLink&&await C(e,r,o.resolveLink),r}async function C(e,t,n){if(!n)return;const a=ss.getBlockData(t).data;try{const o=await n(a.url),{reason:i,...r}=a;ss.updateBlockData(t,{...r,...o,url:a.url},e)}catch{ss.updateBlockData(t,{...a,reason:"provider_unreachable"},e)}}var S={bg:"#ffffff",blockHighlightBg:"rgba(0, 0, 0, 0.05)",border:"rgba(17, 24, 39, 0.12)",borderSubtle:"rgba(17, 24, 39, 0.06)",codeBg:"#f2f4f7",codeBorder:"rgba(17, 24, 39, 0.10)",codeComment:"#868f9c",codeFunction:"#6f42c1",codeGutter:"#868f9c",codeKeyword:"#cf222e",codeNumber:"#0550ae",codePunctuation:"#525866",codeSelectionBg:"rgba(91, 91, 255, 0.14)",codeString:"#0a7c3e",codeText:"#0a0a0a",codeType:"#953800",error:"#dc2626",errorBg:"rgba(220, 38, 38, 0.08)",info:"#2563eb",infoBg:"rgba(37, 99, 235, 0.08)",marker:"#ffe047",primary:"#5b5bff",primaryBg:"rgba(91, 91, 255, 0.08)",primaryHover:"#4747e6",selectionBg:"rgba(91, 91, 255, 0.14)",success:"#16a34a",successBg:"rgba(22, 163, 74, 0.08)",surface:"#f8f9fa",surface2:"#f1f3f5",text:"#0a0a0a",textMuted:"#525866",textSubtle:"#868f9c",warning:"#d97706",warningBg:"rgba(217, 119, 6, 0.08)"},A={bg:"--clepit-bg",blockHighlightBg:"--clepit-block-highlight-bg",border:"--clepit-border",borderSubtle:"--clepit-border-subtle",codeBg:"--clepit-code-bg",codeBorder:"--clepit-code-border",codeComment:"--clepit-code-comment",codeFunction:"--clepit-code-function",codeGutter:"--clepit-code-gutter",codeKeyword:"--clepit-code-keyword",codeNumber:"--clepit-code-number",codePunctuation:"--clepit-code-punctuation",codeSelectionBg:"--clepit-code-selection-bg",codeString:"--clepit-code-string",codeText:"--clepit-code-text",codeType:"--clepit-code-type",error:"--clepit-error",errorBg:"--clepit-error-bg",info:"--clepit-info",infoBg:"--clepit-info-bg",marker:"--clepit-marker",primary:"--clepit-primary",primaryBg:"--clepit-primary-bg",primaryHover:"--clepit-primary-hover",selectionBg:"--clepit-selection-bg",success:"--clepit-success",successBg:"--clepit-success-bg",surface:"--clepit-surface",surface2:"--clepit-surface-2",text:"--clepit-text",textMuted:"--clepit-text-muted",textSubtle:"--clepit-text-subtle",warning:"--clepit-warning",warningBg:"--clepit-warning-bg"},E=(e,t,n)=>{const a=[];for(const o of Object.keys(A)){const n=e[o],i=t[o];if(void 0===n&&void 0===i)continue;const r=A[o];void 0!==n&&void 0!==i?a.push(` ${r}: light-dark(${n}, ${i});`):a.push(` ${r}: ${n??i};`)}return 0===a.length?"":`${n} {\n${a.join("\n")}\n}`},N=class e{static{this.idSuffixes={actionBar:{clearButton:"action-bar-clear-button",copyButton:"action-bar-copy-button",downloadButton:"action-bar-download-button",editButton:"edit-button",jsonButton:"json-button",previewButton:"preview-button"},editorContent:"content"}}static{this.classNames={actionBar:{action:"clepit-view-actions",actionButton:"clepit-view-action-button",button:"clepit-action-bar-button",container:"clepit-action-bar",copyFeedback:"clepit-view-action-button--copy-feedback",group:"clepit-action-bar-group"},block:{active:"clepit-block--active",alert:"clepit-alert",audio:{captionEditable:"clepit-audio-caption-editable",container:"clepit-audio-container",dropArea:"clepit-audio-drop-area",wrapper:"clepit-audio-wrapper"},audioDeleteBtn:"clepit-audio-delete-btn",checklist:{checkbox:"clepit-checklist-checkbox",container:"clepit-checklist",item:"clepit-checklist-item",text:"clepit-checklist-text"},code:{container:"clepit-code-container",editor:"clepit-code-editor",header:"clepit-code-header",headerWrapper:"clepit-code-header-wrapper"},container:"clepit-block",content:"clepit-block-content",header:"clepit-header",image:{captionEditable:"clepit-image-caption-editable",container:"clepit-image-container",dropArea:"clepit-image-drop-area",wrapper:"clepit-image-wrapper"},imageDeleteBtn:"clepit-image-delete-btn",indent1:"clepit-block-indent-1",indent2:"clepit-block-indent-2",indent3:"clepit-block-indent-3",link:"clepit-link",list:{container:"clepit-list",item:"clepit-list-item"},output:"clepit-output-block",paragraph:"clepit-paragraph",quote:{author:"clepit-quote-author",container:"clepit-quote-container",divider:"clepit-quote-divider",text:"clepit-quote-text"},table:{caption:"clepit-table-caption",cell:"clepit-table-cell",downloadSwitch:"clepit-table-download-switch",headerCell:"clepit-table-header-cell",headerRow:"clepit-table-header-row",row:"clepit-table-row"},tooltip:"clepit-tooltip",video:{captionEditable:"clepit-video-caption-editable",container:"clepit-video-container",dropArea:"clepit-video-drop-area",iframe:"clepit-video-iframe",video:"clepit-video",wrapper:"clepit-video-wrapper"},videoDeleteBtn:"clepit-video-delete-btn"},editor:{container:"clepit-editor",content:"clepit-editor-content",jsonEditable:"clepit-json-editable",jsonEmpty:"clepit-json-empty",jsonError:"clepit-json-error",jsonOutput:"clepit-json-output"},renderer:{content:"clepit-renderer-content"},switch:{container:"clepit-custom-switch"}}}static applyStyles(e,t){t&&"object"==typeof t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n)if(t.startsWith("--"))e.style.setProperty(t,String(n));else{const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}})}static applyClassNames(e,t){t&&("string"==typeof t?e.classList.add(t):Object.entries(t).forEach(([t,n])=>{n&&"string"==typeof n&&e.classList.add(n)}))}static applyStyling(t,n){const{styles:a,classNames:o}=n;if(a&&"object"==typeof a){const n=[],o={};Object.entries(a).forEach(([e,t])=>{void 0===t?n.push(e):o[e]=t}),Object.keys(o).length>0&&e.applyStyles(t,o),n.forEach(e=>t.style.removeProperty(e))}o&&e.applyClassNames(t,o)}static createStyledElement(t,n,a){const o=document.createElement(t);return o.className=n,a&&e.applyStyling(o,a),o}static injectStyles(e,t){if(document.getElementById(e))return!1;const n=document.createElement("style");return n.id=e,n.textContent=t,document.head.appendChild(n),!0}static{this.themeRegistry=/* @__PURE__ */new Map}static{this.themeSubscribers=/* @__PURE__ */new Set}static registerEditor(t,n,a){const o=document.getElementById(t);o&&(o.setAttribute("data-clepit-theme",n),o.setAttribute("data-clepit-instance",t)),e.themeRegistry.set(t,n),e.syncBodyThemeAttribute();const i=document.getElementById(`clepit-overrides-${t}`);if(i&&i.remove(),a){const n=E(a.light??{},a.dark??{},`[data-clepit-instance='${t}']`);n&&e.injectStyles(`clepit-overrides-${t}`,n)}e.ensureThemeListener()}static unregisterEditor(t){const n=document.getElementById(`clepit-overrides-${t}`);n&&n.remove();const a=document.getElementById(t);a&&(a.removeAttribute("data-clepit-theme"),a.removeAttribute("data-clepit-instance")),e.themeRegistry.delete(t),e.syncBodyThemeAttribute(),e.maybeDetachThemeListener()}static syncBodyThemeAttribute(){if("undefined"==typeof document||!document.body)return;const t=e.themeRegistry.values().next().value;t?document.body.setAttribute("data-clepit-theme",t):document.body.removeAttribute("data-clepit-theme")}static getResolvedTheme(){return"undefined"==typeof window||"function"!=typeof window.matchMedia?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}static subscribe(t){return e.themeSubscribers.add(t),e.ensureThemeListener(),()=>{e.themeSubscribers.delete(t),e.maybeDetachThemeListener()}}static unregisterAllEditorsForTest(){for(const t of Array.from(e.themeRegistry.keys()))e.unregisterEditor(t);e.themeSubscribers.clear(),e.maybeDetachThemeListener()}static ensureThemeListener(){"undefined"!=typeof window&&"function"==typeof window.matchMedia&&0!==e.themeSubscribers.size&&(e.themeMediaQuery||(e.themeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaQueryListener=t=>{const n=t.matches?"dark":"light";for(const a of e.themeSubscribers)a(n)},e.themeMediaQuery.addEventListener("change",e.themeMediaQueryListener)))}static maybeDetachThemeListener(){e.themeSubscribers.size>0||e.themeMediaQuery&&e.themeMediaQueryListener&&(e.themeMediaQuery.removeEventListener("change",e.themeMediaQueryListener),e.themeMediaQuery=void 0,e.themeMediaQueryListener=void 0)}},L="\n.clepit-embed {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-embed__frame {\n display: block;\n width: 100%;\n border: 0;\n}\n.clepit-embed-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-embed-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-embed-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-embed-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n.clepit-embed-card--with-reason {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-embed-card--with-reason > .clepit-embed-card {\n padding: 0;\n border: 0;\n}\n.clepit-embed-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-embed-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-embed--gist-frame .clepit-embed__frame {\n height: 552px;\n}\n.clepit-embed-gist {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n.clepit-embed-gist__file {\n display: flex;\n gap: 10px;\n align-items: baseline;\n font-size: 0.9em;\n}\n.clepit-embed-gist__file b {\n font-weight: 600;\n}\n.clepit-embed-gist__file a {\n margin-left: auto;\n color: inherit;\n opacity: 0.7;\n}\n.clepit-embed-offer {\n position: absolute;\n z-index: 20;\n display: inline-flex;\n gap: 6px;\n align-items: center;\n padding: 4px 4px 4px 10px;\n font-size: 12px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 999px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-embed-offer button {\n padding: 3px 9px;\n font: inherit;\n font-weight: 600;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border: 0;\n border-radius: 999px;\n cursor: pointer;\n}\n",B=L,$=L,I=class{constructor(e){this.node=e}get tag(){return this.node.tagName.toLowerCase()}setAttribute(e,t){this.node.setAttribute(e,t)}addClass(...e){this.node.classList.add(...e.filter(Boolean))}setText(e){this.node.textContent=e}setHtml(e){this.node.innerHTML=e}append(e){this.node.appendChild(e.node)}appendText(e){this.node.appendChild(document.createTextNode(e))}},T={create:e=>new I(document.createElement(e)),createNS:(e,t)=>new I(document.createElementNS(e,t))},M=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),_=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),D=e=>e.replace(/&/g,"&").replace(/"/g,"""),q=class{constructor(e,t){this.tag=e,this.sanitize=t,this.attributes=/* @__PURE__ */new Map,this.classes=[],this.children=[]}setAttribute(e,t){this.attributes.set(e,t)}addClass(...e){for(const t of e.filter(Boolean))this.classes.includes(t)||this.classes.push(t)}setText(e){this.children.length=0,this.children.push(_(e))}setHtml(e){this.children.length=0,this.children.push(this.sanitize(e))}append(e){this.children.push(e.toString())}appendText(e){this.children.push(_(e))}toString(){const e=[...this.classes.length>0?[`class="${D(this.classes.join(" "))}"`]:[],...[...this.attributes].map(([e,t])=>`${e}="${D(t)}"`)],t=[this.tag,...e].join(" ");return M.has(this.tag)?`<${t}>`:`<${t}>${this.children.join("")}</${this.tag}>`}},j=e=>({create:t=>new q(t,e),createNS:(t,n)=>new q(n,e)}),z=e=>String(e),H=e=>{if(!(e instanceof I))throw new TypeError("toDomElement needs an element built by the dom backing");return e.node};function O(e,t,n){const a=document.createElement(e);if(t&&(a.className=t),n)for(const[o,i]of Object.entries(n))a.setAttribute(o,i);return a}function P(e,t){return`${e}-${t}`}function R(e){return!e||!e.trim()||"<br>"===e}function F(e){if(!e||R(e))return"";const t=document.createElement("div");t.innerHTML=e;const n=["strong","b","em","i","u","s","del","mark","code","a","span"],a=["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"];function o(e){if(e.nodeType===Node.TEXT_NODE)return e.cloneNode(!0);if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.tagName.toLowerCase();if(!n.includes(i))return document.createTextNode(t.textContent||"");const r=document.createElement(i);for(const e of t.attributes)a.includes(e.name.toLowerCase())&&r.setAttribute(e.name,e.value);"a"===i&&(r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer"));for(const e of Array.from(t.childNodes)){const t=o(e);t&&r.appendChild(t)}return r}return null}const i=document.createElement("div");for(const r of Array.from(t.childNodes)){const e=o(r);e&&i.appendChild(e)}return i.innerHTML}function U(e,t){const n=window.getSelection();if(!n||0===n.rangeCount)return!1;const a=n.getRangeAt(0);if(!a)return!1;if(!e.contains(a.commonAncestorContainer))return!1;if(0===(e.textContent||"").length)return!0;if("left"===t){const t=e.firstChild;return t&&t.nodeType===Node.TEXT_NODE?a.startContainer===t&&0===a.startOffset:a.startContainer===e&&0===a.startOffset}{const t=e.lastChild;return t&&t.nodeType===Node.TEXT_NODE?a.endContainer===t&&a.endOffset===t.textContent?.length:a.endContainer===e&&a.endOffset===e.childNodes.length}}function V(){N.injectStyles("clepit-invalid-data-styles","\n/* Invalid data component styles */\n.clepit-invalid-data {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n background: #ffebee;\n color: #c62828;\n}\n\n.clepit-invalid-data-text {\n font-weight: bold;\n margin: 0;\n padding: 0;\n}\n");const e=O("div","clepit-invalid-data"),t=O("div","clepit-invalid-data-text");return t.textContent="Invalid data",e.appendChild(t),e}var W={assembly:"Assembly",bash:"Bash",clojure:"Clojure",cobol:"COBOL",cpp:"C++",csharp:"C#",css:"CSS",dart:"Dart",diff:"Diff",dockerfile:"Dockerfile",erlang:"Erlang",fortran:"Fortran",go:"Go",graphql:"GraphQL",groovy:"Groovy",haskell:"Haskell",html:"HTML",java:"Java",javascript:"JavaScript",json:"JSON",jsx:"JSX",julia:"Julia",kotlin:"Kotlin",lua:"Lua",markdown:"Markdown",nginx:"Nginx",objectivec:"Objective-C",pascal:"Pascal",perl:"Perl",php:"PHP",plaintext:"Plain Text",powershell:"PowerShell",protobuf:"Protocol Buffers",python:"Python",r:"R",ruby:"Ruby",rust:"Rust",scala:"Scala",scheme:"Scheme",shell:"Shell",sql:"SQL",swift:"Swift",toml:"TOML",tsx:"TSX",typescript:"TypeScript",vb:"Visual Basic",verilog:"Verilog",vhdl:"VHDL",xml:"XML",yaml:"YAML"};function K(e){return W[e]||"Unknown"}var G=Object.fromEntries(Object.keys(n).map(e=>[e,{name:K(e)}])),J=`\n/* Code block styles */\n.clepit-code {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-code-pre {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="code"] .clepit-block-content {\n background: transparent;\n border: none;\n padding: 0;\n margin-right: 8px;\n}\n\n/* Code placeholder styles */\n.clepit-code[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Code container */\n.${N.classNames.block.code.container} {\n border: 1px solid var(--clepit-code-border);\n background: var(--clepit-code-bg);\n border-radius: 6px;\n overflow: visible; /* allow header tooltips to escape */\n margin: 8px 0;\n}\n\n.${N.classNames.block.code.editor} {\n height: 200px;\n max-height: 60vh;\n min-height: 200px;\n overflow: hidden;\n position: relative;\n}\n\n/* The editing surface: a textarea laid over a highlighted pre. The two must\n * agree on every metric that affects where a glyph lands, or the caret drifts\n * away from the colour behind it. They inherit from one rule for that reason. */\n.${N.classNames.block.code.editor} .clepit-code-highlight,\n.${N.classNames.block.code.editor} .clepit-code-input {\n margin: 0;\n border: 0;\n padding: 12px 34px;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n letter-spacing: normal;\n tab-size: 2;\n white-space: pre;\n overflow: auto;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.code.editor} .clepit-code-highlight {\n position: absolute;\n inset: 0;\n pointer-events: none;\n color: var(--clepit-code-text);\n}\n\n/* The text itself is transparent: the colour the reader sees belongs to the pre\n * behind it. The caret keeps a colour of its own so it stays visible. */\n.${N.classNames.block.code.editor} .clepit-code-input {\n position: relative;\n width: 100%;\n height: 100%;\n display: block;\n background: transparent;\n color: transparent;\n caret-color: var(--clepit-code-text);\n resize: none;\n outline: none;\n}\n\n.${N.classNames.block.code.editor} .clepit-code-input::placeholder {\n color: var(--clepit-text-muted);\n}\n\n.${N.classNames.block.code.editor} .clepit-code-input::selection {\n background: var(--clepit-code-selection-bg);\n color: transparent;\n}\n\n/* Code header */\n.${N.classNames.block.code.headerWrapper} {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 8px 34px;\n position: relative; /* allow inner tooltip absolute positioning */\n overflow: visible; /* ensure tooltip not clipped */\n z-index: 2;\n border-bottom: 1px solid var(--clepit-border-color);\n}\n\n.${N.classNames.block.code.header} {\n font-size: 12px;\n font-weight: 500;\n}\n\n/* Code Language Submenu */\n.clepit-code-language-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 160px;\n max-width: 200px;\n margin-left: 4px;\n max-height: 300px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-language-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-language-submenu--hidden {\n display: none !important;\n}\n\n/* Code Theme Submenu */\n.clepit-code-theme-submenu {\n position: absolute;\n top: 0;\n left: 100%;\n z-index: 1002;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n max-width: 180px;\n margin-left: 4px;\n max-height: 250px;\n overflow-y: auto;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-code-theme-submenu--visible {\n display: block !important;\n transform: translateX(0);\n}\n\n.clepit-code-theme-submenu--hidden {\n display: none !important;\n}\n\n/* Code language submenu items */\n.clepit-code-language-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-language-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n/* Code theme submenu items */\n.clepit-code-theme-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.clepit-code-theme-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-surface));\n}\n\n\n`,X="clepit-code-output-styles",Z="\n/* Output Code Block */\n/* No margin of its own — every consumer already governs the gap around this\n * container (page rhythm via the block wrapper's margin-block, or a flex\n * container's gap inside the openapi block). A margin here just adds a second,\n * inconsistent gap on top of whichever one the consumer already applies. */\n.clepit-output-code-container {\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n background: var(--clepit-code-bg);\n margin: 0;\n}\n\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n padding: 8px 34px;\n border-bottom: 1px solid var(--clepit-code-border);\n font-size: 12px;\n color: var(--clepit-text-muted);\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* Output header — theme-agnostic; tokens handle light/dark automatically */\n.clepit-output-code-header {\n background: var(--clepit-code-bg);\n color: var(--clepit-text-muted);\n border-bottom-color: var(--clepit-code-border);\n --clepit-svg-stroke-color: var(--clepit-text-muted);\n --clepit-btn-hover-bg: var(--clepit-block-highlight-bg);\n}\n\n/* Output code variant tabs */\n.clepit-output-code-tabs {\n display: flex;\n align-items: stretch;\n gap: 4px;\n margin: -8px 0 -8px -18px;\n overflow-x: auto;\n scrollbar-width: none;\n}\n\n.clepit-output-code-tabs::-webkit-scrollbar {\n display: none;\n}\n\n.clepit-output-code-tab {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: none;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font: inherit;\n padding: 8px 10px;\n transition: color 0.2s ease, border-color 0.2s ease;\n white-space: nowrap;\n}\n\n.clepit-output-code-tab:hover {\n color: var(--clepit-text);\n}\n\n.clepit-output-code-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n.clepit-output-code-editor {\n overflow: auto;\n max-height: 60vh;\n position: relative;\n border: none;\n border-radius: 0;\n}\n\n/* The output panes: one pre per variant, the inactive ones carrying a hidden attribute.\n * Colour comes from the generated theme stylesheet, keyed on the container's\n * data-theme, so a published page keeps its palette with nothing running. */\n.clepit-output-code-pane {\n margin: 0;\n padding: 12px 34px;\n max-height: 60vh;\n overflow: auto;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n tab-size: 2;\n white-space: pre;\n}\n\n/* Code Output */\n.clepit-output-code {\n margin: 1rem 0;\n background-color: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n overflow: hidden;\n}\n\n.clepit-output-code code {\n display: block;\n padding: 1rem;\n font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;\n font-size: 0.875rem;\n line-height: 1.5;\n color: var(--clepit-code-text);\n overflow-x: auto;\n white-space: pre;\n}\n\n/* Output code copy button */\n.clepit-output-code-copy-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-code-copy-btn {\n color: var(--clepit-text-muted);\n}\n\n.clepit-output-code-copy-btn:hover {\n background: var(--clepit-block-highlight-bg);\n color: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:hover .clepit-copy-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-code-copy-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-copy-icon,\n.clepit-check-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-svg-stroke-color);\n stroke-width: 2;\n fill: none;\n display: block;\n}\n\n/* Code output button animation styles */\n.clepit-output-code-copy-btn--animating {\n color: var(--clepit-success);\n transform: scale(1.1);\n}\n\n.clepit-output-code-copy-btn--normal {\n color: var(--clepit-svg-stroke-color);\n transform: scale(1);\n}\n",Y=(e,t,n)=>c.getState().getInstance(e)?.config.blockToolbarLabels?.[t]||n,Q={auto:"Auto",dark:"Dark",default:"Auto",dracula:"Dracula",github:"GitHub","github-dark":"GitHub Dark",light:"Light",monokai:"Monokai",solarized:"Solarized","solarized-dark":"Solarized Dark",tomorrow:"Tomorrow"};function ee(e){return Q[e]||"Unknown"}var te=Object.fromEntries(Object.keys(Q).map(e=>[e,{name:ee(e),theme:null}])),ne=`\n/* Custom Switch Container */\n.${N.classNames.switch.container} {\n --switch-blue: #0D7EFF;\n --switch-red: #FF0D0D;\n --switch-text: var(--clepit-bg);\n --switch-white: var(--clepit-bg);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n}\n\n.${N.classNames.switch.container} .tgl {\n display: none;\n}\n\n.${N.classNames.switch.container} .tgl,\n.${N.classNames.switch.container} .tgl:after,\n.${N.classNames.switch.container} .tgl:before,\n.${N.classNames.switch.container} .tgl *,\n.${N.classNames.switch.container} .tgl *:after,\n.${N.classNames.switch.container} .tgl *:before,\n.${N.classNames.switch.container} .tgl + .tgl-btn {\n box-sizing: border-box;\n}\n\n.${N.classNames.switch.container} .tgl::selection,\n.${N.classNames.switch.container} .tgl:after::selection,\n.${N.classNames.switch.container} .tgl:before::selection,\n.${N.classNames.switch.container} .tgl *::selection,\n.${N.classNames.switch.container} .tgl *:after::selection,\n.${N.classNames.switch.container} .tgl *:before::selection,\n.${N.classNames.switch.container} .tgl + .tgl-btn::selection {\n background: none;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn {\n outline: 0;\n display: block;\n width: 57px;\n height: 27px;\n position: relative;\n cursor: pointer;\n user-select: none;\n font-size: 12px;\n font-weight: 400;\n color: var(--switch-white);\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:after,\n.${N.classNames.switch.container} .tgl + .tgl-btn:before {\n position: relative;\n display: block;\n content: "";\n width: 44%;\n height: 100%;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:after {\n left: 0;\n}\n\n.${N.classNames.switch.container} .tgl + .tgl-btn:before {\n display: inline;\n position: absolute;\n top: 3px;\n}\n\n.${N.classNames.switch.container} .tgl:checked + .tgl-btn:after {\n left: 56.5%;\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn {\n background: var(--switch-red);\n border-radius: 20rem;\n padding: 2px;\n transition: all 0.4s ease;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:after {\n border-radius: 2em;\n background: var(--switch-white);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.2);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:before {\n content: "No";\n left: 30px;\n color: var(--switch-text);\n transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios + .tgl-btn:active:after {\n padding-right: 0.4em;\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn {\n background: var(--switch-blue);\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active {\n box-shadow: inset 0 0 0 30px rgba(0, 0, 0, 0.1);\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:active:after {\n margin-left: -0.4em;\n}\n\n.${N.classNames.switch.container} .tgl-ios:checked + .tgl-btn:before {\n content: "Yes";\n left: 6px;\n color: var(--switch-white);\n}\n\n.clepit-switch-label-text {\n font-size: 13px;\n display: flex;\n align-items: center;\n}\n`,ae=class{static create(e={}){const{checked:t=!1,onToggle:n,classNames:a,styles:o,label:i,id:r=`switch-${Math.random().toString(36).substring(2,11)}`}=e;N.injectStyles("clepit-custom-switch-styles",ne);const s=N.createStyledElement("div",N.classNames.switch.container,{classNames:a?.container,styles:o?.container}),l=N.createStyledElement("input","tgl tgl-ios",{classNames:a?.input,styles:o?.input});l.type="checkbox",l.id=r,l.checked=t;const c=N.createStyledElement("label","tgl-btn",{classNames:a?.label,styles:o?.label});if(c.setAttribute("for",r),n&&l.addEventListener("change",e=>{const t=e.target;n(t.checked)}),s.appendChild(l),s.appendChild(c),i){const e=N.createStyledElement("span","clepit-switch-label-text",{classNames:a?.labelText,styles:o?.labelText});e.textContent=i,s.appendChild(e)}return s}static getState(e){const t=e.querySelector('input[type="checkbox"]');return!!t&&t.checked}static setState(e,t){const n=e.querySelector('input[type="checkbox"]');n&&(n.checked=t)}},oe=class e{static{this.placeholder="Enter code..."}static{this.supportedLanguages=G}static{this.supportedThemes=te}static{this.defaultLanguage="typescript"}static{this.defaultTheme="auto"}static{this.inputMap=/* @__PURE__ */new WeakMap}static{this.dataMap=/* @__PURE__ */new WeakMap}static save(t){const n=t.querySelector(`.${N.classNames.block.code.container}`),a=n.querySelector(`.${N.classNames.block.code.headerWrapper}`),o=n?.getAttribute("data-language")||e.defaultLanguage,i=n?.getAttribute("data-theme")||e.defaultTheme,r=!!a&&ae.getState(a),s=e.inputMap.get(n);if(s){const t=s.value,a=e.dataMap.get(n),l={code:t.trim()||"",language:o,showCopy:r,theme:i};return a?.variants?.length&&(l.variants=a.variants),a?.syncKey&&(l.syncKey=a.syncKey),e.dataMap.set(n,l),l}return{...e.dataMap.get(n)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme},showCopy:r}}static addVariant(e){const t=e.variants?.length?e.variants:[{code:e.code,...e.language?{language:e.language}:{}}];return{...e,variants:[...t,{code:""}]}}static removeVariant(e,t){const n=(e.variants??[]).filter((e,n)=>n!==t),a=n[0],o={...e,code:a?.code??e.code,...a?.language?{language:a.language}:{}};if(n.length<=1){const{variants:e,...t}=o;return t}return{...o,variants:n}}static render(t,n,a,o){N.injectStyles("clepit-code-input-styles",J);const i={code:"",language:o?.language||e.defaultLanguage,showCopy:!0,theme:o?.theme||e.defaultTheme},r=n?{...i,...n}:i,s=N.createStyledElement("div",N.classNames.block.code.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});s.setAttribute("data-language",r.language||e.defaultLanguage),s.setAttribute("data-theme",r.theme||e.defaultTheme);const l=N.createStyledElement("div",N.classNames.block.code.headerWrapper,{classNames:a?.classNames?.header?.wrapper,styles:a?.styles?.header?.wrapper}),d=N.createStyledElement("div",N.classNames.block.code.header,{classNames:a?.classNames?.header?.text,styles:a?.styles?.header?.text}),p=G[r.language]?.name||K(e.defaultLanguage),u=te[r.theme]?.name||ee(e.defaultTheme);d.textContent=e.getHeaderText(p,u);const m=N.createStyledElement("div",N.classNames.block.code.editor,{classNames:a?.classNames?.container,styles:a?.styles?.container});m.setAttribute("data-placeholder",Y(t,"codeHint",e.placeholder));const h=t?c.getState().getInstance(t):null,g=h?.config.classNames?.switch,b=h?.config.styles?.switch,f=ae.create({checked:r.showCopy||!1,classNames:g,label:"Allow copy",onToggle:t=>{const n=e.dataMap.get(s)||{code:"",language:e.defaultLanguage,theme:e.defaultTheme};e.dataMap.set(s,{...n,showCopy:t}),ss.saveBlockData(s)},styles:b});return l.appendChild(d),l.appendChild(f),s.appendChild(l),s.appendChild(m),e.mountEditor(s,m,r),s}static mountEditor(t,n,a){const o=a.language??e.defaultLanguage,i=document.createElement("pre");i.className="clepit-code-highlight",i.setAttribute("aria-hidden","true");const r=document.createElement("code");i.appendChild(r);const s=document.createElement("textarea");s.className="clepit-code-input",s.value=a.code??"",s.spellcheck=!1,s.autocapitalize="off",s.setAttribute("autocorrect","off"),s.setAttribute("data-testid","code-input"),s.setAttribute("aria-label",`${K(o)} code`),s.placeholder=n.getAttribute("data-placeholder")||e.placeholder,n.replaceChildren(i,s),e.inputMap.set(t,s),e.dataMap.set(t,a),e.paint(t,r,s.value),s.addEventListener("input",()=>{e.paint(t,r,s.value);const n=e.dataMap.get(t)??{code:"",language:t.getAttribute("data-language")||e.defaultLanguage,theme:t.getAttribute("data-theme")||e.defaultTheme};e.dataMap.set(t,{...n,code:s.value}),ss.saveBlockData(t)}),s.addEventListener("scroll",()=>{i.scrollTop=s.scrollTop,i.scrollLeft=s.scrollLeft}),s.addEventListener("keydown",n=>e.handleKeydown(t,s,n))}static paint(t,n,a){const i=t.getAttribute("data-language")||e.defaultLanguage;n.replaceChildren(...o(a.endsWith("\n")?`${a} `:a,i).map(e=>{const t=document.createElement("span");return e.classes&&(t.className=e.classes),t.textContent=e.text,t}))}static updateLanguage(t,n){const a=t.querySelector(`.${N.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${N.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-language",n);const i=a.querySelector(`.${N.classNames.block.code.header}`),r=a.getAttribute("data-theme")||e.defaultTheme,s=ee(r),l=K(n);i&&(i.textContent=e.getHeaderText(l,s));const c=e.inputMap.get(a);c&&e.mountEditor(a,o,{code:c.value,language:n,theme:r}),ss.saveBlockData(a)}static updateTheme(t,n){const a=t.querySelector(`.${N.classNames.block.code.container}`);if(!a)return;const o=t.querySelector(`.${N.classNames.block.code.editor}`);if(!o)return;a.setAttribute("data-theme",n);const i=a.querySelector(`.${N.classNames.block.code.header}`),r=a.getAttribute("data-language")||e.defaultLanguage,s=K(r),l=ee(n);i&&(i.textContent=e.getHeaderText(s,l));const c=e.inputMap.get(a);c&&e.mountEditor(a,o,{code:c.value,language:r,theme:n}),ss.saveBlockData(a)}static handleKeydown(e,t,n){const a=e.closest(`.${N.classNames.block.container}`);if(!a)return;const o=ss.getEditorId(a);if(!o)return;const i=ss.getBlockIndex(o,a.getAttribute("data-id")),r=n.metaKey||n.ctrlKey;return"Enter"!==n.key||n.shiftKey?"Backspace"===n.key&&r||"Delete"===n.key&&r?(n.preventDefault(),void ss.removeBlock(o,i)):"Backspace"!==n.key||""!==t.value.trim()?"ArrowUp"===n.key?(n.preventDefault(),void(n.shiftKey?ss.moveBlock(o,i,i-1):ss.focusBlock(a.previousElementSibling))):void("ArrowDown"===n.key&&(n.preventDefault(),n.shiftKey?ss.moveBlock(o,i,i+1):ss.focusBlock(a.nextElementSibling))):void ss.removeBlock(o,i):(n.preventDefault(),void ss.insertBlock({data:{html:""},type:"paragraph"},o,i+1))}static getHeaderText(e,t){return`${e} | ${t}`}static isEmpty(t){const n=t.querySelector(`.${N.classNames.block.code.container}`);if(!n)return!0;const a=e.inputMap.get(n);return!a||Boolean(a.value?.trim())}static isEmptyData(e){return R(e.code)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeInput::destroy: Container not found for containerId:",t);n.querySelectorAll(`.${N.classNames.block.code.container}`).forEach(t=>{e.inputMap.delete(t),e.dataMap.delete(t)})}},ie=".clepit-output-code-container",re=(e,n)=>[`${e} { background: ${n.background}; color: ${n.text}; }`,...t.map(t=>`${e} .clepit-code-${t} { color: ${n[t]};${(e=>"comment"===e?" font-style: italic;":"")(t)} }`)].join("\n"),se=()=>[re(ie,e()),...Object.entries(a).map(([e,t])=>re(`${ie}[data-theme='${e}']`,t))].join("\n"),le="clepit:code-variant-sync",ce=e=>`clepit.code-variant.${e}`,de=(e,t)=>e.label?e.label:e.language?W[e.language]??e.language:`Tab ${t+1}`,pe=(e,t)=>{if(!t)return 0;const n=e.findIndex((e,n)=>de(e,n)===t);return-1===n?0:n},ue=e=>{if(!e||"undefined"==typeof localStorage)return null;try{return localStorage.getItem(ce(e))}catch{return null}};function me(e,t,n="below",a,o){let i=null,r=null;const s=()=>{if(i)return;N.injectStyles("clepit-inline-tooltip-styles","\n/* Inline Tooltip Container */\n.clepit-inline-tooltip {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.2s ease-in-out;\n}\n\n/* Tooltip Content */\n.clepit-inline-tooltip-content {\n background: var(--clepit-text);\n color: var(--clepit-bg);\n padding: 6px 10px;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n white-space: nowrap;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transform: translateY(8px);\n transition: transform 0.2s ease-in-out;\n position: relative;\n}\n\n/* Tooltip Arrow */\n.clepit-inline-tooltip-arrow {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n/* Arrow pointing down (when tooltip is above target) */\n.clepit-inline-tooltip-arrow--above {\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-top: 6px solid var(--clepit-text);\n}\n\n/* Arrow pointing up (when tooltip is below target) */\n.clepit-inline-tooltip-arrow--below {\n bottom: 100%;\n left: 50%;\n transform: translateX(-50%);\n border-left: 6px solid transparent;\n border-right: 6px solid transparent;\n border-bottom: 6px solid var(--clepit-text);\n}\n"),i=document.createElement("div"),i.className=`clepit-inline-tooltip ${a?.container||""}`,N.applyStyling(i,{styles:o?.container});const s=document.createElement("div");s.className=`clepit-inline-tooltip-content ${a?.content||""}`,s.textContent=t,N.applyStyling(s,{styles:o?.content});const c=document.createElement("div");c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${n} ${a?.arrow||""}`,N.applyStyling(c,{styles:o?.arrow}),s.appendChild(c),i.appendChild(s),document.body.appendChild(i);const d=e.getBoundingClientRect(),p=s.offsetWidth,u=s.offsetHeight;let m,h=d.left+d.width/2-p/2;h=Math.max(8,Math.min(h,window.innerWidth-p-8));let g=n;"below"===n?(m=d.bottom+6+2,m+u>window.innerHeight-8&&(m=d.top-u-6-2,g="above")):(m=d.top-u-6-2,m<8&&(m=d.bottom+6+2,g="below")),c.className=`clepit-inline-tooltip-arrow clepit-inline-tooltip-arrow--${g} ${a?.arrow||""}`,i.style.left=`${h}px`,i.style.top=`${Math.max(8,Math.min(m,window.innerHeight-u-8))}px`,requestAnimationFrame(()=>{i&&(i.style.opacity="1",s.style.transform="translateY(0)")}),r||(r=new MutationObserver(()=>{document.body.contains(e)&&e.isConnected||(l(),r&&(r.disconnect(),r=null))}),r.observe(document.body,{childList:!0,subtree:!0}))},l=()=>{i&&(i.style.opacity="0",setTimeout(()=>{i&&i.parentElement&&i.parentElement.removeChild(i),i=null,r&&(r.disconnect(),r=null)},120))};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",l),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",l),l()}}var he="http://www.w3.org/2000/svg",ge=e=>e.variants?.length?e.variants:[{code:e.code,language:e.language}],be=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static draw(t,n=T,a){if(!e.validate(t)||oe.isEmptyData(t))return null;const i=ge(t),r=i.length>1,s=Math.min(Math.max(a?.activeVariant??0,0),i.length-1),l=n.create("div");l.addClass("clepit-output-code-container"),l.setAttribute("data-theme",t.theme??oe.defaultTheme),t.syncKey&&l.setAttribute("data-sync-key",t.syncKey);const c=n.create("div");if(c.addClass("clepit-output-code-header"),r){const e=n.create("div");e.addClass("clepit-output-code-tabs"),e.setAttribute("role","tablist"),e.setAttribute("data-testid","code-variant-tabs"),i.forEach((t,a)=>{const o=n.create("button");o.addClass("clepit-output-code-tab"),o.setAttribute("type","button"),o.setAttribute("role","tab"),o.setAttribute("aria-selected",a===s?"true":"false"),o.setAttribute("tabindex",a===s?"0":"-1"),o.setAttribute("data-testid",`code-variant-tab-${a}`),o.setText(de(t,a)),e.append(o)}),c.append(e)}else{const e=n.create("span");e.setText(W[t.language??"typescript"]??"TypeScript"),c.append(e)}if(t.showCopy){const e=n.create("button");e.addClass("clepit-output-code-copy-btn"),e.setAttribute("type","button"),e.setAttribute("aria-label","Copy code"),e.append((e=>{const t=e.createNS(he,"svg");t.setAttribute("class","clepit-copy-icon"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const n=e.createNS(he,"path");return n.setAttribute("d","M7.5 3H14.6C16.8402 3 17.9603 3 18.816 3.43597C19.5686 3.81947 20.1805 4.43139 20.564 5.18404C21 6.03969 21 7.15979 21 9.4V16.5M6.2 21H14.3C15.4201 21 15.9802 21 16.408 20.782C16.7843 20.5903 17.0903 20.2843 17.282 19.908C17.5 19.4802 17.5 18.9201 17.5 17.8V9.7C17.5 8.57989 17.5 8.01984 17.282 7.59202C17.0903 7.21569 16.7843 6.90973 16.408 6.71799C15.9802 6.5 15.4201 6.5 14.3 6.5H6.2C5.0799 6.5 4.51984 6.5 4.09202 6.71799C3.71569 6.90973 3.40973 7.21569 3.21799 7.59202C3 8.01984 3 8.57989 3 9.7V17.8C3 18.9201 3 19.4802 3.21799 19.908C3.40973 20.2843 3.71569 20.5903 4.09202 20.782C4.51984 21 5.0799 21 6.2 21Z"),n.setAttribute("stroke","var(--clepit-svg-stroke-color)"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.append(n),t})(n)),c.append(e)}l.append(c);const d=n.create("div");return d.addClass("clepit-output-code-editor"),r&&d.setAttribute("role","tabpanel"),i.forEach((e,a)=>{const i=n.create("pre");i.addClass("clepit-output-code-pane"),i.setAttribute("data-variant-index",String(a)),a!==s&&i.setAttribute("hidden","");const r=n.create("code");for(const s of o(e.code??t.code,e.language??t.language??"plaintext")){const e=n.create("span");s.classes&&e.addClass(...s.classes.split(" ")),e.setText(s.text),r.append(e)}i.append(r),d.append(i)}),l.append(d),l}static render(t,n,a,o,i){if(N.injectStyles(X,Z),N.injectStyles(`${X}-theme`,se()),!e.validate(t))return V();if(oe.isEmptyData(t))return document.createElement("div");const r=ge(t),s=r.length>1?pe(r,ue(t.syncKey)):0,l=H(e.draw(t,T,{activeVariant:s}));o?.container&&l.classList.add(o.container),a?.container&&Object.assign(l.style,a.container);const c=l.querySelector(".clepit-output-code-header");return c&&o?.header?.text&&c.classList.add(o.header.text),c&&a?.header?.text&&Object.assign(c.style,a.header.text),e.attach(l,t,s,i),l}static activate(t,n){if(!e.validate(n)||oe.isEmptyData(n))return()=>{};const a=ge(n),o=a.length>1?pe(a,ue(n.syncKey)):0;return e.attach(t,n,o,void 0,!0)}static activateFromMarkup(t){const n=[...t.querySelectorAll(".clepit-output-code-pane")];if(0===n.length)return()=>{};const a=[...t.querySelectorAll(".clepit-output-code-tab")],o=n.map((e,t)=>({code:e.textContent??"",label:a[t]?.textContent||void 0})),i=t.getAttribute("data-sync-key")??void 0,r={code:o[0]?.code??"",showCopy:null!==t.querySelector(".clepit-output-code-copy-btn"),syncKey:i,variants:o},s=o.length>1?pe(o,ue(i)):0;return e.attach(t,r,s,void 0,!0)}static attach(t,n,a,o,i=!1){const r=ge(n),s=o?document.getElementById(o):null,l=[...t.querySelectorAll(".clepit-output-code-tab")],d=[...t.querySelectorAll(".clepit-output-code-pane")];let p=a;const u=[];let m;const h=(t,n,a)=>{if(t.addEventListener(n,a),u.push({event:n,handler:a,target:t}),s){const o=e.eventListenersMap.get(s)??[];o.push({element:t,event:n,handler:a}),e.eventListenersMap.set(s,o)}},g=(e,t)=>{if(e<0||e>=r.length)return;if(p=e,l.forEach((t,n)=>{t.setAttribute("aria-selected",n===e?"true":"false"),t.tabIndex=n===e?0:-1}),d.forEach((t,n)=>{t.hidden=n!==e}),!t||!n.syncKey)return;const a=de(r[e],e);((e,t)=>{if(e&&"undefined"!=typeof localStorage)try{localStorage.setItem(ce(e),t)}catch{return}})(n.syncKey,a),window.dispatchEvent(new CustomEvent(le,{detail:{label:a,syncKey:n.syncKey}}))};if(l.forEach((e,t)=>{h(e,"click",()=>g(t,!0)),h(e,"keydown",e=>{const n=e.key,a="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,o="Home"===n?0:"End"===n?r.length-1:0===a?-1:(t+a+r.length)%r.length;-1!==o&&(e.preventDefault(),g(o,!0),l[o]?.focus())})}),l.length>1&&n.syncKey){const t=e=>{const t=e.detail;if(!t||t.syncKey!==n.syncKey)return;const a=r.findIndex((e,n)=>de(e,n)===t.label);-1!==a&&a!==p&&g(a,!1)};if(window.addEventListener(le,t),u.push({event:le,handler:t,target:window}),s){const n=e.eventListenersMap.get(s)??[];n.push({element:window,event:le,handler:t}),e.eventListenersMap.set(s,n)}}const b=()=>{for(const{event:e,handler:t,target:n}of u)n.removeEventListener(e,t);m?.()};i&&g(a,!1);const f=t.querySelector(".clepit-output-code-copy-btn");if(!f)return b;h(f,"click",()=>{e.copyCodeToClipboard(r[p]?.code??n.code),e.animateCopyButton(f)});const y=o?c.getState().getInstance(o):null;return m=me(f,"Copy code","above",y?.config.classNames?.tooltips,y?.config.styles?.tooltips),b}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.code}static copyCodeToClipboard(e){navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy code to clipboard:",e)}):console.warn("Clipboard API not available in this context")}static animateCopyButton(e){const t=e.innerHTML;e.innerHTML='<svg class="clepit-check-icon" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="CheckIcon"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>',e.classList.remove("clepit-output-code-copy-btn--normal"),e.classList.add("clepit-output-code-copy-btn--animating"),setTimeout(()=>{e.innerHTML=t,e.classList.remove("clepit-output-code-copy-btn--animating"),e.classList.add("clepit-output-code-copy-btn--normal")},1e3)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("CodeOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},fe="inline-issue",ye='\n.clepit-issue {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 1px 8px 1px 6px;\n vertical-align: baseline;\n font-size: 0.92em;\n line-height: 1.5;\n color: inherit;\n text-decoration: none;\n white-space: nowrap;\n background: rgba(127, 127, 127, 0.1);\n border: 1px solid rgba(127, 127, 127, 0.25);\n border-radius: 999px;\n cursor: pointer;\n}\n.clepit-issue:hover {\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue__title {\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 28ch;\n}\n.clepit-issue__state {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 0 7px;\n font-size: 12px;\n line-height: 18px;\n border-radius: 999px;\n background: rgba(127, 127, 127, 0.16);\n}\n.clepit-issue__state::before {\n content: \'\';\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n}\n.clepit-issue__state[data-issue-category="todo"] {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue__state[data-issue-category="started"] {\n color: var(--clepit-primary, #5b5bff);\n background: var(--clepit-primary-bg, rgba(91, 91, 255, 0.16));\n}\n.clepit-issue__state[data-issue-category="done"] {\n color: var(--clepit-success, #15803d);\n background: var(--clepit-success-bg, rgba(21, 128, 61, 0.16));\n}\n.clepit-issue__state[data-issue-category="cancelled"] {\n color: var(--clepit-text-muted, #6b7280);\n text-decoration: line-through;\n}\n.clepit-issue__assignee {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.02em;\n color: #fff;\n background: var(--clepit-primary, #5b5bff);\n border-radius: 50%;\n}\n.clepit-issue__reason {\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue--reason {\n border-style: dashed;\n}\n[data-issue-chip-status="off"] .clepit-issue__state,\n[data-issue-chip-assignee="off"] .clepit-issue__assignee {\n display: none;\n}\n.clepit-issue-menu {\n position: absolute;\n z-index: 20;\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 180px;\n padding: 4px;\n font-size: 13px;\n background: var(--clepit-surface, #fff);\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n}\n.clepit-issue-menu a,\n.clepit-issue-menu button {\n display: block;\n width: 100%;\n padding: 6px 10px;\n font: inherit;\n color: inherit;\n text-align: left;\n text-decoration: none;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n.clepit-issue-menu a:hover,\n.clepit-issue-menu button:hover {\n background: rgba(127, 127, 127, 0.1);\n}\n.clepit-issue-menu__reason {\n padding: 6px 10px 2px;\n font-size: 12px;\n color: var(--clepit-text-muted, #6b7280);\n}\n.clepit-issue-card {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px;\n color: inherit;\n text-decoration: none;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n}\n.clepit-issue-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-issue-card__head {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.clepit-issue-card__key {\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n}\n.clepit-issue-card__title {\n font-weight: 600;\n}\n.clepit-issue-card__meta {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 12px;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__assignee {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n}\n.clepit-issue-card__reason {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 14px;\n align-items: center;\n font-size: 0.9em;\n opacity: 0.85;\n}\n.clepit-issue-card__action {\n padding: 0;\n font: inherit;\n color: inherit;\n text-decoration: underline;\n background: none;\n border: 0;\n cursor: pointer;\n}\n.clepit-issues {\n width: 100%;\n border-collapse: collapse;\n font-size: 0.95em;\n}\n.clepit-issues th,\n.clepit-issues td {\n padding: 6px 10px;\n text-align: left;\n border-bottom: 1px solid rgba(127, 127, 127, 0.25);\n}\n.clepit-issues th {\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n opacity: 0.7;\n}\n.clepit-issues a {\n color: inherit;\n font-weight: 600;\n text-decoration: none;\n}\n.clepit-issues a:hover {\n text-decoration: underline;\n}\n.clepit-issues__empty {\n opacity: 0.55;\n}\n',ve={categoryCancelled:"Cancelled",categoryDone:"Done",categoryStarted:"In progress",categoryTodo:"To do",columnAssignee:"Assignee",columnIssue:"Issue",columnStatus:"Status",columnTitle:"Title",connectAction:"Connect",connectTool:"Connect {tool} to see this issue",linkedIssuesEmpty:"No issues linked on this page yet",noAccess:"You do not have access to this issue in {tool}",openInTool:"Open in {tool}",providerUnreachable:"{tool} did not answer",showAsCard:"Show as card",unassigned:"Unassigned",updatedRelative:"updated {when}"},xe={asana:"Asana",github_issues:"GitHub",jira:"Jira",linear:"Linear"},ke={cancelled:"categoryCancelled",done:"categoryDone",started:"categoryStarted",todo:"categoryTodo"};function we(e,t,n={}){let a=e?.[t]??ve[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Ce=e=>xe[e]??e,Se="clepit-issue",Ae=["todo","started","done","cancelled"],Ee=["connect_tool","no_access","provider_unreachable"],Ne={connect_tool:"connectTool",no_access:"noAccess",provider_unreachable:"providerUnreachable"},Le=e=>e.trim().split(/\s+/).slice(0,2).map(e=>e.charAt(0).toUpperCase()).join(""),Be=(e,t)=>e.reason?we(t,Ne[e.reason],{tool:Ce(e.tool)}):null,$e=(e,t)=>e.stateName||we(t,ke[e.category]),Ie=(e,t,n="")=>({category:"todo",key:n,stateName:"",title:"",tool:t,updatedAt:"",url:e}),Te=class e{static build(t,n,a=T){const o=a.create("a");o.addClass(Se),t.reason&&o.addClass(`${Se}--reason`),o.setAttribute("href",t.url),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer"),o.setAttribute("contenteditable","false");for(const[s,l]of Object.entries(e.attributes(t)))o.setAttribute(s,l);const i=a.create("span");i.addClass(`${Se}__key`),i.setText(t.key||(t.title?"":Ce(t.tool))),!t.key&&t.title||o.append(i);const r=Be(t,n);if(r){const e=a.create("span");return e.addClass(`${Se}__reason`),e.setText(r),o.append(e),o}if(t.title){const e=a.create("span");e.addClass(`${Se}__title`),e.setText(t.title),o.append(e)}if(t.stateName||t.updatedAt){const e=a.create("span");e.addClass(`${Se}__state`),e.setAttribute("data-issue-category",t.category),e.setText($e(t,n)),o.append(e)}if(t.assigneeName){const e=a.create("span");e.addClass(`${Se}__assignee`),e.setAttribute("title",t.assigneeName),e.setText(Le(t.assigneeName)),o.append(e)}return o}static markup(t,n,a){return z(e.build(t,n,j(a)))}static create(t,n){return N.injectStyles(fe,ye),H(e.build(t,n))}static refresh(t,n,a){const o=e.create(n,a);for(const e of Array.from(t.attributes))e.name.startsWith("data-issue-")&&t.removeAttribute(e.name);for(const e of Array.from(o.attributes))t.setAttribute(e.name,e.value);t.replaceChildren(...Array.from(o.childNodes))}static read(e){const t=t=>e.getAttribute(`data-issue-${t}`)??"",n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:Ae.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Ee.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||e.getAttribute("href")||""}}static collect(e){return Array.from(e.querySelectorAll(`a.${Se}`))}static refreshAll(t,n,a){for(const o of e.collect(t)){const t=o.getAttribute("data-issue-url")||o.getAttribute("href")||"",i=n[t];i&&e.refresh(o,{...i,url:t},a)}}static applyParts(e,t){e.setAttribute("data-issue-chip-status",!1===t?.status?"off":"on"),e.setAttribute("data-issue-chip-assignee",!1===t?.assignee?"off":"on")}static insertAtCaret(t,n){const a=window.getSelection();if(!a||0===a.rangeCount)return null;const o=a.getRangeAt(0);o.deleteContents();const i=e.create(t,n);o.insertNode(i);const r=document.createTextNode(" ");i.after(r);const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),a.removeAllRanges(),a.addRange(s),i}static attributes(e){const t={"data-issue-category":e.category,"data-issue-key":e.key,"data-issue-state":e.stateName,"data-issue-title":e.title,"data-issue-tool":e.tool,"data-issue-updated":e.updatedAt,"data-issue-url":e.url};return e.assigneeName&&(t["data-issue-assignee"]=e.assigneeName),e.assigneeAvatarUrl&&(t["data-issue-avatar"]=e.assigneeAvatarUrl),e.pull&&(t["data-issue-pull"]="true"),e.reason&&(t["data-issue-reason"]=e.reason),t}},Me=/<a\b[^>]*\bclepit-issue(?=["'\s])[^>]*>[\s\S]*?<\/a>/g,_e=(e,t)=>(new RegExp(`\\b${t}="([^"]*)"`).exec(e)?.[1]??"").replace(/"/g,'"').replace(/&/g,"&"),De=e=>{const t=t=>_e(e,`data-issue-${t}`),n=t("category"),a=t("reason");return{assigneeAvatarUrl:t("avatar")||void 0,assigneeName:t("assignee")||void 0,category:Ae.includes(n)?n:"todo",key:t("key"),pull:"true"===t("pull")||void 0,reason:Ee.includes(a)?a:void 0,stateName:t("state"),title:t("title"),tool:t("tool"),updatedAt:t("updated"),url:t("url")||_e(e,"href")}},qe=e=>Array.from(e.matchAll(Me),e=>De(e[0])),je=(e,t,n,a,o)=>t||n?e.replace(Me,e=>{const i=De(e),r={...t?.[i.url]?{...t[i.url],url:i.url}:i};return!1===n?.status&&(r.stateName="",r.updatedAt=""),!1===n?.assignee&&(r.assigneeName=void 0),Te.markup(r,a,o)}):e,ze=class e{static render(t,n){return N.injectStyles(fe,ye),H(e.draw(t,T,n,!0))}static draw(t,n,a,o){const i=Be(t,a);if(i)return e.drawReason(t,i,n,a,o);const r=n.create("a");r.addClass("clepit-issue-card","clepit-output-embed"),r.setAttribute("data-testid","issue-card"),r.setAttribute("href",t.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__head"),t.key){const e=n.create("span");e.addClass("clepit-issue-card__key"),e.setText(t.key),s.append(e)}const l=n.create("span");l.addClass("clepit-issue-card__title"),l.setText(t.title||t.url),s.append(l);const c=n.create("span");c.addClass("clepit-issue__state"),c.setAttribute("data-issue-category",t.category),c.setText($e(t,a)),s.append(c),r.append(s);const d=n.create("span");d.addClass("clepit-issue-card__meta");const p=n.create("span");if(p.addClass("clepit-issue-card__assignee"),t.assigneeName){const e=n.create("span");e.addClass("clepit-issue__assignee"),e.setAttribute("title",t.assigneeName),e.setText(Le(t.assigneeName)),p.append(e),p.appendText(t.assigneeName)}else p.setText(we(a,"unassigned"));if(d.append(p),t.updatedAt){const e=n.create("span");e.addClass("clepit-issue-card__updated"),e.setText(we(a,"updatedRelative",{when:(u=t.updatedAt,u.length>=10?u.slice(0,10):u)})),d.append(e)}var u;return r.append(d),r}static drawReason(e,t,n,a,o){const i=n.create("div");i.addClass("clepit-issue-card","clepit-issue-card--reason","clepit-output-embed"),i.setAttribute("data-testid","issue-card");const r=n.create("a");r.addClass("clepit-issue-card__head"),r.setAttribute("href",e.url),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank");const s=n.create("span");if(s.addClass("clepit-issue-card__key"),s.setText(e.key||Ce(e.tool)),r.append(s),e.title){const t=n.create("span");t.addClass("clepit-issue-card__title"),t.setText(e.title),r.append(t)}i.append(r);const l=n.create("span");l.addClass("clepit-issue-card__reason"),l.setAttribute("data-testid","issue-reason");const c=n.create("span");if(c.setText(t),l.append(c),o&&"connect_tool"===e.reason){const t=n.create("button");t.addClass("clepit-issue-card__action"),t.setAttribute("type","button"),t.setAttribute("data-issue-action","connect"),t.setAttribute("data-issue-tool",e.tool),t.setAttribute("data-testid","issue-reason-action-connect"),t.setText(we(a,"connectAction")),l.append(t)}return i.append(l),i}},He="allow-scripts allow-same-origin allow-presentation allow-forms",Oe={connectGoogle:"Connect your Google account to show this file",connectGoogleAction:"Connect",noAccess:"You do not have access to this file in Google Drive",offerShowLive:"{tool} · Show live",providerUnreachable:"{tool} did not answer, so the content is not shown",switchedOff:"Live view for {tool} is switched off for this workspace",truncated:"truncated",tryAgain:"Try again",viewOnGithub:"View on GitHub"},Pe={figma:"Figma",githubGist:"GitHub",googleDrive:"Google Drive",loom:"Loom",miro:"Miro"};function Re(e,t,n={}){let a=e?.[t]??Oe[t];for(const[o,i]of Object.entries(n))a=a.replace(`{${o}}`,i);return a}var Fe=new Set(Object.keys(W)),Ue={"c#":"csharp","c++":"cpp","html+erb":"html","objective-c":"objectivec",shell:"bash"};function Ve(e){if(!e)return;const t=e.toLowerCase(),n=Ue[t];return n||(Fe.has(t)?t:void 0)}var We={connect_google:"connectGoogle",no_access:"noAccess",provider_unreachable:"providerUnreachable",switched_off:"switchedOff"},Ke={connectGoogle:"connectGoogleAction",retry:"tryAgain"};function Ge(e,t){const n=Pe[t.provider]??"The tool";if(t.switchedOff)return{reason:"switched_off",tool:n};switch(e.reason){case"connect_google":return{action:"connectGoogle",reason:"connect_google",tool:n};case"no_access":return{reason:"no_access",tool:n};case"provider_unreachable":return{action:"retry",reason:"provider_unreachable",tool:n};case"switched_off":return{reason:"switched_off",tool:n};default:return null}}var Je=(e,t)=>"card"===e.display||!0===t.switchedOff||void 0!==e.reason,Xe=class e{static render(t,n,a,o){if(N.injectStyles("embed-output",$),!e.validate(t))return V();if(t.issue)return ze.render({...t.issue,...n?.issues?.[t.url],url:t.url},n?.issueLabels);const i=k(t.url,{disabledProviders:n?.disabledEmbedProviders,mapsEmbedKey:n?.mapsEmbedKey});if("invalid"===i.provider)return V();if(!Je(t,i)){if(i.gist)return e.gistFrame(i.gist,a,o);if(i.embedUrl)return e.frame(i.embedUrl,i.aspect,a,o)}const r=e.card(t,i.url,a,o),s=Ge(t,i);if(!s)return r;const l=N.createStyledElement("div","clepit-embed-card--with-reason clepit-output-embed",{classNames:o?.wrapper,styles:a?.wrapper});r.classList.remove("clepit-output-embed"),l.appendChild(r);const c=document.createElement("span");c.className="clepit-embed-card__reason",c.setAttribute("data-testid","embed-reason");const d=document.createElement("span");if(d.textContent=Re(n?.embedLabels,We[s.reason],{tool:s.tool}),c.appendChild(d),s.action){const e=document.createElement("button");e.type="button",e.className="clepit-embed-card__action",e.setAttribute("data-embed-action",s.action),e.setAttribute("data-testid",`embed-reason-action-${s.action}`),e.textContent=Re(n?.embedLabels,Ke[s.action]),c.appendChild(e)}return l.appendChild(c),l}static draw(t,n=T,a){if(!e.validate(t))return null;if(t.issue)return ze.draw({...t.issue,...a?.issues?.[t.url],url:t.url},n,a?.issueLabels,!1);const o=k(t.url,{disabledProviders:a?.disabledEmbedProviders,mapsEmbedKey:a?.mapsEmbedKey});if("invalid"===o.provider)return null;if(!Je(t,o)){if(o.gist&&t.gist&&t.gist.files.length>0)return e.drawGist(t,n,a);if(o.embedUrl)return e.drawFrame(o.embedUrl,o.aspect,n)}const i=Ge(t,o);if(!i)return e.drawCard(t,o.url,n,!0);const r=n.create("div");r.addClass("clepit-embed-card--with-reason","clepit-output-embed"),r.append(e.drawCard(t,o.url,n,!1));const s=n.create("span");s.addClass("clepit-embed-card__reason"),s.setAttribute("data-testid","embed-reason");const l=n.create("span");return l.setText(Re(a?.embedLabels,We[i.reason],{tool:i.tool})),s.append(l),r.append(s),r}static drawGist(e,t,n){const a=e.gist,o=t.create("div");o.addClass("clepit-embed-gist","clepit-output-embed");for(const i of a.files){const e=t.create("div");e.addClass("clepit-embed-gist__file");const r=t.create("b");if(r.setText(i.name),e.append(r),i.truncated){const a=t.create("span");a.setText(Re(n?.embedLabels,"truncated")),e.append(a)}const s=t.create("a");s.setAttribute("href",a.htmlUrl),s.setAttribute("rel","noopener noreferrer nofollow"),s.setAttribute("target","_blank"),s.setText(Re(n?.embedLabels,"viewOnGithub")),e.append(s),o.append(e);const l=be.draw({code:i.content,language:Ve(i.language),showCopy:!1},t,n);l&&o.append(l)}return o}static drawFrame(e,t,n){const a=n.create("div");a.addClass("clepit-embed","clepit-output-embed");const o=n.create("iframe");return o.addClass("clepit-embed__frame"),o.setAttribute("src",e),o.setAttribute("sandbox",He),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.setAttribute("allowfullscreen","true"),o.setAttribute("style",`aspect-ratio: ${t??16/9};`),a.append(o),a}static drawCard(e,t,n,a){const o=n.create("a");o.addClass("clepit-embed-card"),a&&o.addClass("clepit-output-embed"),o.setAttribute("href",t),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank");const i=n.create("span"),r=n.create("span");if(r.addClass("clepit-embed-card__title"),r.setText(e.title||t),i.append(r),e.description){const t=n.create("span");t.addClass("clepit-embed-card__description"),t.setText(e.description),i.append(t)}return o.append(i),o}static gistFrame(e,t,n){const a=N.createStyledElement("div","clepit-embed clepit-embed--gist-frame clepit-output-embed",{classNames:n?.wrapper,styles:t?.wrapper}),o=document.createElement("iframe");var i,r;return o.className="clepit-embed__frame",o.setAttribute("srcdoc",(i=e.owner,r=e.id,`<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>body{margin:0;padding:8px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.gist .gist-file{margin-bottom:0}</style></head><body><script src="https://gist.github.com/${encodeURIComponent(i)}/${encodeURIComponent(r)}.js"><\/script></body></html>`)),o.setAttribute("sandbox","allow-scripts allow-popups allow-popups-to-escape-sandbox"),o.setAttribute("referrerpolicy","no-referrer"),o.setAttribute("loading","lazy"),o.style.height="552px",a.appendChild(o),a}static frame(e,t,n,a){const o=N.createStyledElement("div","clepit-embed clepit-output-embed",{classNames:a?.wrapper,styles:n?.wrapper}),i=document.createElement("iframe");return i.className="clepit-embed__frame",i.src=e,i.setAttribute("sandbox",He),i.setAttribute("referrerpolicy","no-referrer"),i.setAttribute("loading","lazy"),i.setAttribute("allowfullscreen","true"),i.style.aspectRatio=String(t??16/9),o.appendChild(i),o}static card(e,t,n,a){const o=N.createStyledElement("a","clepit-embed-card clepit-output-embed",{classNames:a?.card,styles:n?.card});o.href=t,o.rel="noopener noreferrer nofollow",o.target="_blank";const i=document.createElement("span"),r=document.createElement("span");if(r.className="clepit-embed-card__title",r.textContent=e.title||t,i.appendChild(r),e.description){const t=document.createElement("span");t.className="clepit-embed-card__description",t.textContent=e.description,i.appendChild(t)}return o.appendChild(i),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url&&e.url.length>0}},Ze=/^[A-Z][A-Z0-9_]*-\d+$/,Ye=/^\d+$/,Qe=(e,t)=>e.endsWith(".atlassian.net")||t.some(t=>(e=>{try{return new URL(e).host.toLowerCase()}catch{return null}})(t)===e),et=(e,t,n)=>n?{key:t,site:n,tool:e}:{key:t,tool:e};function tt(e,t=[]){let n;try{n=new URL(e)}catch{return null}if("https:"!==n.protocol&&"http:"!==n.protocol)return null;const a=n.host.toLowerCase(),o=n.pathname.split("/").filter(Boolean);if("linear.app"===a){const[,e,t]=o;return"issue"===e&&t&&Ze.test(t)?et("linear",t):null}if("github.com"===a||"www.github.com"===a){const[e,t,n,a]=o;return e&&t&&("issues"===n||"pull"===n)&&a&&Ye.test(a)?et("github_issues",`${e}/${t}#${a}`):null}if("app.asana.com"===a){const[e,...t]=o;return"0"===e&&t.length>=2&&Ye.test(t[0])&&Ye.test(t[1])||("1"===e&&"project"===t[1]&&"task"===t[3]&&t[4]&&Ye.test(t[4])||"1"===e&&"task"===t[1]&&t[2]&&Ye.test(t[2]))?et("asana",""):null}if(Qe(a,t)){const e=`https://${a}`;if("browse"===o[0]&&o[1]&&Ze.test(o[1]))return et("jira",o[1],e);const t=n.searchParams.get("selectedIssue");return t&&Ze.test(t)?et("jira",t,e):null}return null}var nt=/* @__PURE__ */new WeakMap,at=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-output-embed")?e:e.querySelector(".clepit-output-embed");return(t?nt.get(t):void 0)??{url:""}}static render(t,n,a){N.injectStyles("embed-input",B);const o=n??{url:""},i=c.getState().getInstance(t)?.config,r=Xe.render(o,{disabledEmbedProviders:i?.disabledEmbedProviders,embedLabels:i?.embedLabels},a?.styles,a?.classNames);return r.classList.add("clepit-embed--input"),r.setAttribute("contenteditable","false"),nt.set(r,o),e.listenForActions(t,r),r}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static handleOperation(t,n,a){const o=n.getAttribute("data-id"),i=e.save(n);switch(t){case"embedShowLive":{const{display:e,...t}=i;return ss.updateBlockData(o,t,a)}case"embedShowCard":return ss.updateBlockData(o,{...i,display:"card"},a);case"embedShowLink":{const e=ss.getBlockIndex(a,o);if(-1===e)return;const t=document.createElement("a");return t.href=i.url,t.textContent=i.url,ss.replaceBlock(a,e,{data:{html:t.outerHTML},type:"paragraph"})}case"embedCopyLink":return void navigator.clipboard?.writeText(i.url);case"embedShowChip":{const e=ss.getBlockIndex(a,o);if(-1===e)return;const t=c.getState().getInstance(a)?.config,n=tt(i.url,t?.jiraSites),r=i.issue??Ie(i.url,n?.tool??"",n?.key??""),s=Te.create({...r,url:i.url},t?.issueLabels);return ss.replaceBlock(a,e,{data:{html:`${s.outerHTML} `},type:"paragraph"})}default:return}}static refreshIssue(t,n,a){const o=e.save(t);if(!o.issue)return;const i=t.querySelector(`.${N.classNames.block.content}`);if(!i)return;const r=c.getState().getInstance(n),s={classNames:r?.config.classNames?.blocks?.embed,styles:r?.config.styles?.blocks?.embed};i.replaceChildren(e.render(n,{...o,issue:{...a,url:o.url}},s))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}static listenForActions(t,n){const a=e=>{const a=e.target?.closest("[data-issue-action]");if(a)return e.preventDefault(),e.stopPropagation(),void c.getState().getInstance(t)?.config.onIssueAction?.("connect",a.getAttribute("data-issue-tool")??"");const o=e.target?.closest("[data-embed-action]");if(!o)return;e.preventDefault(),e.stopPropagation();const i=o.getAttribute("data-embed-action"),r=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");if(!r)return;const s=c.getState().getInstance(t)?.config;"retry"===i?C(t,r,s?.resolveLink):s?.onEmbedAction?.(i,r)};n.addEventListener("click",a),e.eventListenersMap[t]??=[],e.eventListenersMap[t].push({element:n,event:"click",handler:a})}};async function ot(e,t){const n=c.getState().getInstance(e)?.config;if(!n?.resolveIssues||0===t.length)return{};try{const e=await n.resolveIssues([...t]),a={};for(const n of t)e[n]&&(a[n]={...e[n],url:n});return a}catch{const e={};for(const a of t){const t=tt(a,n.jiraSites);e[a]={...Ie(a,t?.tool??"",t?.key??""),reason:"provider_unreachable"}}return e}}async function it(e,t,n,a,o,i){const r=c.getState().getInstance(e)?.config,s=Ie(o,i.tool,i.key);if(a&&"on"===r?.issueCards){const t={data:{issue:s,url:o},type:"embed"};ss.replaceBlock(e,n,t);const a=ss.getBlocks(e)[n]?.getAttribute("data-id");return void(a&&await async function(e,t,n){const a=(await ot(e,[n]))[n];if(!a)return;const o=ss.getBlock(t);if(!o)return;const i=at.save(o);ss.updateBlockData(t,{...i,issue:{...a,url:i.url}},e)}(e,a,o))}const l=Te.insertAtCaret(s,r?.issueLabels);if(!l)return;const d=l.closest('[contenteditable="true"]');d&&ss.saveBlockData(d),await async function(e,t,n){const a=(await ot(e,[n]))[n];if(!a||!t.isConnected)return;const o=c.getState().getInstance(e)?.config;Te.refresh(t,a,o?.issueLabels);const i=t.closest('[contenteditable="true"]');i&&ss.saveBlockData(i)}(e,l,o)}function rt(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".tiff",".ico"].some(e=>t.includes(e))||t.includes("data:image/")||t.includes("blob:")}function st(e){const t=e.toLowerCase();return[".mp4",".webm",".ogg",".mov",".avi",".mkv",".flv",".wmv",".m4v"].some(e=>t.includes(e))||t.includes("data:video/")||t.includes("blob:")}function lt(e){const t=e.toLowerCase();return t.includes("youtube.com")||t.includes("youtu.be")}function ct(e){return e.toLowerCase().includes("vimeo.com")}function dt(e){const t=e.trim();if(!function(e){try{return new URL(e),!0}catch{return!1}}(t))return{isImage:!1,isUrl:!1,isVideo:!1,isVimeo:!1,isYouTube:!1,url:t};const n=lt(t),a=ct(t);return{isImage:rt(t),isUrl:!0,isVideo:st(t)||n||a,isVimeo:a,isYouTube:n,url:t}}var pt=(e,t)=>void 0===e?.allowedBlockTools||e.allowedBlockTools.includes(t),ut=(e,t)=>{const n=dt(t);if(!n.isUrl)return null;if(n.isImage)return pt(e,"image")?{kind:"image",url:n.url}:null;if(n.isVideo)return pt(e,"video")?{isVimeo:n.isVimeo,isYouTube:n.isYouTube,kind:"video",url:n.url}:null;const a=(o=t,i=e?.jiraSites,tt(o,i));var o,i;if(a)return{issue:a,kind:"issue"};if(!pt(e,"embed"))return null;const r=function(e,t){const n=k(e,{disabledProviders:t});return"invalid"===n.provider||"link"===n.provider?null:n}(t,e?.disabledEmbedProviders);return r?{embed:r,kind:"embed"}:null};function mt(){if("undefined"==typeof navigator)return"unknown";const e=navigator.platform.toLowerCase(),t=navigator.userAgent.toLowerCase();return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":e.includes("linux")||t.includes("linux")?"linux":"unknown"}function ht(){return"mac"===mt()?"⌘":"Ctrl"}function gt(e){return"mac"===mt()?e.join(""):e.join(" + ")}var bt=e=>gt([ht(),e]),ft=e=>gt([ht(),{down:"↓",left:"←",right:"→",up:"↑"}[e]]),yt=()=>gt([ht(),"B"]),vt=()=>gt([ht(),"⌫"]),xt=()=>gt([ht(),"⌦"]),kt=()=>gt([ht(),"I"]),wt=()=>gt([ht(),"K"]),Ct=e=>gt([ht(),"⇧",e]),St=e=>gt([ht(),"⇧",{down:"↓",left:"←",right:"→",up:"↑"}[e]]),At=()=>gt([ht(),"U"]),Et=class e{static{this.label="bold"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h6a4 4 0 0 1 0 8H7z"/><path d="M7 12h7a4 4 0 0 1 0 8H7z"/></svg>'}static{this.shortcut=yt()}static apply(e){N.injectStyles("clepit-bold-styles","\n/* Bold inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const t=document.createElement("strong");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findBoldElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("strong");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findBoldElement(n)||t.cloneContents().querySelectorAll('b, strong, [style*="font-weight: bold"], [style*="font-weight:bold"]').length>0}static findBoldElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("B"===e.tagName||"STRONG"===e.tagName)return e;if("bold"===e.style.fontWeight||Number.parseInt(e.style.fontWeight)>=700)return e}return t.parentNode?e.findBoldElement(t.parentNode):null}},Nt=class e{static{this.label="inline code"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="7 8 3 12 7 16"/><polyline points="17 8 21 12 17 16"/></svg>'}static{this.shortcut=bt("`")}static apply(e,t,n){N.injectStyles("clepit-inline-code-styles","\n/* Inline code styling when <code> is within editable text */\n.clepit-paragraph code,\n.clepit-header code,\n.clepit-list-item code,\n.clepit-quote-text code,\n.clepit-quote-caption code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output inline code styling */\n.clepit-output-paragraph code,\n.clepit-output-header code,\n.clepit-output-list li code,\n.clepit-output-quote code,\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Toolbar button code styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n");const a=document.createElement("code");a.classList.add("clepit-inline-code"),t&&N.applyClassNames(a,t),n&&Object.entries(n).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);a.style.setProperty(n,String(t))}}),e.surroundContents(a),ss.updateStateFromRange(e)}static remove(t){const n=e.findCodeElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("code");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findCodeElement(n)||t.cloneContents().querySelectorAll('code, [style*="font-family: monospace"], [style*="font-family:monospace"]').length>0}static findCodeElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("CODE"===e.tagName)return e;const n=window.getComputedStyle(e);if(n.fontFamily.includes("monospace")||n.fontFamily.includes("Monaco")||n.fontFamily.includes("Menlo"))return e;if(e.style.fontFamily.includes("monospace")||e.style.fontFamily.includes("Monaco")||e.style.fontFamily.includes("Menlo"))return e}return t.parentNode?e.findCodeElement(t.parentNode):null}static updateExistingCodeElements(e,t){document.querySelectorAll("code").forEach(n=>{n instanceof HTMLElement&&(n.classList.contains("clepit-inline-code")||n.classList.add("clepit-inline-code"),e&&N.applyClassNames(n,e),t&&Object.entries(t).forEach(([e,t])=>{if(void 0!==t){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);n.style.setProperty(a,String(t))}}))})}},Lt=class e{static{this.label="italic"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 4h8"/><path d="M7 20h8"/><path d="M13 4L9 20"/></svg>'}static{this.shortcut=kt()}static apply(e){N.injectStyles("clepit-italic-styles","\n/* Italic inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n.clepit-menu-icon--italic {\n font-style: italic;\n}\n");const t=document.createElement("em");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findItalicElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("em, i");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findItalicElement(n)||t.cloneContents().querySelectorAll('i, em, [style*="font-style: italic"], [style*="font-style:italic"]').length>0}static findItalicElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("I"===e.tagName||"EM"===e.tagName)return e;if("italic"===window.getComputedStyle(e).fontStyle)return e;if("italic"===e.style.fontStyle)return e}return t.parentNode?e.findItalicElement(t.parentNode):null}},Bt="clepit-link-styles",$t=`\n/* Link styles - simple and clean */\n.${N.classNames.block.link} {\n color: var(--clepit-primary);\n cursor: pointer;\n}\n\n.${N.classNames.block.link}:hover {\n color: var(--clepit-primary-hover);\n}\n`,It="clepit-dialogs-styles",Tt="\n/* Dialog Overlay */\n/* A native <dialog>. showModal() puts it in the top layer and paints a real\n * ::backdrop, so the full-screen scrim, the z-index and the manual centring are\n * the browser's job now. The non-modal branch below keeps the old flex overlay\n * for a DOM without showModal, where the element is an ordinary block. */\n.clepit-dialog-overlay {\n border: none;\n padding: 0;\n background: transparent;\n max-width: none;\n max-height: none;\n}\n\n.clepit-dialog-overlay[open] {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.clepit-dialog-overlay::backdrop {\n background: rgba(0, 0, 0, 0.5);\n backdrop-filter: blur(2px);\n}\n\n/* Fallback: no showModal, so the element is not in the top layer and paints no\n * backdrop of its own. */\n.clepit-dialog-overlay:not([open]) {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n z-index: 10000;\n backdrop-filter: blur(2px);\n}\n\n/* Dialog Container */\n.clepit-dialog {\n background: var(--clepit-bg);\n border-radius: 8px;\n box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);\n padding: 24px;\n min-width: 400px;\n max-width: 500px;\n max-height: 80vh;\n overflow-y: auto;\n position: relative;\n transform: scale(0.95);\n opacity: 0;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-dialog--hidden {\n transform: scale(0.95);\n opacity: 0;\n}\n\n.clepit-dialog:not(.clepit-dialog--hidden) {\n transform: scale(1);\n opacity: 1;\n}\n\n/* Dialog Title */\n.clepit-dialog-title {\n margin: 0 0 20px 0;\n font-size: 18px;\n font-weight: 600;\n color: var(--clepit-text);\n text-align: center;\n}\n\n/* Dialog Group */\n.clepit-dialog-group {\n margin-bottom: 16px;\n}\n\n/* Dialog Label */\n.clepit-dialog-label {\n display: block;\n margin-bottom: 6px;\n font-size: 14px;\n font-weight: 500;\n color: var(--clepit-text);\n}\n\n/* Dialog Input */\n.clepit-dialog-input {\n width: 100%;\n padding: 10px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n font-size: 14px;\n color: var(--clepit-text);\n background: var(--clepit-bg);\n transition: border-color 0.2s ease, box-shadow 0.2s ease;\n box-sizing: border-box;\n}\n\n.clepit-dialog-input:focus {\n outline: none;\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);\n}\n\n.clepit-dialog-input::placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Dialog Buttons */\n.clepit-dialog-buttons {\n display: flex;\n gap: 12px;\n justify-content: flex-end;\n margin-top: 24px;\n}\n\n/* Dialog Button */\n.clepit-dialog-button {\n padding: 10px 20px;\n border: none;\n border-radius: 6px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.2s ease;\n min-width: 80px;\n}\n\n.clepit-dialog-button--cancel {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n}\n\n.clepit-dialog-button--cancel:hover {\n background: var(--clepit-border);\n border-color: var(--clepit-text-subtle);\n}\n\n.clepit-dialog-button--save {\n background: var(--clepit-primary);\n color: white;\n}\n\n.clepit-dialog-button--save:hover {\n background: var(--clepit-primary);\n}\n\n.clepit-dialog-button--save:disabled {\n background: var(--clepit-text-subtle);\n cursor: not-allowed;\n}\n\n/* Responsive */\n@media (max-width: 640px) {\n .clepit-dialog {\n min-width: 320px;\n max-width: 90vw;\n margin: 20px;\n }\n\n .clepit-dialog-buttons {\n flex-direction: column;\n }\n\n .clepit-dialog-button {\n width: 100%;\n }\n}\n",Mt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.textInput?.value.trim()||"",t=this.urlInput?.value.trim()||"";e&&t&&(this.options.onConfirm(e,t),this.hide())}},this.options=e}show(){this.overlay||e.isOpen||(N.injectStyles(It,Tt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,this.urlInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="link-dialog-title",e.textContent=this.word("insertLink","Insert Link"),this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup(this.word("textField","Text"),this.word("linkTextPlaceholder","Link text"),this.options.text,"text","link-dialog-text");this.textInput=t.querySelector("input");const n=this.createInputGroup(this.word("urlField","URL"),this.word("urlPlaceholder","https://example.com"),this.options.url,"url","link-dialog-url");this.urlInput=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none")}createInputGroup(e,t,n,a,o){const i=O("div","clepit-dialog-group");this.applyStyles(i,this.options.styles?.group),this.applyClassNames(i,this.options.classNames?.group);const r=O("label","clepit-dialog-label");r.dataset.testid=`${o}-label`,r.textContent=e,this.applyStyles(r,this.options.styles?.label),this.applyClassNames(r,this.options.classNames?.label);const s=O("input","clepit-dialog-input");return s.type="url"===a?"url":"text",s.value=n,s.dataset.testid=`${o}-input`,s.placeholder=t,this.applyStyles(s,this.options.styles?.input),this.applyClassNames(s,this.options.classNames?.input),i.appendChild(r),i.appendChild(s),i}createButtonGroup(){const e=O("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=O("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="link-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=O("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="link-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.textInput?.value.trim()||"",this.urlInput?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.textInput&&this.textInput.addEventListener("keydown",this.handleInputKeyDown),this.urlInput&&this.urlInput.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.urlInput&&(this.urlInput.focus(),this.urlInput.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{void 0!==n&&e.style.setProperty(t,String(n))})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){document.removeEventListener("keydown",this.handleKeyDown),this.hide(),e.isOpen=!1}},_t=class e{static{this.label="link"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l1.76-1.76a5 5 0 0 0-7.07-7.07L10 5"/><path d="M14 11a5 5 0 0 0-7.07 0L5.17 12.76a5 5 0 0 0 7.07 7.07L14 19"/></svg>'}static{this.shortcut=wt()}static apply(t,n,a,o){N.injectStyles(Bt,$t);const i=t.toString().trim(),r=e.findLinkElement(t.commonAncestorContainer);let s=i,l="";r&&(s=r.textContent||i,l=r.href||"");const c=t.cloneRange();new Mt({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(c))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(a){if(a.removeAllRanges(),a.addRange(c),!n.trim())return void e.remove(c);if(t!==i){c.deleteContents();const e=document.createTextNode(t);c.insertNode(e),c.selectNode(e)}const o=N.createStyledElement("a",N.classNames.block.link);o.href=n,o.target="_blank",o.rel="noopener noreferrer";try{c.surroundContents(o)}catch{const e=c.extractContents();o.appendChild(e),c.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');if(s){const e=new Event("input",{bubbles:!0});s.dispatchEvent(e)}}}catch(a){console.error("Failed to apply link:",a)}},styles:a,text:s||"Link text",url:l}).show(),ss.updateStateFromRange(t)}static remove(t){const n=e.findLinkElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("a");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static findLinkElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("A"===e.tagName)return e}return t.parentNode?e.findLinkElement(t.parentNode):null}static isActive(t){const n=t.commonAncestorContainer;return!!e.findLinkElement(n)||t.cloneContents().querySelectorAll("a").length>0}},Dt="clepit-marker-styles",qt="\n/* Marker brush effect */\n.clepit-paragraph mark,\n.clepit-header mark,\n.clepit-list-item mark,\n.clepit-quote-text mark,\n.clepit-quote-caption mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n.clepit-paragraph mark::before,\n.clepit-header mark::before,\n.clepit-list-item mark::before,\n.clepit-quote-text mark::before,\n.clepit-quote-caption mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n/* Output marker brush effect for <mark> */\n.clepit-output-paragraph mark,\n.clepit-output-header mark,\n.clepit-output-list li mark,\n.clepit-output-quote mark,\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n.clepit-output-paragraph mark::before,\n.clepit-output-header mark::before,\n.clepit-output-list li mark::before,\n.clepit-output-quote mark::before,\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n z-index: -1;\n}\n\n/* Marker wrapper styling */\n.clepit-marker-wrapper {\n position: relative;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n color: inherit;\n}\n\n/* Marker stroke styling */\n.clepit-marker-stroke {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n z-index: -1;\n pointer-events: none;\n -webkit-mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n mask-image: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z'/></svg>\");\n -webkit-mask-size: 100% 100%;\n mask-size: 100% 100%;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n background-color: var(--clepit-marker);\n}\n\n/* Toolbar button mark styling */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n",jt=class e{static{this.label="marker"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 21l6-2 9-9a2.828 2.828 0 0 0-4-4l-9 9-2 6z"/><path d="M14 7l3 3"/></svg>'}static{this.shortcut=Ct("M")}static apply(t,n,a){N.injectStyles(Dt,qt);const o=document.createElement("span");o.classList.add("clepit-marker-wrapper");const i=document.createElement("span");i.classList.add("clepit-marker-stroke");const r=t.extractContents();o.appendChild(document.createTextNode(" ")),o.appendChild(r),o.appendChild(document.createTextNode(" ")),o.insertBefore(i,o.firstChild),t.insertNode(o),t.selectNodeContents(o),e.applyUserStyles(o,i,n,a);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0})),ss.updateStateFromRange(t)}static remove(t){const n=e.findMarkerElement(t.commonAncestorContainer);if(n){const t=n.parentElement;if(t){const a=n.previousSibling,o=n.nextSibling,i=document.createDocumentFragment();Array.from(n.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),n.replaceWith(i),e.cleanupSpaces(t,a,o);const r=t.closest('[contenteditable="true"]');r&&r.dispatchEvent(new Event("input",{bubbles:!0}))}return}const a=t.cloneContents().querySelectorAll(".clepit-marker-wrapper");if(a.length>0){a.forEach(t=>{const n=t.parentElement;if(n){const a=t.previousSibling,o=t.nextSibling,i=document.createDocumentFragment();Array.from(t.childNodes).forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&e.classList?.contains("clepit-marker-stroke")||i.appendChild(e.cloneNode(!0))}),t.replaceWith(i),e.cleanupSpaces(n,a,o)}});const n=t.commonAncestorContainer.closest('[contenteditable="true"]');return void(n&&n.dispatchEvent(new Event("input",{bubbles:!0})))}const o=e.findLegacyMarkElement(t.commonAncestorContainer);if(o){const e=o.parentElement;if(e){const t=o.textContent||"",n=document.createTextNode(t);e.insertBefore(n,o),e.removeChild(o);const a=e.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}ss.updateStateFromRange(t)}static cleanupSpaces(e,t,n){const a=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE);a.forEach((e,o)=>{let i=e.textContent||"";if(0===o&&t?.nodeType===Node.TEXT_NODE&&(t.textContent||"").endsWith(" ")&&i.startsWith(" ")&&(i=i.substring(1)),o===a.length-1&&n?.nodeType===Node.TEXT_NODE){const e=n.textContent||"";i.endsWith(" ")&&e.startsWith(" ")&&(i=i.substring(0,i.length-1))}e.textContent=i})}static isActive(t){if(t.collapsed)return!1;if(t.cloneContents().querySelectorAll(".clepit-marker-wrapper").length>0)return!0;if(e.findMarkerElement(t.commonAncestorContainer))return!0;const n=t.startContainer,a=t.endContainer;return!(n===t.commonAncestorContainer||!e.findMarkerElement(n))||(!(a===t.commonAncestorContainer||a===n||!e.findMarkerElement(a))||null!==e.findLegacyMarkElement(t.commonAncestorContainer))}static findMarkerElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains("clepit-marker-wrapper"))return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(N.classNames.editor.container))break}t=t.parentNode,n++}return null}static findLegacyMarkElement(e){let t=e,n=0;for(;t&&n<10;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("MARK"===e.tagName)return e;if(e.classList?.contains("clepit-block")||e.classList?.contains(N.classNames.editor.container))break;if(0===n){const t=window.getComputedStyle(e);if("yellow"===t.backgroundColor||"rgb(255, 255, 0)"===t.backgroundColor)return e;if("yellow"===e.style.backgroundColor||"rgb(255, 255, 0)"===e.style.backgroundColor)return e}}t=t.parentNode,n++}return null}static applyUserStyles(t,n,a,o){a&&N.applyClassNames(t,a),o&&Object.entries(o).forEach(([e,n])=>{if(void 0!==n&&"background"!==e){const a=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);t.style.setProperty(a,String(n))}});const i=t.style.getPropertyValue("--marker-background")||t.getAttribute("data-marker-background");if(i){const t=e.createStrokeSVG(i);return void(n.style.background=t)}if(o?.background){const t=o.background;if(t){const a=e.createStrokeSVG(String(t));return void(n.style.background=a)}}const r=t.closest(`.${N.classNames.editor.content}, .${N.classNames.renderer.content}`);if(r){const t=window.getComputedStyle(r).getPropertyValue("--clepit-marker-background");if(t&&"initial"!==t&&"inherit"!==t){const a=e.createStrokeSVG(t.trim());return void(n.style.background=a)}}const s=t.closest(`.${N.classNames.block.content}`);if(!s)return;const l=s.style.background||s.style.backgroundColor||s.style.getPropertyValue("background-color");if(l&&"initial"!==l&&"inherit"!==l){const t=e.createStrokeSVG(l);return void(n.style.background=t)}const c=window.getComputedStyle(s).backgroundColor;if(c&&"rgba(0, 0, 0, 0)"!==c&&"transparent"!==c){const t=e.createStrokeSVG(c);n.style.background=t}}static createStrokeSVG(t){const n=e.colorToHex(t);return`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='${encodeURIComponent(n)}'/></svg>") no-repeat center / 100% 100%`}static colorToHex(e){if(e.startsWith("#"))return e;if(e.startsWith("rgb")){const t=e.match(/\d+/g);if(t&&t.length>=3)return`#${parseInt(t[0]).toString(16).padStart(2,"0")}${parseInt(t[1]).toString(16).padStart(2,"0")}${parseInt(t[2]).toString(16).padStart(2,"0")}`}return{blue:"#3742FA",cyan:"#7FDBDA",green:"#2ED573",lime:"#32FF7E",orange:"#FFA502",pink:"#FF6B9D",purple:"#A55EEA",red:"#FF4757",teal:"#006266",yellow:"#FFE047"}[e.toLowerCase()]||"#FFE047"}},zt="clepit-inline-status-styles",Ht='\n/* Inline status — same visual language as the Alert block but inline. */\n.clepit-status {\n display: inline;\n padding: 2px 8px;\n border-radius: 4px;\n font-size: 0.9em;\n line-height: 1.5;\n vertical-align: baseline;\n}\n\n.clepit-status[data-status-variant="info"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-status[data-status-variant="success"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-status[data-status-variant="warning"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-status[data-status-variant="error"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-status[data-status-variant="plain"] {\n background: transparent;\n color: inherit;\n}\n\n/* Dialog variant picker — mirrors inline chip styling at rest, highlight on hover/selected. */\n.clepit-status-dialog-variants {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-top: 4px;\n}\n\n.clepit-status-dialog-variant {\n appearance: none;\n -webkit-appearance: none;\n background: transparent;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 6px 12px;\n cursor: pointer;\n font-family: inherit;\n font-size: 13px;\n color: var(--clepit-text);\n transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n}\n\n.clepit-status-dialog-variant:hover {\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--info:hover,\n.clepit-status-dialog-variant--info[data-selected="true"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--success:hover,\n.clepit-status-dialog-variant--success[data-selected="true"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--warning:hover,\n.clepit-status-dialog-variant--warning[data-selected="true"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--error:hover,\n.clepit-status-dialog-variant--error[data-selected="true"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n border-color: transparent;\n}\n\n.clepit-status-dialog-variant--plain:hover,\n.clepit-status-dialog-variant--plain[data-selected="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text);\n border-color: transparent;\n}\n',Ot=["info","success","warning","error","plain"],Pt={error:"statusError",info:"statusInfo",plain:"statusPlain",success:"statusSuccess",warning:"statusWarning"},Rt=class e{static{this.isOpen=!1}constructor(e){this.overlay=null,this.dialog=null,this.textInput=null,this.options=e,this.variant=e.variant}show(){this.overlay||e.isOpen||(N.injectStyles(It,Tt),e.isOpen=!0,this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const t=this.overlay;"function"==typeof t.close&&t.open&&t.close(),t.remove(),this.overlay=null,this.dialog=null,this.textInput=null,e.isOpen=!1;const n=document.querySelector(".clepit-toolbar");n&&(n.style.display="flex")}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="status-dialog-title",e.textContent=this.word("inlineStatus","Inline status"),this.applyStyles(e,this.options.styles?.title),this.dialog.appendChild(e);const t=O("label","clepit-dialog-label");t.dataset.testid="status-dialog-text-label",t.textContent=this.word("statusLabelField","Label"),this.applyStyles(t,this.options.styles?.label),this.dialog.appendChild(t),this.textInput=O("input","clepit-dialog-input"),this.textInput.type="text",this.textInput.value=this.options.text,this.textInput.dataset.testid="status-dialog-text-input",this.textInput.placeholder=this.word("statusLabelPlaceholder","Status label"),this.applyStyles(this.textInput,this.options.styles?.input),this.dialog.appendChild(this.textInput);const n=O("label","clepit-dialog-label");n.dataset.testid="status-dialog-variant-label",n.textContent=this.word("statusVariantField","Variant"),this.applyStyles(n,this.options.styles?.label),this.dialog.appendChild(n);const a=O("div","clepit-status-dialog-variants");for(const c of Ot){const e=O("button",`clepit-status-dialog-variant clepit-status-dialog-variant--${c}`);e.type="button",e.dataset.variant=c,e.dataset.testid=`status-dialog-variant-${c}`,e.textContent=this.word(Pt[c],c),e.dataset.selected=String(c===this.variant),e.addEventListener("click",()=>{this.variant=c;for(const e of Array.from(a.children))e.dataset.selected=String(e.dataset.variant===c)}),a.appendChild(e)}this.dialog.appendChild(a);const o=O("div","clepit-dialog-buttons");this.applyStyles(o,this.options.styles?.buttons);const i=O("button","clepit-dialog-button clepit-dialog-button--cancel");i.type="button",i.dataset.testid="status-dialog-cancel",i.textContent=this.word("cancel","Cancel"),i.addEventListener("click",()=>this.handleCancel()),this.applyStyles(i,this.options.styles?.cancelButton),o.appendChild(i);const r=O("button","clepit-dialog-button clepit-dialog-button--save");r.type="button",r.dataset.testid="status-dialog-apply",r.textContent=this.word("apply","Apply"),r.addEventListener("click",()=>this.handleConfirm()),this.applyStyles(r,this.options.styles?.saveButton),o.appendChild(r),this.dialog.appendChild(o),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const s=this.overlay;"function"==typeof s.showModal?s.showModal():s.style.display="flex";const l=document.querySelector(".clepit-toolbar");l&&(l.style.display="none")}bindEvents(){if(!this.overlay||!this.dialog||!this.textInput)return;this.overlay.addEventListener("click",e=>{e.target===this.overlay&&this.handleCancel()});const e=e=>{"Escape"===e.key&&this.handleCancel(),"Enter"===e.key&&e.target===this.textInput&&(e.preventDefault(),this.handleConfirm())};document.addEventListener("keydown",e),this.dialog.dataset.keyHandlerRegistered="true",this.dialog.__keyHandler=e}focusFirstInput(){setTimeout(()=>this.textInput?.focus(),50)}handleConfirm(){this.textInput&&(this.options.onConfirm(this.textInput.value.trim(),this.variant),this.cleanupKeyHandler(),this.hide())}handleCancel(){this.options.onCancel(),this.cleanupKeyHandler(),this.hide()}cleanupKeyHandler(){if(!this.dialog)return;const e=this.dialog.__keyHandler;e&&document.removeEventListener("keydown",e)}applyStyles(e,t){if(t)for(const[n,a]of Object.entries(t))void 0!==a&&e.style.setProperty(n,String(a))}},Ft="clepit-status",Ut=class e{static{this.label="status"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="8" width="18" height="8" rx="4"/><circle cx="8" cy="12" r="1.25"/><circle cx="16" cy="12" r="1.25"/></svg>'}static apply(t,n,a,o){N.injectStyles(zt,Ht);const i=t.toString().trim(),r=e.findStatusElement(t.commonAncestorContainer),s=r?r.textContent??i:i,l=r?e.readVariant(r):"info",c=t.cloneRange();new Rt({classNames:n,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(c))},onConfirm:(t,n)=>{try{const a=window.getSelection();if(!a)return;if(a.removeAllRanges(),a.addRange(c),!t.trim())return void e.remove(c);if(e.unwrap(c),t!==i){c.deleteContents();const e=document.createTextNode(t);c.insertNode(e),c.selectNode(e)}const o=document.createElement("span");o.className=(e=>`${Ft} ${Ft}--${e}`)(n),o.dataset.statusVariant=n;try{c.surroundContents(o)}catch{const e=c.extractContents();o.appendChild(e),c.insertNode(o)}const r=document.createRange();r.selectNodeContents(o),a.removeAllRanges(),a.addRange(r);const s=o.closest('[contenteditable="true"]');s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch(a){console.error("Failed to apply inline status:",a)}},styles:a,text:s||"status",variant:l}).show(),ss.updateStateFromRange(t)}static remove(t){e.unwrap(t),ss.updateStateFromRange(t)}static isActive(t){return!!e.findStatusElement(t.commonAncestorContainer)||t.cloneContents().querySelectorAll(`.${Ft}`).length>0}static unwrap(t){const n=e.findStatusElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}return}const a=t.commonAncestorContainer;if(a.nodeType!==Node.ELEMENT_NODE)return;const o=a.querySelectorAll(`.${Ft}`);for(const e of Array.from(o)){if(!t.intersectsNode(e))continue;const n=e.parentElement;n&&(n.insertBefore(document.createTextNode(e.textContent||""),e),n.removeChild(e))}}static findStatusElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList?.contains(Ft))return e}return t.parentNode?e.findStatusElement(t.parentNode):null}static readVariant(e){const t=e.dataset.statusVariant;if(t&&["info","success","warning","error"].includes(t))return t;for(const n of["info","success","warning","error"])if(e.classList.contains(`${Ft}--${n}`))return n;return"info"}},Vt=class e{static{this.label="strikethrough"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/></svg>'}static{this.shortcut=Ct("X")}static apply(e){N.injectStyles("clepit-strikethrough-styles",'\n/* Strikethrough inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button s,\n.clepit-toolbar-button del,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep strikethrough visual hint without changing size */\n.clepit-toolbar-button[data-tool="strikethrough"] {\n text-decoration: line-through;\n}\n');const t=document.createElement("s");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findStrikethroughElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]');for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findStrikethroughElement(n)||t.cloneContents().querySelectorAll('s, del, [style*="text-decoration: line-through"], [style*="text-decoration:line-through"]').length>0}static findStrikethroughElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("S"===e.tagName||"DEL"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("line-through"))return e;if(e.style.textDecoration.includes("line-through"))return e}return t.parentNode?e.findStrikethroughElement(t.parentNode):null}},Wt="clepit-tooltip-styles",Kt=`\n/* Tooltip styles - border bottom instead of text-decoration to avoid underline tool conflict */\n.${N.classNames.block.tooltip} {\n border-bottom: 1px dotted var(--clepit-text-subtle);\n cursor: help;\n}\n\n.${N.classNames.block.tooltip}:hover {\n border-bottom: 1px dotted var(--clepit-text-muted);\n}\n`,Gt=class{constructor(e){this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null,this.handleKeyDown=e=>{"Escape"===e.key&&(this.options.onCancel(),this.hide())},this.handleInputKeyDown=e=>{if("Enter"===e.key){const e=this.inputText?.value.trim()||"",t=this.inputTooltip?.value.trim()||"";this.options.onConfirm(e,t),this.hide()}},this.options=e}show(){this.overlay||(N.injectStyles(It,Tt),document.querySelectorAll(".clepit-dialog-overlay").forEach(e=>{e!==this.overlay&&e.remove()}),this.createDialog(),this.bindEvents(),this.focusFirstInput())}hide(){if(!this.overlay)return;const e=this.overlay;"function"==typeof e.close&&e.open&&e.close(),this.destroy()}word(e,t){return this.options.labels?.[e]||t}createDialog(){this.overlay=O("dialog","clepit-dialog-overlay"),this.applyStyles(this.overlay,this.options.styles?.overlay),this.applyClassNames(this.overlay,this.options.classNames?.overlay),this.dialog=O("div","clepit-dialog"),this.applyStyles(this.dialog,this.options.styles?.container),this.applyClassNames(this.dialog,this.options.classNames?.container);const e=O("h3","clepit-dialog-title");e.dataset.testid="tooltip-dialog-title",e.textContent=this.word("insertTooltip","Insert Tooltip"),this.applyStyles(e,this.options.styles?.title),this.applyClassNames(e,this.options.classNames?.title);const t=this.createInputGroup(this.word("textField","Text"),this.word("textPlaceholder","Text"),this.options.text,"text","tooltip-dialog-text");this.inputText=t.querySelector("input");const n=this.createInputGroup(this.word("tooltipField","Tooltip"),this.word("tooltipPlaceholder","Tooltip text"),this.options.tooltip,"text","tooltip-dialog-tooltip");this.inputTooltip=n.querySelector("input");const a=this.createButtonGroup();this.dialog.appendChild(e),this.dialog.appendChild(t),this.dialog.appendChild(n),this.dialog.appendChild(a),this.overlay.appendChild(this.dialog),document.body.appendChild(this.overlay);const o=this.overlay;"function"==typeof o.showModal?o.showModal():o.style.display="flex",this.dialog?.classList.remove("clepit-dialog--hidden");const i=document.querySelector(".clepit-toolbar");i&&(i.style.display="none"),this.options.onShow?.()}createInputGroup(e,t,n,a,o){const i=O("div","clepit-dialog-group");this.applyStyles(i,this.options.styles?.group),this.applyClassNames(i,this.options.classNames?.group);const r=O("label","clepit-dialog-label");r.dataset.testid=`${o}-label`,r.textContent=e,this.applyStyles(r,this.options.styles?.label),this.applyClassNames(r,this.options.classNames?.label);const s=O("input","clepit-dialog-input");return s.type="url"===a?"url":"text",s.value=n,s.dataset.testid=`${o}-input`,s.placeholder=t,this.applyStyles(s,this.options.styles?.input),this.applyClassNames(s,this.options.classNames?.input),i.appendChild(r),i.appendChild(s),i}createButtonGroup(){const e=O("div","clepit-dialog-buttons");this.applyStyles(e,this.options.styles?.buttons),this.applyClassNames(e,this.options.classNames?.buttons);const t=O("button","clepit-dialog-button clepit-dialog-button--cancel");t.dataset.testid="tooltip-dialog-cancel",t.textContent=this.word("cancel","Cancel"),t.type="button",this.applyStyles(t,this.options.styles?.cancelButton),this.applyClassNames(t,this.options.classNames?.cancelButton);const n=O("button","clepit-dialog-button clepit-dialog-button--save");return n.dataset.testid="tooltip-dialog-apply",n.textContent=this.word("apply","Apply"),n.type="button",this.applyStyles(n,this.options.styles?.saveButton),this.applyClassNames(n,this.options.classNames?.saveButton),t.addEventListener("click",()=>{this.options.onCancel(),this.hide()}),n.addEventListener("click",()=>{this.options.onConfirm(this.inputText?.value.trim()||"",this.inputTooltip?.value.trim()||""),this.hide()}),e.appendChild(t),e.appendChild(n),e}bindEvents(){this.overlay&&(this.overlay.addEventListener("click",e=>{e.target===this.overlay&&(this.options.onCancel(),this.hide())}),document.addEventListener("keydown",this.handleKeyDown),this.inputText&&this.inputText.addEventListener("keydown",this.handleInputKeyDown),this.inputTooltip&&this.inputTooltip.addEventListener("keydown",this.handleInputKeyDown))}focusFirstInput(){setTimeout(()=>{this.inputTooltip&&(this.inputTooltip.focus(),this.inputTooltip.select())},100)}applyStyles(e,t){t&&Object.entries(t).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.style.setProperty(a,String(n))}})}applyClassNames(e,t){t&&e.classList.add(t)}destroy(){if(document.removeEventListener("keydown",this.handleKeyDown),this.overlay){this.overlay.remove(),this.overlay=null,this.dialog=null,this.inputText=null,this.inputTooltip=null;const e=document.querySelector(".clepit-toolbar");e&&(e.style.display="flex"),this.options.onHide&&this.options.onHide()}}},Jt=class e{static{this.label="tooltip"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 7l-2.5 3H5a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-4.5L12 7z"/><path d="M8 13h8"/><path d="M8 16h6"/></svg>'}static{this.shortcut=Ct("T")}static apply(t,n,a,o){N.injectStyles(Wt,Kt);const i=t.toString(),r=t.cloneRange();let s="",l=i;const c=e.findTooltipSpan(t.commonAncestorContainer);c&&(s=c.getAttribute("data-tooltip")||"",l=c.textContent||""),new Gt({classNames:n.classNames,labels:o,onCancel:()=>{const e=window.getSelection();e&&(e.removeAllRanges(),e.addRange(r))},onConfirm:(t,o)=>{const i=window.getSelection();if(!i)return;if(i.removeAllRanges(),i.addRange(r),!o.trim())return e.remove(r),void(t!==l&&(r.deleteContents(),r.insertNode(document.createTextNode(t))));if(c){const e=c.parentElement;if(e){const t=document.createTextNode(c.textContent||"");e.insertBefore(t,c),e.removeChild(c),r.selectNode(t)}}if(t!==l){r.deleteContents();const e=document.createTextNode(t);r.insertNode(e),r.selectNode(e)}const s=N.createStyledElement("span",N.classNames.block.tooltip);s.setAttribute("data-tooltip",o),a.classNames&&N.applyClassNames(s,a.classNames),a.styles&&Object.entries(a.styles).forEach(([e,t])=>{if(void 0!==t){const n=e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);s.style.setProperty(n,String(t))}});try{r.surroundContents(s)}catch{const e=r.extractContents();s.appendChild(e),r.insertNode(s)}t!==l&&s.textContent!==t&&(s.textContent=t),me(s,o,"above",n.classNames,n.styles);const d=s.closest('[contenteditable="true"]');d&&d.dispatchEvent(new Event("input",{bubbles:!0}))},styles:n.styles,text:l,tooltip:s}).show(),ss.updateStateFromRange(t)}static remove(t){const n=t.commonAncestorContainer,a=e.findTooltipSpan(n);if(a){const e=a.parentElement;if(!e)return;e.insertBefore(document.createTextNode(a.textContent||""),a),e.removeChild(a),t.selectNode(e)}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findTooltipSpan(n)||t.cloneContents().querySelectorAll(`span.${N.classNames.block.tooltip}`).length>0}static initializeElements(e,t){e.querySelectorAll(`span.${N.classNames.block.tooltip}`).forEach(e=>{if(e instanceof HTMLElement&&(t.classNames&&N.applyClassNames(e,t.classNames),t.styles&&Object.entries(t.styles).forEach(([t,n])=>{if(void 0!==n){const a=t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(a,String(n))}}),!e.hasAttribute("data-tooltip-initialized"))){const t=e.getAttribute("data-tooltip");t&&(me(e,t,"above"),e.setAttribute("data-tooltip-initialized","true"))}})}static findTooltipSpan(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(e.classList.contains(N.classNames.block.tooltip))return e}return t.parentNode?e.findTooltipSpan(t.parentNode):null}},Xt=class e{static{this.label="underline"}static{this.icon='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 4v7a6 6 0 0 0 12 0V4"/><path d="M4 20h16"/></svg>'}static{this.shortcut=At()}static apply(e){N.injectStyles("clepit-underline-styles",'\n/* Underline inline formatting styles */\n.clepit-toolbar-button strong,\n.clepit-toolbar-button em,\n.clepit-toolbar-button u,\n.clepit-toolbar-button code,\n.clepit-toolbar-button mark {\n font-size: inherit;\n font-weight: inherit;\n font-style: inherit;\n text-decoration: inherit;\n background: transparent;\n padding: 0;\n border-radius: 0;\n font-family: inherit;\n}\n\n/* Keep underline visual hint without changing size */\n.clepit-toolbar-button[data-tool="underline"] {\n text-decoration: underline;\n}\n');const t=document.createElement("u");e.surroundContents(t),ss.updateStateFromRange(e)}static remove(t){const n=e.findUnderlineElement(t.commonAncestorContainer);if(n){const e=n.parentElement;if(e){const a=document.createTextNode(n.textContent||"");e.insertBefore(a,n),e.removeChild(n),t.selectNode(a)}}else{const e=t.commonAncestorContainer;if(e.nodeType===Node.ELEMENT_NODE){const n=e.querySelectorAll("u");for(const e of n)if(t.intersectsNode(e)){const t=e.parentElement;t&&(t.insertBefore(document.createTextNode(e.textContent||""),e),t.removeChild(e))}}}ss.updateStateFromRange(t)}static isActive(t){const n=t.commonAncestorContainer;return!!e.findUnderlineElement(n)||t.cloneContents().querySelectorAll('u, [style*="text-decoration: underline"], [style*="text-decoration:underline"]').length>0}static findUnderlineElement(t){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("U"===e.tagName)return e;if(window.getComputedStyle(e).textDecoration.includes("underline"))return e;if(e.style.textDecoration.includes("underline"))return e}return t.parentNode?e.findUnderlineElement(t.parentNode):null}},Zt=["bold","inline-code","italic","link","marker","status","strikethrough","tooltip","underline"],Yt=["alert","audio","checklist","code","collapsible","collection","columns","date","delimiter","doc_card","embed","file","glance","header","image","issues","latex","list","mermaid","openapi","paragraph","quote","sketch","table","toc","updates","video"],Qt=["asana","github_issues","jira","linear"],en=["categoryCancelled","categoryDone","categoryStarted","categoryTodo","columnAssignee","columnIssue","columnStatus","columnTitle","connectAction","connectTool","linkedIssuesEmpty","noAccess","openInTool","providerUnreachable","showAsCard","unassigned","updatedRelative"],tn=["connectGoogle","connectGoogleAction","noAccess","providerUnreachable","tryAgain","switchedOff","offerShowLive","viewOnGithub","truncated"],nn=["editView","previewView","jsonView","copyJson","downloadJson","clearEditor"],an=["insertLink","insertTooltip","inlineStatus","textField","urlField","tooltipField","statusLabelField","statusVariantField","urlPlaceholder","linkTextPlaceholder","textPlaceholder","tooltipPlaceholder","statusLabelPlaceholder","cancel","apply","statusInfo","statusSuccess","statusWarning","statusError","statusPlain"],on=["improve","shorten","lengthen","simplify","fix_grammar"],rn=()=>[Et,Lt,Xt,Vt,Nt,jt,Ut,_t,Jt],sn="inline-toolbar",ln=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.hideTimeoutMap=/* @__PURE__ */new Map}static{this.tooltipAnchorSeq=0}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static create(t){const n=c.getState().getInstance(t);if(!n)return console.error("InlineToolbar::create: Instance not found for containerId:",t);const a=document.getElementById(t);if(!a)return console.error("InlineToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(a)||e.eventListenersMap.set(a,[]),N.injectStyles("clepit-inline-toolbar-styles","\n/* Inline Toolbar */\n.clepit-toolbar {\n position: absolute;\n z-index: 1002;\n background: var(--clepit-toolbar-bg, var(--clepit-bg));\n border: var(--clepit-toolbar-border, 1px solid var(--clepit-border));\n border-radius: 8px;\n padding: 8px;\n box-shadow: var(--clepit-toolbar-shadow, 0 2px 8px rgba(0, 0, 0, 0.1));\n backdrop-filter: blur(8px);\n display: none;\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n white-space: nowrap;\n will-change: transform;\n}\n\n.clepit-toolbar--layout {\n display: flex;\n flex-direction: row;\n gap: 0px;\n align-items: center;\n}\n\n.clepit-toolbar--hidden {\n display: none !important;\n}\n\n.clepit-toolbar--visible {\n display: flex !important;\n transform: translateY(0) scale(1) !important;\n}\n\n@keyframes toolbarFadeIn {\n from {\n opacity: 0;\n transform: translateY(-10px) scale(0.95);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n\n.clepit-toolbar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-toolbar-color, var(--clepit-text));\n font-size: 12px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;\n line-height: 1;\n /* Ensure all content inside buttons inherits the same font size and styling */\n text-rendering: optimizeLegibility;\n will-change: transform, background-color, color;\n}\n\n/* Normalize SVG icon sizing in toolbar buttons */\n.clepit-toolbar-button svg {\n width: 14px;\n height: 14px;\n display: block;\n stroke: currentColor;\n}\n\n.clepit-toolbar-button:hover {\n background: var(--clepit-toolbar-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-hover-color, var(--clepit-text));\n transform: scale(1.05);\n}\n\n.clepit-toolbar-button:active {\n transform: scale(0.95);\n transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar-button.active {\n background: var(--clepit-toolbar-active-bg, var(--clepit-primary-bg));\n color: var(--clepit-toolbar-active-color, var(--clepit-primary));\n font-weight: bold;\n}\n\n/* Ensure consistent base font size for character-based icons */\n.clepit-toolbar-button { font-size: 12px; }\n\n/* Tooltip styles */\n/* Anchored to its own button and shown by :hover / :focus-visible, so no\n * JavaScript measures or centres it. :focus-visible is not decoration: the old\n * mouseenter-only version was invisible to a keyboard user.\n *\n * Guarded by @supports — anchor positioning is Baseline 2026 at ~91%. Without\n * it the tooltip simply never shows, which is what it already did before this\n * change for anyone not using a mouse. */\n.clepit-toolbar-tooltip {\n position: absolute;\n display: none;\n z-index: 9999;\n pointer-events: none;\n}\n\n@supports (anchor-name: --a) {\n .clepit-toolbar-tooltip {\n position: fixed;\n position-area: top;\n margin-block-end: 8px;\n justify-self: anchor-center;\n opacity: 0;\n transform: translateY(8px);\n transition:\n opacity 0.15s ease-in-out,\n transform 0.15s ease-in-out,\n display 0.15s allow-discrete;\n }\n\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n display: block;\n opacity: 1;\n transform: translateY(0);\n }\n\n @starting-style {\n .clepit-toolbar-button:hover + .clepit-toolbar-tooltip,\n .clepit-toolbar-button:focus-visible + .clepit-toolbar-tooltip {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .clepit-toolbar-tooltip {\n transition-duration: 0s;\n }\n}\n\n.clepit-toolbar-tooltip-content {\n white-space: nowrap;\n font-size: 12px;\n font-weight: 500;\n color: var(--clepit-bg);\n background-color: var(--clepit-text);\n padding: 6px 10px;\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\n transition: transform 0.2s ease-in-out;\n}\n\n.clepit-toolbar-tooltip-arrow {\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -4px;\n width: 0;\n height: 0;\n border-left: 4px solid transparent;\n border-right: 4px solid transparent;\n border-top: 4px solid var(--clepit-text);\n}\n\n.clepit-toolbar-tooltip--hidden {\n display: none;\n transform: translateY(8px);\n}\n\n.clepit-toolbar-tooltip--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-toolbar-tooltip--fade-out {\n transform: translateY(5px);\n}\n\n/* Toolbar positioning and animation classes */\n.clepit-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-toolbar--measurement {\n display: flex;\n visibility: hidden;\n opacity: 0;\n position: absolute;\n left: -9999px;\n top: -9999px;\n}\n\n.clepit-toolbar--show-animation {\n display: flex;\n visibility: visible;\n transform: translateY(-10px) scale(0.95);\n transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--show-animation.clepit-toolbar--visible {\n transform: translateY(0) scale(1);\n}\n\n.clepit-toolbar--position-animation {\n transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), top 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n.clepit-toolbar--hide-animation {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n transform: translateY(-5px) scale(0.98);\n}\n\n/* Rewrite menu — the sparkle-wand's action list, anchored under the toolbar */\n.clepit-toolbar-rewrite-menu {\n position: absolute;\n top: 100%;\n right: 0;\n margin-top: 4px;\n flex-direction: column;\n min-width: 160px;\n padding: 4px;\n border-radius: var(--clepit-radius-sm, 6px);\n background: var(--clepit-surface, #fff);\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);\n z-index: 2;\n}\n\n.clepit-toolbar-rewrite-item {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--clepit-text-primary, inherit);\n font: inherit;\n text-align: start;\n padding: 6px 10px;\n border-radius: var(--clepit-radius-xs, 4px);\n cursor: pointer;\n}\n\n.clepit-toolbar-rewrite-item:hover,\n.clepit-toolbar-rewrite-item:focus-visible {\n background: var(--clepit-surface-hover, rgba(0, 0, 0, 0.06));\n}\n\n/* The wand stays put while a rewrite is in flight, so the toolbar does not\n reflow under the pointer mid-request. */\n.clepit-toolbar-button.busy {\n opacity: 0.5;\n pointer-events: none;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n .clepit-toolbar {\n flex-wrap: wrap;\n max-width: 200px;\n }\n}\n");const o=O("div","clepit-toolbar");o.id=`${t}-${sn}`,o.classList.add("clepit-toolbar--hidden","clepit-toolbar--layout"),N.applyStyling(o,{classNames:n.config.classNames?.inlineToolbar?.container,styles:n.config.styles?.inlineToolbar?.container}),a.appendChild(o)}static repaint(t,n){const a=c.getState().getInstance(t);if(!a)return console.error("InlineToolbar::repaint: Instance not found for containerId:",t);if(!e.getElementFromContainerId(t))return console.error("InlineToolbar::repaint: Toolbar not found for containerId:",t);e.clearButtons(t);const o=((n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement)?.closest(`.${N.classNames.block.container}`))?.getAttribute("data-tool"),i=e.getFilteredTools(o,a.config);i.forEach(a=>e.addButton(t,a,n)),a.config.onInlineRewrite&&e.addRewriteButton(t,n);const r=n.getBoundingClientRect(),s=document.getElementById(a.config.containerId)?.getBoundingClientRect();if(!s)return;const l=((e=!1,t=rn().length)=>({height:40,width:24*(t+(e?1:0))+16}))(Boolean(a.config.onInlineRewrite),i.length),d=r.left-s.left+r.width/2-l.width/2;let p=r.top-s.top-l.height-8;p<0&&(p=r.bottom-s.top+8),e.show(a.config.containerId,d,p)}static addRewriteButton(t,n){const a=c.getState().getInstance(t),o=a?.config.onInlineRewrite;if(!a||!o)return;const i=e.getElementFromContainerId(t),r=document.getElementById(t);if(!i||!r)return;const s=O("button","clepit-toolbar-button",{type:"button"});s.innerHTML='<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M12 2l1.6 4.4L18 8l-4.4 1.6L12 14l-1.6-4.4L6 8l4.4-1.6L12 2zm6 10l.9 2.5L21 15l-2.1.8L18 18l-.9-2.2L15 15l2.1-.5L18 12zM6 13l1.1 3L10 17l-2.9 1L6 21l-1.1-3L2 17l2.9-1L6 13z"/></svg>',s.setAttribute("data-tool","rewrite"),N.applyStyling(s,{classNames:a.config.classNames?.inlineToolbar?.button,styles:a.config.styles?.inlineToolbar?.button});const l=O("div","clepit-toolbar-rewrite-menu");l.style.display="none",l.setAttribute("data-rewrite-menu","true");for(const c of on){const t=O("button","clepit-toolbar-rewrite-item",{type:"button"});t.textContent=a.config.inlineRewriteLabels?.[c]??c,t.setAttribute("data-rewrite-action",c),e.addEventListener(r,t,"mousedown",e=>e.preventDefault()),e.addEventListener(r,t,"click",()=>{l.style.display="none";const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,a=t&&!t.collapsed?t:n,i=a.toString();i.trim()&&(s.classList.add("busy"),o(i,c).then(e=>{e&&(a.deleteContents(),a.insertNode(document.createTextNode(e)),r.dispatchEvent(new Event("input",{bubbles:!0})))}).catch(()=>{}).finally(()=>s.classList.remove("busy")))}),l.appendChild(t)}e.addEventListener(r,s,"mousedown",e=>e.preventDefault()),e.addEventListener(r,s,"click",()=>{l.style.display="none"===l.style.display?"flex":"none"}),i.appendChild(s),e.createTooltip(i,s,a.config.inlineRewriteTooltip??"rewrite"),i.appendChild(l)}static addButton(t,n,a){const o=c.getState().getInstance(t);if(!o)return console.error("InlineToolbar::addButton: Instance not found for containerId:",t);const i=e.getElementFromContainerId(t);if(!i)return console.error("InlineToolbar::addButton: Toolbar not found for containerId:",t);const r=O("button","clepit-toolbar-button",{type:"button"});r.innerHTML=n.icon,N.applyStyling(r,{classNames:o.config.classNames?.inlineToolbar?.button,styles:o.config.styles?.inlineToolbar?.button}),n.isActive(a)&&r.classList.add("active"),r.setAttribute("data-tool",n.label.toLowerCase());const s=document.getElementById(t);s&&(e.addEventListener(s,r,"mousedown",e=>e.preventDefault()),e.addEventListener(s,r,"click",()=>{try{const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0):null,i=t&&!t.collapsed?t:a;if(i&&n.isActive(i))n.remove(i),r.classList.remove("active");else if(i){switch(n.label){case"italic":Lt.apply(i);break;case"bold":Et.apply(i);break;case"underline":Xt.apply(i);break;case"strikethrough":Vt.apply(i);break;case"inlineCode":Nt.apply(i,o.config.classNames?.blocks?.["inline-code"],o.config.styles?.blocks?.["inline-code"]);break;case"marker":jt.apply(i,o.config.classNames?.blocks?.marker,o.config.styles?.blocks?.marker);break;case"status":Ut.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs,o.config.dialogLabels);break;case"link":_t.apply(i,o.config.classNames?.dialogs,o.config.styles?.dialogs,o.config.dialogLabels);break;case"tooltip":Jt.apply(i,{classNames:o.config.classNames?.tooltips,styles:o.config.styles?.tooltips},{classNames:o.config.classNames?.blocks?.tooltip,styles:o.config.styles?.blocks?.tooltip},o.config.dialogLabels)}r.classList.add("active")}}catch(e){console.warn("Error applying inline tool:",e)}})),i.appendChild(r),e.createTooltip(i,r,n.label)}static createTooltip(t,n,a){const o=O("div","clepit-toolbar-tooltip clepit-toolbar-tooltip--hidden"),i=O("div","clepit-toolbar-tooltip-content");i.textContent=a;const r=O("div","clepit-toolbar-tooltip-arrow");i.appendChild(r),o.appendChild(i),n.insertAdjacentElement("afterend",o);const s="--clepit-inline-tool-"+e.tooltipAnchorSeq++;n.style.setProperty("anchor-name",s),o.style.setProperty("position-anchor",s),o.classList.remove("clepit-toolbar-tooltip--hidden")}static clearButtons(t){const n=e.getElementFromContainerId(t);if(!n)return console.error("InlineToolbar::clearButtons: Toolbar not found for containerId:",t);n.querySelectorAll(".clepit-toolbar-button").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-tooltip").forEach(e=>e.remove()),n.querySelectorAll(".clepit-toolbar-rewrite-menu").forEach(e=>e.remove())}static show(t,n,a){const o=e.getElementFromContainerId(t);if(!o)return console.error("InlineToolbar::show: Toolbar not found for containerId:",t);if(e.cancelPendingHide(t),o.classList.remove("clepit-toolbar--hidden"),o.classList.add("clepit-toolbar--visible"),o.classList.contains("clepit-toolbar--visible")){const e=parseFloat(o.style.left)||0,t=parseFloat(o.style.top)||0;(Math.abs(e-n)>1||Math.abs(t-a)>1)&&o.classList.add("clepit-toolbar--position-animation")}else o.classList.add("clepit-toolbar--show-animation");o.style.left=`${n}px`,o.style.top=`${a}px`,requestAnimationFrame(()=>{o.classList.add("clepit-toolbar--visible")})}static hide(t){const n=e.getElementFromContainerId(t);if(n)if(e.cancelPendingHide(t),n.classList.contains("clepit-toolbar--visible")){n.classList.add("clepit-toolbar--hide-animation");const a=setTimeout(()=>{n.classList.remove("clepit-toolbar--visible","clepit-toolbar--hide-animation"),n.classList.add("clepit-toolbar--hidden"),e.hideTimeoutMap.delete(t)},200);e.hideTimeoutMap.set(t,a)}else n.classList.remove("clepit-toolbar--visible"),n.classList.add("clepit-toolbar--hidden")}static cancelPendingHide(t){const n=e.hideTimeoutMap.get(t);void 0!==n&&(clearTimeout(n),e.hideTimeoutMap.delete(t))}static getElementFromContainerId(e){const t=document.querySelector(`#${e}`);return t?t.querySelector(`#${t.id}-${sn}`):(console.error("InlineToolbar::getElementFromContainerId: Container not found for containerId:",e),null)}static getFilteredTools(e,t){const n=rn().filter(e=>((e,t)=>void 0===e?.allowedInlineTools||e.allowedInlineTools.includes(t))(t,e.label.replace(" ","-")));return"header"===e?n.filter(e=>"bold"!==e.label):n}static destroy(t){e.cancelPendingHide(t);const n=document.querySelector(`#${t}`);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n));const o=n.querySelector(`#${t}-${sn}`);if(!o)return console.warn("InlineToolbar::destroy: Toolbar not found for containerId:",t);o.remove()}},cn={},dn={dismiss(e){for(const{capture:t,element:n,event:a,handler:o}of cn[e]??[])n.removeEventListener(a,o,t);cn[e]=[],document.querySelector(`[data-embed-offer-for="${e}"]`)?.remove()},show(e,t,n,a){dn.dismiss(e);const o=window.getSelection(),i=o?.rangeCount?o.getRangeAt(0):null;if(!i)return;i.deleteContents();const r=document.createTextNode(n);i.insertNode(r),i.setStartAfter(r),i.collapse(!0),o?.removeAllRanges(),o?.addRange(i);const s=document.getElementById(e);if(!s)return;const l=c.getState().getInstance(e)?.config,d=Pe[a.provider]??a.provider,p=document.createElement("div");p.className="clepit-embed-offer",p.setAttribute("data-testid","embed-offer"),p.setAttribute("data-embed-offer-for",e);const u=document.createElement("span");u.textContent=Re(l?.embedLabels,"offerShowLive",{tool:d}).replace(" · Show live",""),p.appendChild(u);const m=document.createElement("button");m.type="button",m.setAttribute("data-testid","embed-offer-accept"),m.textContent=Re(l?.embedLabels,"offerShowLive",{tool:d}).split(" · ").pop()??"Show live",p.appendChild(m);const h=i.getBoundingClientRect(),g=s.getBoundingClientRect();p.style.left=`${Math.max(0,h.left-g.left)}px`,p.style.top=h.bottom-g.top+6+"px",s.appendChild(p);const b=()=>{const a=t.getAttribute("data-id"),o=ss.getBlockIndex(e,a);dn.dismiss(e),-1!==o&&w(e,o,!0,n)},f=t=>{const n=t.key;if("Enter"===n)return t.preventDefault(),t.stopPropagation(),void b();"Shift"!==n&&"Meta"!==n&&"Control"!==n&&"Alt"!==n&&dn.dismiss(e)},y=t=>{p.contains(t.target)||dn.dismiss(e)};m.addEventListener("click",b),document.addEventListener("keydown",f,!0),document.addEventListener("mousedown",y),cn[e]=[{element:m,event:"click",handler:b},{capture:!0,element:document,event:"keydown",handler:f},{element:document,event:"mousedown",handler:y}]}},pn={},un={dismiss(e){for(const{element:t,event:n,handler:a}of pn[e]??[])t.removeEventListener(n,a);pn[e]=[],document.querySelector(`[data-issue-menu-for="${e}"]`)?.remove()},show(e,t){un.dismiss(e),N.injectStyles(fe,ye);const n=document.getElementById(e);if(!n)return;const a=c.getState().getInstance(e)?.config,o=Te.read(t),i=Ce(o.tool),r=document.createElement("div");r.className="clepit-issue-menu",r.setAttribute("data-testid","issue-menu"),r.setAttribute("data-issue-menu-for",e);const s=Be(o,a?.issueLabels);if(s){const t=document.createElement("div");if(t.className="clepit-issue-menu__reason",t.setAttribute("data-testid","issue-reason"),t.textContent=s,r.appendChild(t),"connect_tool"===o.reason){const t=document.createElement("button");t.type="button",t.setAttribute("data-testid","issue-connect"),t.textContent=we(a?.issueLabels,"connectAction"),t.addEventListener("click",()=>{un.dismiss(e),a?.onIssueAction?.("connect",o.tool)}),r.appendChild(t)}}const l=document.createElement("a");l.href=o.url,l.target="_blank",l.rel="noopener noreferrer",l.setAttribute("data-testid","issue-open"),l.textContent=we(a?.issueLabels,"openInTool",{tool:i}),l.addEventListener("click",()=>un.dismiss(e)),r.appendChild(l);const d=document.createElement("button");d.type="button",d.setAttribute("data-testid","issue-show-card"),d.textContent=we(a?.issueLabels,"showAsCard"),d.addEventListener("click",()=>{un.dismiss(e),un.showAsCard(e,t)}),r.appendChild(d);const p=t.getBoundingClientRect(),u=n.getBoundingClientRect();r.style.left=`${Math.max(0,p.left-u.left)}px`,r.style.top=p.bottom-u.top+6+"px",n.appendChild(r);const m=t=>{"Escape"===t.key&&un.dismiss(e)},h=n=>{r.contains(n.target)||t.contains(n.target)||un.dismiss(e)};document.addEventListener("keydown",m),document.addEventListener("mousedown",h),pn[e]=[{element:document,event:"keydown",handler:m},{element:document,event:"mousedown",handler:h}]},showAsCard(e,t){const n=Te.read(t),a=t.closest(`.${N.classNames.block.container}`),o=a?.getAttribute("data-id");if(!a||!o)return;const i=ss.getBlockIndex(e,o);if(-1===i)return;const r=t.closest('[contenteditable="true"]');t.remove();const s={data:{issue:n,url:n.url},type:"embed"};ss.getTool(a.getAttribute("data-tool"))?.input.isEmpty(a)?ss.replaceBlock(e,i,s):(r&&ss.saveBlockData(r),ss.insertBlock(s,e,i+1))}},mn=class e{static addListeners(t){const n=document.getElementById(t);if(!n)return console.error("EventManager::addListeners: Container not found for containerId:",t);document.addEventListener("selectionchange",e.handleSelectionChange),document.addEventListener("paste",e.handlePaste),n.addEventListener("click",e.handleClick)}static removeListeners(t){const n=document.getElementById(t);n&&(document.removeEventListener("selectionchange",e.handleSelectionChange),document.removeEventListener("paste",e.handlePaste),n.removeEventListener("click",e.handleClick))}static getInstanceAndTargetFromRange(e){const t=e.commonAncestorContainer,n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n)return null;const a=n.closest(`.${N.classNames.editor.content}`);if(!a)return null;const o=a.getAttribute("data-container-id");if(!o)return null;const i=c.getState().getInstance(o);return i?{instance:i,target:n}:null}static handleClick(e){const t=e.currentTarget,n=e.target,a=n.closest(`a.${Se}`);if(a){if("edit"!==c.getState().getInstance(t.id)?.currentView)return;return e.preventDefault(),void un.show(t.id,a)}const o=n.closest(`.${N.classNames.block.link}`);if(o){const e=document.createRange();e.selectNodeContents(o);const n=c.getState().getInstance(t.id);return void(n&&_t.apply(e,n.config.classNames?.dialogs,n.config.styles?.dialogs,n.config.dialogLabels))}const i=n.closest(`.${N.classNames.block.tooltip}`);if(i){const e=document.createRange();e.selectNodeContents(i);const n=c.getState().getInstance(t.id);return void(n&&Jt.apply(e,{classNames:n.config.classNames?.tooltips,styles:n.config.styles?.tooltips},{classNames:n.config.classNames?.blocks?.tooltip,styles:n.config.styles?.blocks?.tooltip},n.config.dialogLabels))}}static handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const n=t.getRangeAt(0),a=e.getInstanceAndTargetFromRange(n);if(!a)return;if("edit"!==a.instance.currentView){try{ln.hide(a.instance.config.containerId)}catch{}return}if(null!==document.querySelector(".clepit-dialog-overlay"))return;const o=t?.toString().trim();if(o&&o.length>0||t&&t.rangeCount>0&&!t.getRangeAt(0).collapsed)try{ln.repaint(a.instance.config.containerId,n)}catch{}else try{ln.hide(a.instance.config.containerId)}catch{}}static handlePaste(e){const t=e.clipboardData?.getData("text/plain").trim()??"";if(!t)return;const n=document.activeElement;if(!n)return;const a=n.closest(`.${N.classNames.block.container}`);if(!a)return;const o=a.closest(`.${N.classNames.editor.container}`);if(!o)return;const i=c.getState().getInstance(o.id)?.config,r=ut(i,t);if(!r)return;const s=a.getAttribute("data-id"),l=ss.getBlockIndex(o.id,s);if(-1===l)return;const d=ss.getTool(a.getAttribute("data-tool"));if(!d)return;const p=d.input.isEmpty(a);if(e.preventDefault(),"issue"!==r.kind)if("embed"!==r.kind)if("image"===r.kind){const e={data:{alignment:"center",alt:"Image",caption:"",url:r.url},type:"image"};p?ss.replaceBlock(o.id,l,e):ss.insertBlock(e,o.id,l+1)}else{let e=r.url;r.isYouTube?e=function(e){const t=function(e){for(const t of[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\n?#]+)/,/youtube\.com\/embed\/([^&\n?#]+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://www.youtube.com/embed/${t}`:null}(r.url)||r.url:r.isVimeo&&(e=function(e){const t=function(e){for(const t of[/vimeo\.com\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/]){const n=e.match(t);if(n)return n[1]}return null}(e);return t?`https://player.vimeo.com/video/${t}`:null}(r.url)||r.url);const t={data:{alignment:"center",alt:"Video",caption:"",url:e},type:"video"};p?ss.replaceBlock(o.id,l,t):ss.insertBlock(t,o.id,l+1)}else"offer"===(i?.pasteEmbeds??"live")?dn.show(o.id,a,t,r.embed):w(o.id,l,p,t);else it(o.id,0,l,p,t,r.issue)}},hn="\n/* Output alert styles */\n.clepit-output-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 1rem 0;\n}\n\n.clepit-output-alert--info {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-output-alert--warning {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-output-alert--error {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-output-alert--success {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-output-alert--plain {\n background: transparent;\n color: inherit;\n}\n\n.clepit-output-alert-content {\n line-height: 1.5;\n}\n\n/* Output alert link styles */\n.clepit-output-alert a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-alert a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output alert inline code styling */\n.clepit-output-alert code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output alert marker brush effect */\n.clepit-output-alert mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-alert mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",gn=class e{static{this.placeholder="Alert message here..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.alert}`)||e,n=t.getAttribute("data-variant")||"info";return{html:F(t.innerHTML),variant:n}}static render(t,n,a){N.injectStyles("clepit-alert-input-styles","\n/* Alert block styles */\n.clepit-alert {\n padding: 12px 16px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n margin: 0 20px;\n}\n\n.clepit-alert[data-variant=\"info\"] {\n background: var(--clepit-primary-bg);\n color: var(--clepit-primary-hover);\n}\n\n.clepit-alert[data-variant=\"warning\"] {\n background: var(--clepit-warning-bg);\n color: var(--clepit-warning);\n}\n\n.clepit-alert[data-variant=\"error\"] {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n}\n\n.clepit-alert[data-variant=\"success\"] {\n background: var(--clepit-success-bg);\n color: var(--clepit-success);\n}\n\n.clepit-alert[data-variant=\"plain\"] {\n background: transparent;\n color: inherit;\n}\n\n.clepit-alert-text {\n outline: none;\n margin: 0;\n padding: 0;\n}\n\n.clepit-alert[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n pointer-events: none;\n}\n\n/* Alert link styles */\n.clepit-alert-text a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-alert-text a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Alert inline code styling */\n.clepit-alert-text code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Alert marker brush effect */\n.clepit-alert-text mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-alert-text mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={html:"",variant:"info"},i=n?{...o,...n}:o,r=N.createStyledElement("div","clepit-alert",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});return r.setAttribute("data-variant",i.variant),r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(t,"alertTextHint",e.placeholder)),i.html?r.innerHTML=i.html:r.innerHTML="",e.addEventListener(t,r,"keydown",ss.handleKeydown),e.addEventListener(t,r,"input",ss.handleInput),r}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i=t.innerHTML||"",r={html:i.trim()&&"<br>"!==i.trim()?i:"",variant:n},s={classNames:o.config.classNames?.blocks?.alert,margins:o.config.margins,styles:o.config.styles?.blocks?.alert},l=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),d=e.render(a,r,s);t.replaceWith(d),c.getState().updateBlockData(a,l,r)}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.alert}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},bn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-alert-output-styles",hn),!e.validate(t))return V();if(gn.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.variant,s=N.createStyledElement("div",`clepit-output-alert clepit-output-alert--${r}`,{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=T){if(!e.validate(t)||gn.isEmptyData(t))return null;const a=n.create("div");return a.addClass("clepit-output-alert",`clepit-output-alert--${t.variant}`),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"variant"in e&&"html"in e&&"string"==typeof e.html}},fn={icon:"!",get input(){return gn},label:"Alert",get output(){return bn},shortcut:Ct("A"),testId:"block-type-alert",type:"alert"},yn=`\n/* Audio block styles */\n.clepit-audio-container {\n margin: 0 16px;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 96%;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.audio.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-audio {\n width: 100%;\n}\n\n.align-left {\n justify-content: flex-start;\n}\n\n.align-center {\n justify-content: center;\n}\n\n.align-right {\n justify-content: flex-end;\n}\n\n.${N.classNames.block.audio.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-audio-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-audio-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-audio-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-audio-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Audio caption styling */\n.clepit-audio-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Audio caption placeholder styles */\n.clepit-audio-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Audio Drop Area */\n.clepit-audio-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-audio-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-audio-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-audio-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-audio-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-audio-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-audio-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Audio Loading State */\n.clepit-audio-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-audio-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-audio-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Audio Error State */\n.clepit-audio-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-audio-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-audio-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-audio-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-audio-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Audio delete button */\n.${N.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Audio drop area delete button */\n.clepit-audio-drop-area .${N.classNames.block.audioDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-audio-drop-area .${N.classNames.block.audioDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,vn="\n/* Output audio styles */\n.clepit-output-audio-container {\n width: 100%;\n margin: 1rem 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper {\n width: 100%;\n display: flex;\n}\n\n.clepit-output-audio {\n width: 100%;\n}\n\n\n.clepit-output-audio-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output audio alignment */\n.clepit-output-audio-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-audio-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-audio-wrapper--right {\n justify-content: flex-end;\n}\n",xn=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["audio/mp3","audio/wav","audio/ogg","audio/mpeg","audio/mp4","audio/webm"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("audio"),n=e.querySelector(`.${N.classNames.block.audio.captionEditable}`),a=e.querySelector(`.${N.classNames.block.audio.wrapper}`);let o="center";return a&&(o=a.classList.contains("align-left")?"left":a.classList.contains("align-right")?"right":"center"),{alignment:o,alt:t&&t.getAttribute("alt")||"",caption:F(n?.innerHTML),url:t&&t.getAttribute("src")||""}}static render(t,n,a,o){N.injectStyles("clepit-audio-input-styles",yn);const i=a||{alt:"",caption:"",url:""},r=N.createStyledElement("div",N.classNames.block.audio.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderAudio(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderAudio(t,n,a,o,i){if(!document.getElementById(o))return;t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.audio.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("align-left");break;case"center":r.classList.add("align-center");break;case"right":r.classList.add("align-right")}const s=N.createStyledElement("audio","clepit-audio",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.src=n.url,s.controls=!0,s.preload="metadata",n.alt&&s.setAttribute("alt",n.alt);const l=N.createStyledElement("div","clepit-audio-caption-container",{classNames:i?.classNames?.container,styles:i?.styles?.container});l.classList.add("clepit-audio-caption-container");const c=N.createStyledElement("div","clepit-audio-caption-editable",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n.caption||"",e.addEventListener(o,c,"keydown",ss.handleKeydown),e.addEventListener(o,c,"input",ss.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.audio.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-audio-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="♪";const s=N.createStyledElement("div","clepit-audio-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop an audio file here</strong><br>or <span class="clepit-audio-click-text">click to select</span>';const l=N.createStyledElement("div","clepit-audio-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});l.textContent="Supports MP3, WAV, OGG, and other audio formats";const d=N.createStyledElement("button",`${N.classNames.block.audioDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});d.type="button",d.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(l),i.appendChild(d);const p=a?c.getState().getInstance(a):null,u=p?.config.classNames?.tooltips,m=p?.config.styles?.tooltips;me(d,"Delete block","below",u,m),e.addEventListener(a,d,"click",e=>{e.preventDefault(),e.stopPropagation();const t=d.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-audio-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-audio-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="audio/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidAudioFile(i)?e.processAudioFile(i,t,n,a,o):e.showError(t,"Please select a valid audio file (MP3, WAV, OGG)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidAudioFile(t)?e.processAudioFile(t,n,a,o,i):e.showError(n,"Please select a valid audio file (MP3, WAV, OGG)")}}static isValidAudioFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("audio/")}static async processAudioFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderAudio(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showError(n,"Failed to upload audio. Please try again.")}catch(r){console.error("Audio upload error:",r),e.showError(n,"Failed to upload audio. Please try again.")}}static showLoading(e){e.innerHTML="";const t=N.createStyledElement("div","clepit-audio-loading",void 0);t.textContent="Uploading audio...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-audio-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-audio-wrapper");n&&(n.classList.remove("align-left","align-center","align-right"),n.classList.add(`align-${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.audio.wrapper} audio`),n=e.querySelector(`.${N.classNames.block.audio.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},kn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-audio-output-styles",vn),!e.validate(t))return V();if(xn.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=N.createStyledElement("div","clepit-output-audio-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-audio-wrapper");switch(s){case"left":c.classList.add("clepit-output-audio-wrapper--left");break;case"center":c.classList.add("clepit-output-audio-wrapper--center");break;case"right":c.classList.add("clepit-output-audio-wrapper--right")}const d=O("audio","clepit-output-audio");if(d.src=i,d.controls=!0,d.preload="metadata",t.alt&&d.setAttribute("alt",t.alt),c.appendChild(d),l.appendChild(c),r){const e=N.createStyledElement("figcaption","clepit-output-audio-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-audio-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=T){if(!e.validate(t)||xn.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-audio-container");const o=n.create("div");o.addClass("clepit-output-audio-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-audio-wrapper--${i}`);const r=n.create("audio");if(r.addClass("clepit-output-audio"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-audio-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},wn={icon:"♪",get input(){return xn},label:"Audio",get output(){return kn},shortcut:Ct("O"),testId:"block-type-audio",type:"audio"},Cn=`\n/* Checklist input block styles */\n.${N.classNames.block.checklist.container} {\n margin: 0;\n padding: 0 20px;\n}\n\n.${N.classNames.block.checklist.item} {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 4px 0;\n}\n\n.${N.classNames.block.checklist.text} {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n outline: none;\n min-height: 1.2em;\n line-height: 1.6;\n padding: 0;\n margin: 0;\n}\n\n.${N.classNames.block.checklist.text}::before,\n.${N.classNames.block.checklist.text}::after {\n content: "";\n position: absolute;\n}\n\n.${N.classNames.block.checklist.text}::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.${N.classNames.block.checklist.text}::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.${N.classNames.block.checklist.checkbox} {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n}\n\n.${N.classNames.block.checklist.checkbox}::before,\n.${N.classNames.block.checklist.checkbox}::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.${N.classNames.block.checklist.checkbox}::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.${N.classNames.block.checklist.checkbox}::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text} {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text}::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.${N.classNames.block.checklist.checkbox}:checked + .${N.classNames.block.checklist.text}::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n.${N.classNames.block.checklist.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Checklist input link styles */\n.${N.classNames.block.checklist.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.checklist.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n`,Sn='\n/* Checklist output block styles */\n.clepit-output-checklist {\n margin: 0 0 1rem 0;\n padding-left: 0;\n}\n\n.clepit-output-checklist-item {\n --text: var(--clepit-text);\n --check: var(--clepit-primary);\n --disabled: var(--clepit-text-muted);\n --border-radius: 10px;\n border-radius: var(--border-radius);\n position: relative;\n padding: 5px;\n display: grid;\n grid-template-columns: 30px auto;\n align-items: center;\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text {\n color: var(--text);\n position: relative;\n cursor: pointer;\n display: grid;\n align-items: center;\n width: -webkit-fit-content;\n width: -moz-fit-content;\n width: fit-content;\n transition: color 0.3s ease;\n line-height: 1.6;\n}\n\n.clepit-output-checklist-text::before,\n.clepit-output-checklist-text::after {\n content: "";\n position: absolute;\n}\n\n.clepit-output-checklist-text::before {\n height: 2px;\n width: 8px;\n left: -27px;\n background: var(--check);\n border-radius: 2px;\n transition: background 0.3s ease;\n}\n\n.clepit-output-checklist-text::after {\n height: 4px;\n width: 4px;\n top: 8px;\n left: -25px;\n border-radius: 50%;\n}\n\n.clepit-output-checklist-checkbox {\n -webkit-appearance: none;\n -moz-appearance: none;\n position: relative;\n height: 15px;\n width: 15px;\n outline: none;\n border: 0;\n margin: 0 15px 0 0;\n cursor: pointer;\n background: var(--background);\n display: grid;\n align-items: center;\n pointer-events: none;\n}\n\n.clepit-output-checklist-checkbox::before,\n.clepit-output-checklist-checkbox::after {\n content: "";\n position: absolute;\n height: 2px;\n top: auto;\n background: var(--check);\n border-radius: 2px;\n}\n\n.clepit-output-checklist-checkbox::before {\n width: 0px;\n right: 60%;\n transform-origin: right bottom;\n}\n\n.clepit-output-checklist-checkbox::after {\n width: 0px;\n left: 40%;\n transform-origin: left bottom;\n}\n\n.clepit-output-checklist-checkbox:checked::before {\n -webkit-animation: clepit-check-01-11 0.4s ease forwards;\n animation: clepit-check-01-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked::after {\n -webkit-animation: clepit-check-02-11 0.4s ease forwards;\n animation: clepit-check-02-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text {\n color: var(--disabled);\n -webkit-animation: clepit-move-11 0.3s ease 0.1s forwards;\n animation: clepit-move-11 0.3s ease 0.1s forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::before {\n background: var(--disabled);\n -webkit-animation: clepit-slice-11 0.4s ease forwards;\n animation: clepit-slice-11 0.4s ease forwards;\n}\n\n.clepit-output-checklist-checkbox:checked + .clepit-output-checklist-text::after {\n -webkit-animation: clepit-firework-11 0.5s ease forwards 0.1s;\n animation: clepit-firework-11 0.5s ease forwards 0.1s;\n}\n\n@-webkit-keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@keyframes clepit-move-11 {\n 50% {\n padding-left: 8px;\n padding-right: 0px;\n }\n 100% {\n padding-right: 4px;\n }\n}\n\n@-webkit-keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@keyframes clepit-slice-11 {\n 60% {\n width: 100%;\n left: 4px;\n }\n 100% {\n width: 100%;\n left: -2px;\n padding-left: 0;\n }\n}\n\n@-webkit-keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@keyframes clepit-check-01-11 {\n 0% {\n width: 4px;\n top: auto;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: auto;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(45deg);\n }\n 100% {\n width: 5px;\n top: 8px;\n transform: rotate(45deg);\n }\n}\n\n@-webkit-keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@keyframes clepit-check-02-11 {\n 0% {\n width: 4px;\n top: 17px;\n transform: rotate(0);\n }\n 50% {\n width: 0px;\n top: 17px;\n transform: rotate(0);\n }\n 51% {\n width: 0px;\n top: 8px;\n transform: rotate(-45deg);\n }\n 100% {\n width: 10px;\n top: 8px;\n transform: rotate(-45deg);\n }\n}\n\n@-webkit-keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n\n@keyframes clepit-firework-11 {\n 0% {\n opacity: 1;\n box-shadow: 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check), 0 0 0 -2px var(--check);\n }\n 30% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n box-shadow: 0 -15px 0 0px var(--check), 14px -8px 0 0px var(--check), 14px 8px 0 0px var(--check), 0 15px 0 0px var(--check), -14px 8px 0 0px var(--check), -14px -8px 0 0px var(--check);\n }\n}\n',An=class e{static{this.placeholder="Add checklist item..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=[];return e.querySelectorAll(`.${N.classNames.block.checklist.item}`).forEach(e=>{const n=e.querySelector('input[type="checkbox"]'),a=e.querySelector(`.${N.classNames.block.checklist.text}`);n&&a&&t.push({checked:n.checked,text:F(a.innerHTML)})}),{items:t}}static render(t,n,a){N.injectStyles("clepit-checklist-input-styles",Cn);const o={items:[]},i=n?{...o,...n}:o,r=N.createStyledElement("div",N.classNames.block.checklist.container,{classNames:a?.classNames?.container,styles:a?.styles?.container});return i.items.length>0?i.items.forEach(n=>e.createAndAppendChecklistItem(n,r,t,a)):e.createAndAppendChecklistItem({checked:!1,text:""},r,t,a),r}static createAndAppendChecklistItem(t,n,a,o){const i=N.createStyledElement("div",N.classNames.block.checklist.item,{classNames:o?.classNames?.item,styles:o?.styles?.item}),r=N.createStyledElement("input",N.classNames.block.checklist.checkbox,{classNames:o?.classNames?.checkbox,styles:o?.styles?.checkbox});r.type="checkbox",r.checked=t.checked;const s=N.createStyledElement("div",N.classNames.block.checklist.text,{classNames:o?.classNames?.text,styles:o?.styles?.text});s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(a,"checklistItemHint",e.placeholder)),s.innerHTML=t.text?.trim()||"",e.addEventListener(a,r,"change",()=>ss.saveBlockData(r)),e.addEventListener(a,s,"keydown",t=>{const r=t,l=n.closest(`.${N.classNames.block.container}`);if(!l)return;const c=ss.getBlockIndex(a,l.getAttribute("data-id")),d=r.metaKey||r.ctrlKey;if(r.shiftKey)switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&ss.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=ss.getBlocks(a);e&&c<e.length-1&&ss.moveBlock(a,c,c+1)}else if(d)switch(r.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),ss.removeBlock(a,c)}else if("Enter"===r.key)if(t.preventDefault(),t.stopPropagation(),R(s.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;const o=ss.getBlockIndex(a,t.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendChecklistItem({checked:!1,text:""},n,a,o);else if("Backspace"===r.key){if(R(s.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),o=e.indexOf(i);if(1===e.length){const e=n.closest(`.${N.classNames.block.container}`);if(!e)return;const t=ss.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;ss.removeBlock(a,t)}else i.remove(),o>0?e[o-1].querySelector(".clepit-checklist-text")?.focus():e[o+1].querySelector(".clepit-checklist-text")?.focus()}}else{ss.ensureActiveBlock(a);const e=ss.getBlocks(a);switch(r.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),o=a.indexOf(i);if(0===o){if(c>0){const t=e[c-1];t&&ss.focusBlock(t)}}else{const e=a[o-1].querySelector(`.${N.classNames.block.checklist.text}`);e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const r=Array.from(n.querySelectorAll(`.${N.classNames.block.checklist.item}`)),s=r.indexOf(i);if(s===r.length-1){if(c<e.length-1){const t=e[c+1];t&&ss.focusBlock(t)}}else{const e=r[s+1].querySelector(`.${N.classNames.block.checklist.text}`);e&&e.focus()}return}}}),e.addEventListener(a,s,"input",ss.handleInput),i.appendChild(r),i.appendChild(s),n.appendChild(i),s.focus()}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll(`.${N.classNames.block.checklist.item}`)),n=t.filter(e=>R(e.querySelector(`.${N.classNames.block.checklist.text}`)?.innerHTML||""));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${N.classNames.block.checklist.item}`);return!t||Array.from(t).every(e=>R(e.querySelector(`.${N.classNames.block.checklist.text}`)?.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>R(e.text))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},En=class e{static render(t,n,a,o){if(N.injectStyles("clepit-checklist-output-styles",Sn),!e.validate(t))return V();if(An.isEmptyData(t))return document.createElement("div");const i=t.items,r=N.createStyledElement("div","clepit-output-checklist",{classNames:o?.container,styles:a?.container});return i.forEach((e,t)=>{const n=N.createStyledElement("div","clepit-output-checklist-item",{classNames:o?.item,styles:a?.item}),i=N.createStyledElement("input","clepit-output-checklist-checkbox",{classNames:o?.checkbox,styles:a?.checkbox});i.type="checkbox",i.checked=e.checked,i.setAttribute("readonly","true");const s=N.createStyledElement("div","clepit-output-checklist-text",{classNames:o?.text,styles:a?.text});e.text&&e.text.trim()&&(s.innerHTML=e.text),i.checked&&n.classList.add("checked"),n.appendChild(i),n.appendChild(s),r.appendChild(n)}),r}static draw(t,n=T){if(!e.validate(t)||An.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-checklist");for(const e of t.items){const t=n.create("div");t.addClass("clepit-output-checklist-item");const o=n.create("input");o.addClass("clepit-output-checklist-checkbox"),o.setAttribute("type","checkbox"),e.checked&&o.setAttribute("checked","checked"),o.setAttribute("readonly","true"),t.append(o);const i=n.create("div");i.addClass("clepit-output-checklist-text"),e.text?.trim()&&i.setHtml(e.text),t.append(i),a.append(t)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)}},Nn={icon:"☑",get input(){return An},label:"Checklist",get output(){return En},shortcut:Ct("K"),testId:"block-type-checklist",type:"checklist"},Ln={icon:"𝕔",get input(){return oe},label:"Code",get output(){return be},shortcut:Ct("C"),testId:"block-type-code",type:"code"},Bn="\n.clepit-collapsible {\n display: block;\n}\n.clepit-collapsible > summary {\n display: flex;\n align-items: flex-start;\n gap: 6px;\n cursor: pointer;\n font-weight: 600;\n list-style: none;\n}\n.clepit-collapsible > summary::-webkit-details-marker {\n display: none;\n}\n.clepit-collapsible > summary::before {\n content: '';\n flex: 0 0 auto;\n width: 8px;\n height: 8px;\n margin-top: 7px;\n border-right: 2px solid currentColor;\n border-bottom: 2px solid currentColor;\n transform: rotate(-45deg);\n transition: transform 120ms ease;\n}\n.clepit-collapsible[open] > summary::before {\n transform: rotate(45deg);\n}\n.clepit-collapsible__children {\n padding-left: 22px;\n}\n.clepit-collapsible__children > * + * {\n margin-top: 8px;\n}\n",$n=`${Bn}\n.clepit-collapsible__title-input {\n border: none;\n outline: none;\n background: transparent;\n font: inherit;\n font-weight: 600;\n width: 100%;\n}\n.clepit-collapsible__add-child {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-collapsible__add-child:hover {\n opacity: 1;\n}\n.clepit-collapsible__child-row {\n display: flex;\n align-items: flex-start;\n gap: 4px;\n}\n.clepit-collapsible__child-row > :first-child {\n flex: 1 1 auto;\n}\n.clepit-collapsible__remove-child {\n border: none;\n background: transparent;\n cursor: pointer;\n opacity: 0.4;\n padding: 2px;\n}\n.clepit-collapsible__remove-child:hover {\n opacity: 1;\n}\n`,In=Bn,Tn=/* @__PURE__ */new WeakMap;var Mn=class e{static{this.placeholder="Section title"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-collapsible")?e:e.querySelector(".clepit-collapsible");if(!t)return{children:[],html:"",open:!1};const n=t.querySelector(".clepit-collapsible__title"),a=t.open??!1,o=Tn.get(t)??[],i=[];return t.querySelectorAll(".clepit-collapsible__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),{children:i,html:F(n?.innerHTML),open:a}}static render(t,n,a){N.injectStyles("collapsible-input",$n);const o={children:[],html:"",open:!0},i=n?{...o,...n}:o,r=N.createStyledElement("details","clepit-collapsible clepit-collapsible--input",{classNames:a?.classNames?.section,styles:a?.styles?.section});r.open=i.open??!0,Tn.set(r,[...i.children??[]]);const s=document.createElement("summary"),l=document.createElement("span");l.className="clepit-collapsible__title",l.setAttribute("contenteditable","true"),l.setAttribute("data-placeholder",Y(t,"collapsibleTitleHint",e.placeholder)),i.html&&(l.innerHTML=F(i.html)),s.appendChild(l),r.appendChild(s);const c=document.createElement("div");return c.className="clepit-collapsible__children",(i.children??[]).forEach(n=>{c.appendChild(e.renderChild(t,n))}),r.appendChild(c),e.addEventListener(t,l,"keydown",ss.handleKeydown),e.addEventListener(t,l,"input",ss.handleInput),r}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-collapsible__child";const a=ss.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-collapsible__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-collapsible");if(!t)return!0;const n=t.querySelector(".clepit-collapsible__title"),a=t.querySelectorAll(".clepit-collapsible__child").length>0;return R(n?.innerHTML)&&!a}static isEmptyData(e){return R(e.html)&&0===(e.children??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},_n="\n.clepit-collection {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-collection__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-collection__label {\n opacity: 0.7;\n}\n",Dn=_n,qn=_n,jn=class e{static render(t,n,a,o){if(N.injectStyles("collection-output",qn),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-collection clepit-output-collection",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-collection-id",t.collectionId);const r=document.createElement("span");r.className="clepit-collection__icon",r.textContent="▦",i.appendChild(r);const s=document.createElement("span");return s.className="clepit-collection__label",s.textContent="Collection",i.appendChild(s),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-collection","clepit-output-collection"),a.setAttribute("data-collection-id",t.collectionId);const o=n.create("span");o.addClass("clepit-collection__icon"),o.setText("▦"),a.append(o);const i=n.create("span");return i.addClass("clepit-collection__label"),i.setText("Collection"),a.append(i),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.collectionId&&e.collectionId.length>0}},zn="\n.clepit-columns {\n display: flex;\n gap: 16px;\n align-items: flex-start;\n}\n.clepit-columns__column {\n flex: 1 1 0;\n min-width: 0;\n}\n.clepit-columns__column > * + * {\n margin-top: 8px;\n}\n@media (max-width: 640px) {\n .clepit-columns {\n flex-direction: column;\n }\n}\n",Hn=`${zn}\n.clepit-columns__add-child,\n.clepit-columns__add-column {\n border: none;\n background: transparent;\n cursor: pointer;\n font: inherit;\n opacity: 0.6;\n padding: 4px 0;\n}\n.clepit-columns__add-child:hover,\n.clepit-columns__add-column:hover {\n opacity: 1;\n}\n`,On=zn,Pn=class e{static render(t,n,a,o){if(N.injectStyles("columns-output",On),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-columns clepit-output-columns",{classNames:o?.container,styles:a?.container});for(const r of t.columns){const t=N.createStyledElement("div","clepit-columns__column",{classNames:o?.column,styles:a?.column});for(const a of r)t.appendChild(e.renderChild(a,n));i.appendChild(t)}return i}static renderChild(e,t){const n=Zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-columns__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("div");o.addClass("clepit-columns","clepit-output-columns");for(const e of t.columns){const t=n.create("div");t.addClass("clepit-columns__column");for(const o of e){const e=er(o,n,a);e&&t.append(e)}o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.columns)&&e.columns.length>=2&&e.columns.length<=4&&e.columns.every(e=>Array.isArray(e))}},Rn="\n.clepit-date {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 8px;\n border-radius: 6px;\n background: rgba(127, 127, 127, 0.12);\n font-variant-numeric: tabular-nums;\n}\n",Fn=`${Rn}\n.clepit-date--input {\n cursor: pointer;\n border: none;\n font: inherit;\n}\n`,Un=Rn,Vn=/^(\d{4})-(\d{2})-(\d{2})$/;function Wn(e){const t=Vn.exec(e.trim());if(!t)return null;const n=Number(t[1]),a=Number(t[2]),o=Number(t[3]),i=new Date(Date.UTC(n,a-1,o));return i.getUTCFullYear()!==n||i.getUTCMonth()!==a-1||i.getUTCDate()!==o?null:i}var Kn=class e{static render(t,n,a,o){N.injectStyles("date-output",Un);const i=e.validate(t)?Wn(t.date):null;if(!i)return V();const r=N.createStyledElement("time","clepit-date clepit-output-date",{classNames:o?.pill,styles:a?.pill});return r.dateTime=t.date,r.textContent=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(i),r}static draw(t,n=T){const a=e.validate(t)?Wn(t.date):null;if(!a)return null;const o=n.create("time");return o.addClass("clepit-date","clepit-output-date"),o.setAttribute("datetime",t.date),o.setText(new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}).format(a)),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.date}},Gn='\n/* Output delimiter styles */\n.clepit-output-delimiter {\n margin: 2rem 0;\n text-align: center;\n}\n\n.clepit-output-delimiter[data-variant="stars"] {\n font-size: 1.5rem;\n font-weight: 300;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n.clepit-output-delimiter hr[data-variant="line"] {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-output-delimiter[data-variant="line"] {\n margin: 0; /* Remove container margin for line variant */\n}\n',Jn=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{variant:e.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line"}}static render(t,n,a){N.injectStyles("clepit-delimiter-input-styles",'\n/* Delimiter block styles */\n.clepit-delimiter-container {\n margin: 0.5rem 0;\n text-align: center;\n}\n\n.clepit-delimiter {\n border: none;\n height: 2px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 20px 0;\n}\n\n.clepit-delimiter[data-variant="stars"] {\n height: auto;\n background: none;\n font-size: 24px;\n letter-spacing: 8px;\n margin: 0; /* Remove margin for star variant */\n}\n\n');const o={variant:"line"},i=n?{...o,...n}:o,r=N.createStyledElement("div","clepit-delimiter-container",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});if(r.setAttribute("contenteditable","true"),r.setAttribute("tabindex","0"),"stars"===i.variant){const e=N.createStyledElement("div","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),e.textContent="***",r.appendChild(e)}else{const e=N.createStyledElement("hr","clepit-delimiter",{classNames:a?.classNames?.[i.variant],styles:a?.styles?.[i.variant]});e.setAttribute("data-variant",i.variant),r.appendChild(e)}return e.addEventListener(t,r,"keydown",e=>{const n=e,a=r.closest(`.${N.classNames.block.container}`);if(!a)return;const o=ss.getBlockIndex(t,a.getAttribute("data-id")),i=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),o>0&&ss.moveBlock(t,o,o-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const n=ss.getBlocks(t);n&&o<n.length-1&&ss.moveBlock(t,o,o+1)}else if(i)switch(n.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),ss.removeBlock(t,o)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},t,o+1);else if("Backspace"===n.key)n.preventDefault(),n.stopPropagation(),ss.removeBlock(t,o);else{ss.ensureActiveBlock(t);const a=ss.getBlocks(t);switch(n.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),o>0){const e=a[o-1];e&&ss.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),o<a.length-1){const e=a[o+1];e&&ss.focusBlock(e)}return}}}),r.focus(),r}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-variant")===n)return;const i={variant:n},r={classNames:o.config.classNames?.blocks?.delimiter,styles:o.config.styles?.blocks?.delimiter},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Xn=class e{static render(t,n,a,o){if(N.injectStyles("clepit-delimiter-output-styles",Gn),!e.validate(t))return V();if(Jn.isEmptyData(t))return document.createElement("div");const i=t.variant,r=N.createStyledElement("div","clepit-output-delimiter",{classNames:o?.[i],styles:a?.[i]});if("stars"===i)r.innerHTML="***",r.setAttribute("data-variant","stars");else{const e=document.createElement("hr");e.setAttribute("data-variant","line"),e.className="clepit-delimiter",r.appendChild(e)}return r}static draw(t,n=T){if(!e.validate(t)||Jn.isEmptyData(t))return null;const a=n.create("div");if(a.addClass("clepit-output-delimiter"),"stars"===t.variant)return a.setHtml("***"),a.setAttribute("data-variant","stars"),a;const o=n.create("hr");return o.setAttribute("data-variant","line"),o.addClass("clepit-delimiter"),a.append(o),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.variant}},Zn="\n.clepit-doc-card {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n cursor: pointer;\n color: inherit;\n text-decoration: none;\n}\n.clepit-doc-card:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-doc-card__icon {\n font-size: 20px;\n line-height: 1;\n}\n.clepit-doc-card__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-doc-card__description {\n opacity: 0.7;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n",Yn=Zn,Qn=Zn,ea=class e{static render(t,n,a,o){if(N.injectStyles("doc-card-output",Qn),!e.validate(t))return V();const i=N.createStyledElement("a","clepit-doc-card clepit-output-doc-card",{classNames:o?.card,styles:a?.card});i.setAttribute("data-page-id",t.pageId),n?.docHref&&(i.href=n.docHref(t.pageId));const r=document.createElement("span");r.className="clepit-doc-card__icon",r.textContent=t.icon??"📄",i.appendChild(r);const s=document.createElement("span"),l=document.createElement("span");if(l.className="clepit-doc-card__title",l.textContent=t.title||"Untitled",s.appendChild(l),t.description){const e=document.createElement("span");e.className="clepit-doc-card__description",e.textContent=t.description,s.appendChild(e)}return i.appendChild(s),i}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("a");o.addClass("clepit-doc-card","clepit-output-doc-card"),o.setAttribute("data-page-id",t.pageId),a?.docHref&&o.setAttribute("href",a.docHref(t.pageId));const i=n.create("span");i.addClass("clepit-doc-card__icon"),i.setText(t.icon??"📄"),o.append(i);const r=n.create("span"),s=n.create("span");if(s.addClass("clepit-doc-card__title"),s.setText(t.title||"Untitled"),r.append(s),t.description){const e=n.create("span");e.addClass("clepit-doc-card__description"),e.setText(t.description),r.append(e)}return o.append(r),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.pageId&&e.pageId.length>0&&"string"==typeof e.title}},ta="\n.clepit-file {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n text-decoration: none;\n}\n.clepit-file:hover {\n background: rgba(127, 127, 127, 0.08);\n}\n.clepit-file__name {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.clepit-file__size {\n opacity: 0.6;\n font-size: 12px;\n}\n",na=`${ta}\n.clepit-file__upload {\n border: 1px dashed rgba(127, 127, 127, 0.5);\n background: transparent;\n cursor: pointer;\n font: inherit;\n padding: 10px 12px;\n border-radius: 8px;\n}\n`,aa=ta;function oa(e){return null==e?"":e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}var ia=class e{static render(t,n,a,o){if(N.injectStyles("file-output",aa),!e.validate(t))return V();const i=N.createStyledElement("a","clepit-file clepit-output-file",{classNames:o?.row,styles:a?.row});i.href=t.url,i.setAttribute("download",t.name),i.setAttribute("rel","noopener noreferrer");const r=document.createElement("span");r.className="clepit-file__name",r.textContent=t.name,i.appendChild(r);const s=oa(t.size);if(s){const e=document.createElement("span");e.className="clepit-file__size",e.textContent=s,i.appendChild(e)}return i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("a");a.addClass("clepit-file","clepit-output-file"),a.setAttribute("href",t.url),a.setAttribute("download",t.name),a.setAttribute("rel","noopener noreferrer");const o=n.create("span");o.addClass("clepit-file__name"),o.setText(t.name),a.append(o);const i=oa(t.size);if(i){const e=n.create("span");e.addClass("clepit-file__size"),e.setText(i),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&("string"==typeof e.url&&0!==e.url.length&&("string"==typeof e.name&&0!==e.name.length&&/^https?:\/\//i.test(e.url)))}},ra='\n.clepit-glance {\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n padding: 12px 14px;\n}\n\n/* A variant tints the surface only. Text keeps the reading colours the rest of\n * the page uses, so a glance stays as legible as the prose around it. */\n.clepit-glance[data-variant="info"] {\n background: var(--clepit-primary-bg);\n}\n\n.clepit-glance[data-variant="success"] {\n background: var(--clepit-success-bg);\n}\n\n.clepit-glance[data-variant="warning"] {\n background: var(--clepit-warning-bg);\n}\n\n.clepit-glance[data-variant="error"] {\n background: var(--clepit-error-bg);\n}\n\n.clepit-glance-caption {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0 0 8px;\n text-transform: uppercase;\n}\n\n/* Labels form a single vertical rail whatever their length, so the reader scans\n * one column for the question and one for the answer. */\n.clepit-glance-rows {\n column-gap: 16px;\n display: grid;\n grid-template-columns: max-content 1fr;\n margin: 0;\n row-gap: 4px;\n}\n\n.clepit-glance-label {\n color: var(--clepit-text-subtle);\n font-size: 14px;\n}\n\n.clepit-glance-value {\n color: var(--clepit-text);\n font-size: 14px;\n margin: 0;\n}\n\n.clepit-glance-value code {\n background: var(--clepit-code-bg);\n border-radius: 4px;\n font-family: \'SF Mono\', \'Monaco\', \'Roboto Mono\', monospace;\n font-size: 13px;\n padding: 1px 5px;\n}\n\n.clepit-glance-value a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-glance-value a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* A single-column stack below the narrowest tablet: a max-content label column\n * squeezes the value to a few characters once the viewport is phone width. */\n@media (max-width: 600px) {\n .clepit-glance-rows {\n grid-template-columns: 1fr;\n row-gap: 2px;\n }\n\n .clepit-glance-value {\n margin: 0 0 6px;\n }\n}\n',sa="At a glance",la=class e{static render(t,n,a,o){if(N.injectStyles("clepit-glance-output-styles",ra),!e.validate(t))return V();if(0===t.rows.length)return document.createElement("div");const i=N.createStyledElement("div","clepit-glance",{classNames:o?.wrapper,styles:a?.wrapper});i.setAttribute("data-variant",t.variant??"plain"),i.setAttribute("data-testid","glance");const r=O("p","clepit-glance-caption");r.textContent=t.caption?.trim()?t.caption:sa,i.appendChild(r);const s=O("dl","clepit-glance-rows");for(const e of t.rows){const t=O("dt","clepit-glance-label");t.textContent=e.label,s.appendChild(t);const n=O("dd","clepit-glance-value");n.innerHTML=F(e.html),s.appendChild(n)}return i.appendChild(s),i}static draw(t,n=T){if(!e.validate(t)||0===t.rows.length)return null;const a=n.create("div");a.addClass("clepit-glance"),a.setAttribute("data-variant",t.variant??"plain"),a.setAttribute("data-testid","glance");const o=n.create("p");o.addClass("clepit-glance-caption"),o.setText(t.caption?.trim()?t.caption:sa),a.append(o);const i=n.create("dl");i.addClass("clepit-glance-rows");for(const e of t.rows){const t=n.create("dt");t.addClass("clepit-glance-label"),t.setText(e.label),i.append(t);const a=n.create("dd");a.addClass("clepit-glance-value"),a.setHtml(e.html),i.append(a)}return a.append(i),a}static validate(e){return null!=e&&"object"==typeof e&&(!!Array.isArray(e.rows)&&e.rows.every(e=>null!==e&&"object"==typeof e&&"string"==typeof e.label&&"string"==typeof e.html))}},ca="\n/* Output header styles */\n.clepit-output-header {\n margin: 0 0 1rem 0;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\nh1.clepit-output-header {\n font-size: 2.5rem;\n line-height: 1.2;\n}\n\nh2.clepit-output-header {\n font-size: 2rem;\n line-height: 1.3;\n}\n\nh3.clepit-output-header {\n font-size: 1.75rem;\n line-height: 1.4;\n}\n\nh4.clepit-output-header {\n font-size: 1.5rem;\n line-height: 1.4;\n}\n\nh5.clepit-output-header {\n font-size: 1.25rem;\n line-height: 1.4;\n}\n\nh6.clepit-output-header {\n font-size: 1rem;\n line-height: 1.4;\n}\n\n/* Output header inline code styling */\n.clepit-output-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output header marker brush effect */\n.clepit-output-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-header mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output header link styles */\n.clepit-output-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n h1.clepit-output-header {\n font-size: 2rem;\n }\n\n h2.clepit-output-header {\n font-size: 1.75rem;\n }\n\n h3.clepit-output-header {\n font-size: 1.5rem;\n }\n}\n",da=class e{static{this.placeholder="Enter heading..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.header}`),n=t?.getAttribute("data-level")||"h1";return{html:F(t?.innerHTML),level:n}}static render(t,n,a){N.injectStyles("clepit-header-input-styles",'\n/* Header block styles */\n.clepit-header {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content {\n font-weight: bold;\n margin: 16px 0 8px 0;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h1 {\n font-size: 32px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h2 {\n font-size: 24px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h3 {\n font-size: 20px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h4 {\n font-size: 18px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h5 {\n font-size: 16px;\n margin: 0;\n color: inherit;\n}\n\n.clepit-block[data-tool="header"] .clepit-block-content h6 {\n font-size: 14px;\n margin: 0;\n color: inherit;\n}\n\n/* Header placeholder styles */\n.clepit-header[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Header link styles */\n.clepit-header a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-header a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Header inline code styling */\n.clepit-header code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Header marker brush effect */\n.clepit-header mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-header mark::before {\n content: \'\';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 20\' preserveAspectRatio=\'none\'><path d=\'M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z\' fill=\'%23FFE047\'/></svg>") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark\'s stacking context */\n}\n\n');const o={html:"",level:"h1"},i=n?{...o,...n}:o,r=i.level??"h1",s=N.createStyledElement(r,N.classNames.block.header,{classNames:a?.classNames?.[r],styles:a?.styles?.[r]});return s.setAttribute("data-level",r),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(t,"headerHint",e.placeholder)),i.html?s.innerHTML=i.html:s.innerHTML="",e.addEventListener(t,s,"keydown",ss.handleKeydown),e.addEventListener(t,s,"input",ss.handleInput),s}static changeLevel(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-level")===n)return;const i={html:t.innerHTML,level:n},r={classNames:o.config.classNames?.blocks?.header,margins:o.config.margins,styles:o.config.styles?.blocks?.header},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.header}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},pa=class e{static render(t,n,a,o){if(N.injectStyles("clepit-header-output-styles",ca),!e.validate(t))return V();if(da.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.level||"h1",s=N.createStyledElement(r,"clepit-output-header",{classNames:o?.[r],styles:a?.[r]});return i&&(s.innerHTML=i),s}static draw(t,n=T){if(!e.validate(t)||da.isEmptyData(t))return null;const a=n.create(t.level||"h1");return a.addClass("clepit-output-header"),t.html&&a.setHtml(t.html),a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ua=`\n/* Image block styles */\n.${N.classNames.block.image.container} {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-image-caption {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content {\n text-align: center;\n}\n\n.clepit-block[data-tool="image"] .clepit-block-content img {\n max-width: 100%;\n height: auto;\n border-radius: 4px;\n}\n\n/* Image Block Enhanced Styles */\n.${N.classNames.block.image.container} {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.${N.classNames.block.image.wrapper} {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.${N.classNames.block.image.wrapper}:hover {\n opacity: 0.9;\n}\n\n.clepit-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-image-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-image-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-image-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-image-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Image caption styling */\n.clepit-image-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Image caption placeholder styles */\n.clepit-image-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Image Drop Area */\n.${N.classNames.block.image.dropArea} {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.${N.classNames.block.image.dropArea}:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-image-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-image-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-image-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n margin-bottom: 8px;\n}\n\n.clepit-image-drop-subtext {\n font-size: 14px;\n color: var(--clepit-text-subtle);\n line-height: 1.4;\n}\n\n.clepit-image-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Image Loading State */\n.clepit-image-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-image-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-image-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Image Error State */\n.clepit-image-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-image-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-image-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-image-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-image-error-retry:hover {\n background: var(--clepit-error);\n}\n\n.clepit-image-refusal {\n display: flex;\n flex-direction: column;\n gap: 6px;\n align-items: center;\n margin: 16px 0;\n padding: 14px 12px;\n text-align: center;\n border: 1px dashed var(--clepit-border);\n border-radius: 8px;\n}\n\n.clepit-image-refusal-title {\n font-size: 14.5px;\n font-weight: 600;\n color: var(--clepit-text);\n}\n\n.clepit-image-refusal-body {\n max-width: 44ch;\n font-size: 13px;\n line-height: 1.5;\n color: var(--clepit-text-muted);\n}\n\n.clepit-image-refusal-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n justify-content: center;\n}\n\n.clepit-image-refusal-action {\n display: inline-flex;\n align-items: center;\n height: 26px;\n padding: 0 10px;\n font-size: 12px;\n font-weight: 550;\n color: var(--clepit-bg);\n white-space: nowrap;\n text-decoration: none;\n background: var(--clepit-primary);\n border-radius: 6px;\n}\n\n.clepit-image-refusal-action:hover {\n background: var(--clepit-primary-hover);\n}\n\n.clepit-image-refusal-remove {\n display: inline-flex;\n align-items: center;\n height: 28px;\n padding: 0 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n color: var(--clepit-text);\n white-space: nowrap;\n background: none;\n border: 0;\n border-radius: 6px;\n cursor: pointer;\n}\n\n.clepit-image-refusal-remove:hover {\n background: var(--clepit-block-highlight-bg);\n}\n\n/* Image delete button */\n.${N.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Image drop area delete button */\n.clepit-image-drop-area .${N.classNames.block.imageDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-image-drop-area .${N.classNames.block.imageDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,ma="\n/* Output image styles */\n.clepit-output-image-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-image {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-image-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Image wrapper positioning */\n.clepit-image-wrapper {\n position: relative;\n cursor: pointer;\n display: flex;\n margin-bottom: 10px;\n}\n.clepit-output-image-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-output-image-wrapper--center {\n justify-content: center;\n}\n\n.clepit-output-image-wrapper--right {\n justify-content: flex-end;\n}\n",ha=class extends Error{constructor(e){super(e.title),this.notice=e,this.name="UploadRefusal"}},ga=class e{static{this.placeholder="Add a caption..."}static{this.validTypes=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/ico","image/x-icon","image/avif","image/heic"]}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("img"),n=e.querySelector(`.${N.classNames.block.image.captionEditable}`),a=e.querySelector(".clepit-image-wrapper");let o="center";return a&&(o=a.classList.contains("clepit-image-wrapper--left")?"left":a.classList.contains("clepit-image-wrapper--right")?"right":"center"),{alignment:o,alt:t?.getAttribute("alt")||"",caption:F(n?.innerHTML),url:t?.getAttribute("src")||""}}static render(t,n,a,o){N.injectStyles("clepit-image-input-styles",ua);const i={alt:"",caption:"",url:""},r=a?{...i,...a}:i,s=N.createStyledElement("div",N.classNames.block.image.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return r.url?e.renderImage(s,r,t,n,o):e.renderDropArea(s,t,n,o),s}static renderImage(t,n,a,o,i){t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.image.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-image-wrapper--left");break;case"center":r.classList.add("clepit-image-wrapper--center");break;case"right":r.classList.add("clepit-image-wrapper--right")}const s=N.createStyledElement("img","clepit-image",{classNames:i?.classNames?.container,styles:i?.styles?.container});s.alt=n?.alt||"",s.src=n?.url||"",s.classList.add("clepit-image");const l=N.createStyledElement("div","clepit-image-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});l.classList.add("clepit-image-caption-container");const c=N.createStyledElement("div",N.classNames.block.image.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.setAttribute("contenteditable","true"),c.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),c.innerHTML=n?.caption||"",e.addEventListener(o,c,"keydown",ss.handleKeydown),e.addEventListener(o,c,"input",ss.handleInput),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),r.appendChild(s),l.appendChild(c),t.appendChild(r),t.appendChild(l),c.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.image.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.setAttribute("data-testid","image-drop"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-image-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="📷";const s=N.createStyledElement("div","clepit-image-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text}),l=document.createElement("strong");l.setAttribute("data-testid","image-drop-title"),l.textContent=Y(a,"imageDropTitle","Drop an image here");const d=document.createElement("span");d.className="clepit-image-click-text",d.setAttribute("data-testid","image-drop-action"),d.textContent=Y(a,"imageDropAction","or click to select"),s.append(l,document.createElement("br"),d);const p=N.createStyledElement("div","clepit-image-drop-subtext",{classNames:o?.classNames?.dropArea?.subtext,styles:o?.styles?.dropArea?.subtext});p.setAttribute("data-testid","image-drop-formats"),p.textContent=Y(a,"imageDropFormats","Supports JPEG, PNG, GIF, WebP, SVG, and other image formats");const u=N.createStyledElement("button",`${N.classNames.block.imageDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});u.type="button",u.textContent="✕",u.setAttribute("data-testid","image-drop-delete");const m=Y(a,"delete","Delete block");u.setAttribute("aria-label",m),i.appendChild(r),i.appendChild(s),i.appendChild(p),i.appendChild(u);const h=c.getState().getInstance(a),g=h?.config.classNames?.tooltips,b=h?.config.styles?.tooltips;me(u,m,"below",g,b),e.addEventListener(a,u,"click",e=>{e.preventDefault(),e.stopPropagation();const t=u.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-image-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-image-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()}),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidImageFile(t)?e.processImageFile(t,n,a,o,i):e.showInvalidType(n,o)}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="image/*",i.classList.add("clepit-hidden-input"),i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidImageFile(i)?e.processImageFile(i,t,n,a,o):e.showInvalidType(t,a)}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidImageFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("image/")}static async processImageFile(t,n,a,o,i){e.showLoading(n,Y(o,"imageUploading","Uploading image..."));try{let r=await a(t);if(r){e.renderImage(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showUploadFailed(n,o)}catch(r){if(r instanceof ha)return void e.showRefusal(n,o,r.notice);console.error("Image upload error:",r),e.showUploadFailed(n,o)}}static showRefusal(t,n,a){t.innerHTML="";const o=N.createStyledElement("div","clepit-image-refusal",void 0);o.setAttribute("data-testid","image-refusal"),o.setAttribute("role","status");const i=document.createElement("span");i.className="clepit-image-refusal-title",i.setAttribute("data-testid","image-refusal-title"),i.textContent=a.title;const r=document.createElement("span");r.className="clepit-image-refusal-body",r.setAttribute("data-testid","image-refusal-body"),r.textContent=a.body;const s=document.createElement("span");if(s.className="clepit-image-refusal-actions",a.action&&/^https?:\/\//i.test(a.action.href)){const e=document.createElement("a");e.className="clepit-image-refusal-action",e.setAttribute("data-testid","image-refusal-action"),e.setAttribute("href",a.action.href),e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"),e.textContent=a.action.label,s.appendChild(e)}const l=document.createElement("button");l.type="button",l.className="clepit-image-refusal-remove",l.setAttribute("data-testid","image-refusal-remove"),l.textContent=a.remove,e.addEventListener(n,l,"click",e=>{e.preventDefault(),e.stopPropagation();const t=l.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(n,ss.getBlockIndex(n,t))}),s.appendChild(l),o.append(i,r,s),t.appendChild(o)}static showLoading(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-image-loading",void 0);n.setAttribute("data-testid","image-uploading"),n.textContent=t,e.appendChild(n)}static showUploadFailed(t,n){e.showError(t,Y(n,"imageUploadFailed","Failed to upload image. Please try again."),"image-upload-failed")}static showInvalidType(t,n){e.showError(t,Y(n,"imageInvalidType","Please select a valid image file (JPEG, PNG, GIF, WebP, SVG, BMP, TIFF, ICO, AVIF, HEIC, JXL, and more)"),"image-invalid-type")}static showError(e,t,n){e.innerHTML="";const a=N.createStyledElement("div","clepit-image-error",void 0);a.setAttribute("data-testid",n),a.textContent=t,e.appendChild(a)}static setAlignment(e,t){const n=e.querySelector(".clepit-image-wrapper");n&&(n.classList.remove("clepit-image-wrapper--left","clepit-image-wrapper--center","clepit-image-wrapper--right"),n.classList.add(`clepit-image-wrapper--${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.image.wrapper} img`),n=e.querySelector(`.${N.classNames.block.image.captionEditable}`);let a=!1,o=!1;return t&&t.getAttribute("src")?.trim()||(a=!0),n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ba=class e{static render(t,n,a,o){if(N.injectStyles("clepit-image-output-styles",ma),!e.validate(t))return V();if(ga.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alt||r||"",l=N.createStyledElement("div","clepit-output-image-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-image-wrapper");if(t.alignment)switch(t.alignment){case"left":c.classList.add("clepit-output-image-wrapper--left");break;case"center":c.classList.add("clepit-output-image-wrapper--center");break;case"right":c.classList.add("clepit-output-image-wrapper--right")}const d=O("img","clepit-output-image");if(d.src=i,d.alt=s,c.appendChild(d),l.appendChild(c),r){const e=N.createStyledElement("figcaption","clepit-output-image-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}return l}static draw(t,n=T){if(!e.validate(t)||ga.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-image-container");const o=n.create("div");o.addClass("clepit-output-image-wrapper");const i=t.alignment??"";i&&o.addClass(`clepit-output-image-wrapper--${i}`);const r=n.create("img");if(r.addClass("clepit-output-image"),r.setAttribute("src",t.url),r.setAttribute("alt",t.alt||t.caption||""),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-image-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},fa=ye,ya=ye,va=(e,t)=>{if("string"!=typeof e){if(Array.isArray(e))for(const n of e)va(n,t);else if(e&&"object"==typeof e){const n=e;if("embed"===n.type&&n.data&&"object"==typeof n.data){const e=n.data;e.issue&&"object"==typeof e.issue&&t.push({...e.issue,url:e.issue.url||e.url||""})}for(const e of Object.values(n))va(e,t)}}else e.includes("clepit-issue")&&t.push(...qe(e))},xa=class e{static collect(e,t){const n=[];va(e??[],n);const a=/* @__PURE__ */new Set,o=[];for(const i of n)i.url&&!a.has(i.url)&&(a.add(i.url),o.push(t?.[i.url]?{...t[i.url],url:i.url}:i));return o}static render(t,n,a,o){N.injectStyles("issues-output",ya);const i=e.collect(n?.documentBlocks,n?.issues);if(0===i.length){const e=N.createStyledElement("div","clepit-issues__empty clepit-output-issues",{classNames:o,styles:a});return e.setAttribute("data-testid","issues-empty"),e.textContent=we(n?.issueLabels,"linkedIssuesEmpty"),e}const r=H(e.table(i,T,n?.issueLabels));return N.applyStyling(r,{classNames:o,styles:a}),r}static draw(t,n=T,a){if(null==t||"object"!=typeof t)return null;const o=e.collect(a?.documentBlocks,a?.issues);return 0===o.length?null:e.table(o,n,a?.issueLabels)}static table(e,t,n){const a=t.create("table");a.addClass("clepit-issues","clepit-output-issues"),a.setAttribute("data-testid","issues-table");const o=t.create("thead"),i=t.create("tr");for(const s of["columnIssue","columnTitle","columnStatus","columnAssignee"]){const e=t.create("th");e.setText(we(n,s)),i.append(e)}o.append(i),a.append(o);const r=t.create("tbody");for(const s of e){const e=t.create("tr");e.setAttribute("data-testid","issues-row"),e.setAttribute("data-issue-url",s.url);const a=t.create("td"),o=t.create("a");o.setAttribute("href",s.url),o.setAttribute("rel","noopener noreferrer nofollow"),o.setAttribute("target","_blank"),o.setText(s.key||s.title||s.url),a.append(o),e.append(a);const i=t.create("td");i.setText(s.key?s.title:""),e.append(i);const l=t.create("td");if(!s.reason){const e=t.create("span");e.addClass("clepit-issue__state"),e.setAttribute("data-issue-category",s.category),e.setText($e(s,n)),l.append(e)}e.append(l);const c=t.create("td");c.setText(s.reason?"":s.assigneeName||we(n,"unassigned")),e.append(c),r.append(e)}return a.append(r),a}},ka="\n/* Output list styles */\n.clepit-output-list {\n margin: 0 0 1rem 0;\n padding-left: 2rem;\n}\n\n.clepit-output-list-item {\n margin: 0.5rem 0;\n line-height: 1.6;\n}\n\n/* Output list link styles */\n.clepit-output-list a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-list a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output list inline code styling */\n.clepit-output-list li code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output list marker brush effect */\n.clepit-output-list li mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-list li mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Responsive Design */\n@media (max-width: 768px) {\n .clepit-output-list {\n padding-left: 1.5rem;\n }\n}\n",wa=class e{static{this.placeholder="Enter list item..."}static{this.defaultType="unordered"}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(t){const n=t.getAttribute("data-type")||e.defaultType,a=[];return t.querySelectorAll("li").forEach(e=>a.push(F(e.innerHTML))),{items:a,type:n}}static render(t,n,a){N.injectStyles("clepit-list-input-styles","\n/* List block styles */\n.clepit-list {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 16px;\n}\n\n.clepit-list-item {\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content {\n padding-left: 40px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content ul,\n.clepit-block[data-tool=\"list\"] .clepit-block-content ol {\n margin: 0;\n padding-left: 20px;\n}\n\n.clepit-block[data-tool=\"list\"] .clepit-block-content li {\n margin: 4px 0;\n}\n\n/* List item placeholder styles */\n.clepit-list-item[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* List item link styles */\n.clepit-list-item a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-list-item a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* List item inline code styling */\n.clepit-list-item code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* List item marker brush effect */\n.clepit-list-item mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-list-item mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o={items:[],type:e.defaultType},i=n?{...o,...n}:o,r="ordered"===i.type?"ol":"ul",s=N.createStyledElement(r,N.classNames.block.list.container,{classNames:a?.classNames?.[i.type]?.container,styles:a?.styles?.[i.type]?.container});s.setAttribute("data-type",i.type);const l=a?.classNames?.[i.type]?.item,c=a?.styles?.[i.type]?.item;return i.items.length>0?i.items.forEach(n=>e.createAndAppendListItem(n,s,t,l,c)):e.createAndAppendListItem("",s,t,l,c),s}static createAndAppendListItem(t,n,a,o,i){const r=N.createStyledElement("li",N.classNames.block.list.item,{classNames:o,styles:i});r.innerHTML=t,r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(a,"listItemHint",e.placeholder)),e.addEventListener(a,r,"keydown",t=>{const s=t,l=n.closest(`.${N.classNames.block.container}`);if(!l)return;const c=ss.getBlockIndex(a,l.getAttribute("data-id")),d=s.metaKey||s.ctrlKey;if(s.shiftKey)switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),c>0&&ss.moveBlock(a,c,c-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const e=ss.getBlocks(a);e&&c<e.length-1&&ss.moveBlock(a,c,c+1)}else if(d)switch(s.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),ss.removeBlock(a,c)}else if("Enter"===s.key)if(t.preventDefault(),t.stopPropagation(),R(r.innerHTML)){e.cleanupEmptyItems(n);const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;const o=ss.getBlockIndex(a,t.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},a,o+1)}else e.createAndAppendListItem("",n,a,o,i);else if("Backspace"===s.key){if(R(r.innerHTML)){t.preventDefault(),t.stopPropagation();const e=Array.from(n.querySelectorAll("li")),o=e.indexOf(r);if(1===e.length){const e=n.closest(`.${N.classNames.block.container}`);if(!e)return;const t=ss.getBlockIndex(a,e.getAttribute("data-id"));if(-1===t)return;ss.removeBlock(a,t)}else r.remove(),o>0?e[o-1].focus():e[o+1].focus()}}else{ss.ensureActiveBlock(a);const e=ss.getBlocks(a);switch(s.key){case"ArrowUp":t.preventDefault(),t.stopPropagation();const a=Array.from(n.querySelectorAll(`.${N.classNames.block.list.item}`)),o=a.indexOf(r);if(0===o){if(c>0){const t=e[c-1];t&&ss.focusBlock(t)}}else{const e=a[o-1];e&&e.focus()}return;case"ArrowDown":t.preventDefault(),t.stopPropagation();const i=Array.from(n.querySelectorAll(`.${N.classNames.block.list.item}`)),s=i.indexOf(r);if(s===i.length-1){if(c<e.length-1){const t=e[c+1];t&&ss.focusBlock(t)}}else{const e=i[s+1];e&&e.focus()}return}}}),e.addEventListener(a,r,"input",ss.handleInput),n.appendChild(r),r.focus()}static changeType(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if(t.getAttribute("data-type")===n)return;const i={items:[...t.querySelectorAll("li")||[]].map(e=>e.innerHTML),type:n},r={classNames:o.config.classNames?.blocks?.list,styles:o.config.styles?.blocks?.list},s=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),l=e.render(a,i,r);t.replaceWith(l),c.getState().updateBlockData(a,s,i)}static cleanupEmptyItems(e){const t=Array.from(e.querySelectorAll("li")),n=t.filter(e=>R(e.innerHTML));if(t.length===n.length){if(t.length<2)return;for(let e=1;e<n.length;e++)n[e].remove()}else n.forEach(e=>e.remove())}static isEmpty(e){const t=e.querySelectorAll(`.${N.classNames.block.list.item}`);return!t||Array.from(t).every(e=>R(e.innerHTML))}static isEmptyData(e){return 0===e.items.length||e.items.every(e=>R(e))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Ca=class e{static render(t,n,a,o){if(N.injectStyles("clepit-list-output-styles",ka),!e.validate(t))return V();if(wa.isEmptyData(t))return document.createElement("div");const i=t.items,r="ordered"===t.type?"ordered":"unordered",s=N.createStyledElement("ordered"===r?"ol":"ul","clepit-output-list",{classNames:o?.[r]?.container,styles:a?.[r]?.container});return i.forEach((e,t)=>{const n=e,i=N.createStyledElement("li","clepit-output-list-item",{classNames:o?.[r]?.item,styles:a?.[r]?.item});n&&n.trim()&&(i.innerHTML=n),s.appendChild(i)}),s}static draw(t,n=T){if(!e.validate(t)||wa.isEmptyData(t))return null;const a="ordered"===t.type,o=n.create(a?"ol":"ul");o.addClass("clepit-output-list");for(const e of t.items){const t=n.create("li");t.addClass("clepit-output-list-item"),e?.trim()&&t.setHtml(e),o.append(t)}return o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.items)&&"string"==typeof e.type}},Sa="\n.clepit-openapi {\n display: flex;\n flex-direction: column;\n gap: 40px;\n margin: 16px 0;\n}\n\n/* Groups and operations are separated by rhythm, never by rules — the same\n * house style the tables follow. */\n.clepit-openapi-group {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\n/* An eyebrow label rather than a heading, matching the uppercase group headings\n * in the docs sidebar so the reference echoes the nav — approved 2026-08-06\n * (direction 2B, \"Eyebrow\"). */\n.clepit-openapi-group-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 0;\n text-transform: uppercase;\n}\n\n.clepit-openapi-operation {\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n\n/* The head is a tinted strip so an operation reads as one bounded unit in a\n * page of a dozen — approved 2026-08-06 (direction 1B, \"Panel\"). */\n.clepit-openapi-operation-head {\n align-items: center;\n background: color-mix(in oklab, var(--clepit-text) 4%, transparent);\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 10px;\n padding: 10px 14px;\n}\n\n.clepit-openapi-operation-body {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n}\n\n.clepit-openapi-method {\n border-radius: 4px;\n color: var(--clepit-bg);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.04em;\n padding: 3px 8px;\n}\n\n.clepit-openapi-method[data-method=\"GET\"] { background: var(--clepit-success); }\n.clepit-openapi-method[data-method=\"POST\"],\n.clepit-openapi-method[data-method=\"PUT\"],\n.clepit-openapi-method[data-method=\"PATCH\"] { background: var(--clepit-primary); }\n.clepit-openapi-method[data-method=\"DELETE\"] { background: var(--clepit-error); }\n\n.clepit-openapi-path {\n color: var(--clepit-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 14px;\n}\n\n.clepit-openapi-host {\n color: var(--clepit-text-subtle);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-left: auto;\n}\n\n.clepit-openapi-summary {\n color: var(--clepit-text);\n font-size: 16px;\n font-weight: 600;\n margin: 0;\n}\n\n.clepit-openapi-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n.clepit-openapi-section-title {\n color: var(--clepit-text-subtle);\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.08em;\n margin: 4px 0 0;\n text-transform: uppercase;\n}\n\n/* A table has no scroll surface of its own — a cell the house style cannot\n * break (a long host URL) would otherwise force the table, and every ancestor\n * up to the page itself, wider than the viewport. */\n.clepit-openapi-table-scroll {\n max-width: 100%;\n overflow-x: auto;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-openapi-table {\n border-collapse: collapse;\n font-size: 14px;\n width: 100%;\n}\n\n.clepit-openapi-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text-subtle);\n font-weight: 600;\n padding: 6px 8px;\n text-align: left;\n}\n\n/* House style: no horizontal dividers between rows. Zebra striping is what\n * separates them instead. */\n.clepit-openapi-table td {\n color: var(--clepit-text);\n padding: 7px 8px;\n vertical-align: top;\n}\n\n.clepit-openapi-table tr:nth-child(even) td {\n background: var(--clepit-surface);\n}\n\n.clepit-openapi-name {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n overflow-wrap: anywhere;\n}\n\n.clepit-openapi-type {\n color: var(--clepit-text-muted);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n}\n\n.clepit-openapi-required {\n color: var(--clepit-error);\n font-size: 12px;\n}\n\n.clepit-openapi-badge {\n background: var(--clepit-primary-bg);\n border-radius: 4px;\n color: var(--clepit-primary);\n font-size: 12px;\n padding: 2px 8px;\n}\n\n.clepit-openapi-status {\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-weight: 600;\n}\n\n.clepit-openapi-status[data-kind=\"success\"] { color: var(--clepit-success); }\n.clepit-openapi-status[data-kind=\"client\"] { color: var(--clepit-warning); }\n.clepit-openapi-status[data-kind=\"server\"] { color: var(--clepit-error); }\n\n/* One response at a time behind a status tab strip — approved 2026-08-06\n * (direction 1B, \"Tabbed\"). */\n.clepit-openapi-responses {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.clepit-openapi-response-tabs {\n border-bottom: 1px solid var(--clepit-border);\n display: flex;\n flex-wrap: wrap;\n gap: 16px;\n margin-bottom: 4px;\n}\n\n.clepit-openapi-response-tab {\n background: none;\n border: 0;\n border-bottom: 2px solid transparent;\n color: var(--clepit-text-muted);\n cursor: pointer;\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 12px;\n margin-bottom: -1px;\n padding: 6px 0;\n}\n\n.clepit-openapi-response-tab[aria-selected=\"true\"] {\n border-bottom-color: var(--clepit-primary);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-openapi-response-tab:focus-visible {\n outline: 2px solid var(--clepit-primary);\n outline-offset: 2px;\n}\n\n.clepit-openapi-response-description {\n color: var(--clepit-text-muted);\n margin: 0;\n}\n\n/* Tabs hide three quarters of the contract from a printed page, so print gets\n * every response expanded and the strip removed. */\n@media print {\n .clepit-openapi-response-tabs { display: none; }\n .clepit-openapi-response { display: block !important; }\n .clepit-openapi-response + .clepit-openapi-response { margin-top: 10px; }\n}\n\n.clepit-openapi-servers {\n color: var(--clepit-text-muted);\n font-size: 14px;\n margin: 0;\n}\n",Aa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ea=(e,t)=>{const n={children:[],cyclic:!1,nullable:!1,required:!1,type:"unknown"};if(!Aa(e))return n;if("string"==typeof e.$ref){const o=(a=e.$ref).split("/").pop()??a;if(n.ref=o,t.stack.has(o))return n.cyclic=!0,n.type=o,n;const i=t.schemas[o];if(void 0===i)return n;t.stack.add(o);const r=Ea(i,t);return t.stack.delete(o),r.ref=o,r}var a;"string"==typeof e.description&&(n.description=e.description),"string"==typeof e.format&&(n.format=e.format),Array.isArray(e.enum)&&(n.enum=e.enum.map(e=>String(e)));const o=["allOf","anyOf","oneOf"].find(t=>Array.isArray(e[t]));if(o){const a=e[o].map(e=>Ea(e,t));if("allOf"===o){n.type="object";for(const e of a)n.children.push(...e.children);return n}const i=a.filter(e=>"null"!==e.type&&!("unknown"===e.type&&e.nullable));return(a.length!==i.length||a.some(e=>e.nullable))&&(n.nullable=!0),n.type=i.map(e=>e.ref??e.type).join(" | ")||"unknown",n.children.push(...i.flatMap(e=>e.children)),n}if(n.type=((e,t)=>{const n=e.type;if(Array.isArray(n)){const e=n.filter(e=>"string"==typeof e);return e.includes("null")&&(t.nullable=!0),e.find(e=>"null"!==e)??"unknown"}return"string"==typeof n?n:"unknown"})(e,n),"array"===n.type){const a=Ea(e.items,t);return n.type=`${a.ref??a.type}[]`,n.children.push(...a.children),n}return"object"===n.type&&((e,t,n)=>{if(!Aa(e.properties))return;const a=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[];for(const[o,i]of Object.entries(e.properties)){const e=Ea(i,n);e.name=o,e.required=a.includes(o),t.children.push(e)}})(e,n,t),n},Na=(e,t)=>Ea(e,{schemas:t,stack:/* @__PURE__ */new Set}),La=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Ba=e=>{if(!La(e))return"string";const t=Array.isArray(e.type)?e.type.find(e=>"null"!==e):e.type;if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum[0];switch(t){case"array":return[];case"boolean":return!0;case"integer":case"number":return 0;case"object":return{};default:return"string"}},$a=e=>{if(!La(e)||!La(e.properties))return;const t={};for(const[n,a]of Object.entries(e.properties))t[n]=Ba(a);return t},Ia=e=>e.security[0],Ta=(e,t)=>{return`${t}${n=e.path,n.replace(/\{([^}]+)\}/g,":$1")}`;var n},Ma={bash:{build:(e,t)=>{const n=[`curl -X ${e.method} "${Ta(e,t)}"`],a=Ia(e);var o;a&&n.push(` -H "Authorization: Bearer $${o=a,o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}"`);const i=$a(e.request);return i&&(n.push(' -H "Content-Type: application/json"'),n.push(` -d '${JSON.stringify(i)}'`)),n.join(" \\\n")},label:"cURL"},dart:{build:(e,t)=>{const n=$a(e.request),a=e.method.toLowerCase(),o=[` Uri.parse('${Ta(e,t)}'),`],i=[],r=Ia(e);return r&&i.push(` 'Authorization': 'Bearer $${r}',`),n&&i.push(" 'Content-Type': 'application/json',"),i.length>0&&o.push(" headers: {",...i," },"),n&&o.push(` body: jsonEncode(${JSON.stringify(n)}),`),[`final response = await http.${a}(`,...o,");"].join("\n")},label:"Dart"},python:{build:(e,t)=>{const n=$a(e.request),a=e.method.toLowerCase(),o=[` "${Ta(e,t)}",`],i=Ia(e);var r;return i&&o.push(` headers={"Authorization": f"Bearer {${r=i,r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase()}}"},`),n&&o.push(` json=${JSON.stringify(n)},`),[`response = requests.${a}(`,...o,")"].join("\n")},label:"Python"},typescript:{build:(e,t)=>{const n=$a(e.request),a=[],o=Ia(e);o&&a.push(` Authorization: \`Bearer \${${o}}\`,`),n&&a.push(" 'Content-Type': 'application/json',");const i=[` method: '${e.method}',`];return a.length>0&&i.push(" headers: {",...a," },"),n&&i.push(` body: JSON.stringify(${JSON.stringify(n,null,2).replace(/\n/g,"\n ")}),`),[`const response = await fetch('${Ta(e,t)}', {`,...i,"});","","const data = await response.json();"].join("\n")},label:"TypeScript"}},_a=["bash","typescript","dart","python"],Da=["get","post","put","patch","delete"],qa=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ja=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),za=(e,t,n)=>!!e&&(!!e.tags?.some(e=>t.includes(e))||(e.paths?.includes(n)??!1)),Ha=e=>(Array.isArray(e.parameters)?e.parameters:[]).filter(qa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},in:"path"===e.in||"header"===e.in?e.in:"query",name:String(e.name??""),required:!0===e.required,...void 0===e.schema?{}:{schema:e.schema}})),Oa=e=>qa(e.responses)?Object.entries(e.responses).map(([e,t])=>{const n=qa(t)?t:{},a=qa(n.content)?n.content:void 0,o=a&&qa(a["application/json"])?a["application/json"]:void 0;return{description:"string"==typeof n.description?n.description:"",...void 0===o?.schema?{}:{schema:o.schema},status:e}}):[],Pa=e=>{if(!qa(e.requestBody))return;const t=qa(e.requestBody.content)?e.requestBody.content:void 0;return(t&&qa(t["application/json"])?t["application/json"]:void 0)?.schema},Ra=e=>{if(!Array.isArray(e.security))return[];const t=e.security.find(qa);return t?Object.keys(t):[]},Fa=e=>{if(!Array.isArray(e.servers))return;const t=e.servers.find(qa);return"string"==typeof t?.url?t.url:void 0},Ua=(e,t)=>e[0]??t.split("/").filter(Boolean)[0]??"default",Va=(e,t)=>{const n=qa(e)?e:{},a=qa(n.info)?n.info:{},o=qa(n.components)?n.components:{},i={groups:[],schemas:qa(o.schemas)?o.schemas:{},servers:(Array.isArray(n.servers)?n.servers:[]).filter(qa).map(e=>({..."string"==typeof e.description?{description:e.description}:{},url:String(e.url??"")})),title:"string"==typeof a.title?a.title:"",version:"string"==typeof a.version?a.version:""},r=qa(n.paths)?n.paths:{},s=/* @__PURE__ */new Map;for(const[l,c]of Object.entries(r))if(qa(c))for(const e of Da){const n=c[e];if(!qa(n))continue;const a=(Array.isArray(n.tags)?n.tags:[]).filter(e=>"string"==typeof e),o=!0===n["x-internal"],i=t.include?.paths?.includes(l)??!1;if(o&&!i)continue;if(za(t.exclude,a,l))continue;if(t.include&&!i&&!za(t.include,a,l))continue;const r={..."string"==typeof n.description?{description:n.description}:{},id:ja(`${e}-${l}`),internal:o,method:e.toUpperCase(),params:Ha(n),path:l,...void 0===Pa(n)?{}:{request:Pa(n)},responses:Oa(n),security:Ra(n),...void 0===Fa(n)?{}:{server:Fa(n)},summary:"string"==typeof n.summary?n.summary:l,tags:a},d=Ua(a,l),p=s.get(d);p?p.operations.push(r):s.set(d,{id:ja(d),operations:[r],title:d})}return i.groups=[...s.values()],i},Wa=(e,t,n,a)=>{const o=e.create(t);return n&&o.addClass(...n.split(" ")),void 0!==a&&o.setText(a),o},Ka=(e,t)=>{const n=Wa(e,"div","clepit-openapi-table-scroll");return n.append(t),n},Ga=(e,t,n,a)=>{const o=Wa(e,"p","clepit-openapi-section-title",t);return o.setAttribute("data-testid",`openapi-section-${n}-${a}`),o},Ja=e=>{const t=e.ref&&"object"===e.type?e.ref:e.type,n=e.enum?e.enum.join(" | "):t;return e.nullable?`${n} | null`:n},Xa=(e,t=0)=>t>6?Ja(e):e.type.endsWith("[]")?0===e.children.length?[]:[Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,Xa(e,t+1)]))]:e.children.length>0?Object.fromEntries(e.children.map(e=>[e.required?e.name:`${e.name}?`,Xa(e,t+1)])):Ja(e),Za=e=>{const t=Number.parseInt(e,10);return t>=200&&t<300?"success":t>=400&&t<500?"client":t>=500?"server":"other"},Ya=(e,t,n,a)=>{const o=Wa(e,"section","clepit-openapi-operation");o.setAttribute("data-testid",`openapi-operation-${t.id}`);const i=t.server??a.defaultServer??n.servers[0]?.url??"";o.setAttribute("data-server",i);const r=Wa(e,"div","clepit-openapi-operation-head"),s=Wa(e,"span","clepit-openapi-method",t.method);s.setAttribute("data-method",t.method),s.setAttribute("data-testid",`openapi-method-${t.id}`);const l=Wa(e,"span","clepit-openapi-path",t.path);if(l.setAttribute("data-testid",`openapi-path-${t.id}`),r.append(s),r.append(l),i){const n=Wa(e,"span","clepit-openapi-host",i);n.setAttribute("data-testid",`openapi-host-${t.id}`),r.append(n)}o.append(r);const c=Wa(e,"div","clepit-openapi-operation-body"),d=Wa(e,"h3","clepit-openapi-summary",t.summary);d.setAttribute("id",t.id),c.append(d),t.description&&c.append(Wa(e,"p","clepit-openapi-description",t.description));const p=Wa(e,"div","clepit-openapi-security");p.setAttribute("data-testid",`openapi-security-${t.id}`),p.append(Wa(e,"span","clepit-openapi-section-title","Auth")),p.appendText(" "),p.append(Wa(e,"span","clepit-openapi-badge",t.security.length>0?t.security.join(", "):"public")),c.append(p);const u=((e,t,n)=>{if(0===t.params.length)return null;const a=Wa(e,"table","clepit-openapi-table");a.setAttribute("data-testid",`openapi-params-${t.id}`);const o=e.create("tr");for(const i of["Name","In","Type","Description"])o.append(Wa(e,"th","clepit-openapi-th",i));a.append(o);for(const i of t.params){const t=e.create("tr"),o=Wa(e,"td","clepit-openapi-name",i.name);i.required&&o.append(Wa(e,"span","clepit-openapi-required"," required")),t.append(o),t.append(Wa(e,"td","clepit-openapi-cell",i.in)),t.append(Wa(e,"td","clepit-openapi-type",Ja(Na(i.schema,n.schemas)))),t.append(Wa(e,"td","clepit-openapi-cell",i.description??"")),a.append(t)}return a})(e,t,n);if(u&&(c.append(Ga(e,"Parameters","parameters",t.id)),c.append(Ka(e,u))),void 0!==t.request){const a=Na(t.request,n.schemas);if(a.children.length>0){c.append(Ga(e,"Body","body",t.id));const n=Wa(e,"div","clepit-openapi-body");n.setAttribute("data-testid",`openapi-body-${t.id}`);const o=be.draw({code:JSON.stringify(Xa(a),null,2),language:"json",showCopy:!0},e);o&&n.append(o),c.append(n)}}t.responses.length>0&&(c.append(Ga(e,"Responses","responses",t.id)),c.append(((e,t,n)=>{const a=Wa(e,"div","clepit-openapi-responses");a.setAttribute("data-testid",`openapi-responses-${t.id}`);const o=Wa(e,"div","clepit-openapi-response-tabs");o.setAttribute("role","tablist"),o.setAttribute("data-testid",`openapi-response-tabs-${t.id}`);const i=[],r=1===t.responses.length;t.responses.forEach((a,s)=>{const l=Wa(e,"div","clepit-openapi-response");l.setAttribute("id",`${t.id}-response-${a.status}`),l.setAttribute("role","tabpanel"),l.setAttribute("data-status",a.status),l.setAttribute("data-testid",`openapi-response-${t.id}-${a.status}`),0!==s&&l.setAttribute("hidden","");const c=Wa(e,"p","clepit-openapi-response-description");if(r){const t=Wa(e,"span","clepit-openapi-status",a.status);t.setAttribute("data-kind",Za(a.status)),c.append(t),c.appendText(` ${a.description}`)}else c.setText(a.description);if(l.append(c),void 0!==a.schema){const t=Na(a.schema,n.schemas);if(t.children.length>0){const n=be.draw({code:JSON.stringify(Xa(t),null,2),language:"json",showCopy:!0},e);n&&l.append(n)}}i.push(l);const d=Wa(e,"button","clepit-openapi-response-tab",a.status);d.setAttribute("type","button"),d.setAttribute("role","tab"),d.setAttribute("aria-controls",`${t.id}-response-${a.status}`),d.setAttribute("aria-selected",0===s?"true":"false"),d.setAttribute("tabindex",0===s?"0":"-1"),d.setAttribute("data-kind",Za(a.status)),d.setAttribute("data-testid",`openapi-response-tab-${t.id}-${a.status}`),o.append(d)}),r||a.append(o);for(const s of i)a.append(s);return a})(e,t,n)));const m=((e,t,n)=>n.flatMap(n=>{const a=Ma[n];return a?[{code:a.build(e,t),label:a.label,language:n}]:[]}))(t,i,a.snippetLanguages??_a);if(m.length>0){c.append(Ga(e,"Try it","try-it",t.id));const n=be.draw({code:m[0].code,language:m[0].language,showCopy:!0,syncKey:"api-reference",variants:m},e);n&&c.append(n)}return o.append(c),o},Qa=class e{static draw(t,n=T){if(!e.validate(t))return null;const a=Va(t.spec,t),o=Wa(n,"div","clepit-openapi");if(a.servers.length>0){const e=Wa(n,"table","clepit-openapi-table clepit-openapi-servers");e.setAttribute("data-testid","openapi-servers");const t=n.create("tr");t.append(Wa(n,"th","clepit-openapi-th","Host")),t.append(Wa(n,"th","clepit-openapi-th","Serves")),e.append(t);for(const o of a.servers){const t=n.create("tr");t.append(Wa(n,"td","clepit-openapi-name",o.url)),t.append(Wa(n,"td","clepit-openapi-cell",o.description??"")),e.append(t)}o.append(Ka(n,e))}for(const e of a.groups){const i=Wa(n,"section","clepit-openapi-group");i.setAttribute("data-testid",`openapi-group-${e.id}`);const r=Wa(n,"h2","clepit-openapi-group-title",e.title);r.setAttribute("id",e.id),i.append(r);for(const o of e.operations)i.append(Ya(n,o,a,t));o.append(i)}return o}static render(t,n,a,o){if(N.injectStyles("clepit-openapi-output-styles",Sa),!e.validate(t))return V();const i=H(e.draw(t,T));o?.container&&i.classList.add(o.container),a?.container&&Object.assign(i.style,a.container),e.attach(i);for(const e of[...i.querySelectorAll(".clepit-output-code-container")])be.activateFromMarkup(e);return i}static activate(t){const n=[e.attach(t)];for(const e of[...t.querySelectorAll(".clepit-output-code-container")])n.push(be.activateFromMarkup(e));return()=>{for(const e of n)e()}}static attach(e){const t=[],n=(e,n,a)=>{e.addEventListener(n,a),t.push({event:n,handler:a,target:e})};for(const a of[...e.querySelectorAll(".clepit-openapi-responses")]){const e=[...a.querySelectorAll(".clepit-openapi-response-tab")],t=[...a.querySelectorAll(".clepit-openapi-response")],o=n=>{e.forEach((e,t)=>{e.setAttribute("aria-selected",t===n?"true":"false"),e.tabIndex=t===n?0:-1}),t.forEach((e,t)=>{e.hidden=t!==n})};e.forEach((t,a)=>{n(t,"click",()=>o(a)),n(t,"keydown",t=>{const n=t.key,i="ArrowRight"===n?1:"ArrowLeft"===n?-1:0,r="Home"===n?0:"End"===n?e.length-1:0===i?-1:(a+i+e.length)%e.length;-1!==r&&(t.preventDefault(),o(r),e[r]?.focus())})})}return()=>{for(const{event:e,handler:n,target:a}of t)a.removeEventListener(e,n)}}static validate(e){return null!=e&&"object"==typeof e&&("string"==typeof e.url&&e.url.length>0||"object"==typeof e.spec&&null!==e.spec&&!Array.isArray(e.spec))}},eo="\n/* Output paragraph styles */\n.clepit-output-paragraph {\n margin: 0 0 1rem 0;\n line-height: 1.6;\n color: var(--clepit-text);\n}\n\n/* Output paragraph inline code styling */\n.clepit-output-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output paragraph marker brush effect */\n.clepit-output-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n/* Output paragraph link styles */\n.clepit-output-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n",to=class e{static{this.placeholder="Start writing..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{html:F(e.querySelector(`.${N.classNames.block.paragraph}`)?.innerHTML)}}static render(t,n,a){N.injectStyles("clepit-paragraph-input-styles","\n/* Paragraph block styles */\n.clepit-paragraph {\n outline: none;\n margin: 0;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 0 20px;\n}\n\n.clepit-block[data-tool=\"paragraph\"] .clepit-block-content {\n font-size: 16px;\n line-height: 1.6;\n}\n\n/* Paragraph placeholder styles */\n.clepit-paragraph[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Paragraph link styles */\n.clepit-paragraph a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-paragraph a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Paragraph inline code styling */\n.clepit-paragraph code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Paragraph marker brush effect */\n.clepit-paragraph mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0; /* create stacking context so ::before sits behind text, not page */\n white-space: pre-wrap; /* ensure leading/trailing spaces inside mark render */\n}\n\n.clepit-paragraph mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1; /* behind text but within mark's stacking context */\n}\n\n");const o=N.createStyledElement("div",N.classNames.block.paragraph,{classNames:a?.classNames,styles:a?.styles});return o.setAttribute("contenteditable","true"),o.setAttribute("data-placeholder",c.getState().getInstance(t)?.config.placeholder||e.placeholder),o.innerHTML=n?.html||"",e.addEventListener(t,o,"keydown",ss.handleKeydown),e.addEventListener(t,o,"input",ss.handleInput),o}static isEmpty(e){return R(e.querySelector(`.${N.classNames.block.paragraph}`)?.innerHTML)}static isEmptyData(e){return R(e.html)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},no=class e{static render(t,n,a,o){if(N.injectStyles("clepit-paragraph-output-styles",eo),!e.validate(t))return V();const i=N.createStyledElement("p","clepit-output-paragraph",{classNames:o,styles:a});if(to.isEmptyData(t))return i.appendChild(document.createElement("br")),i;const r=t.html;return r&&(i.innerHTML=r),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("p");return a.addClass("clepit-output-paragraph"),to.isEmptyData(t)?(a.append(n.create("br")),a):(t.html&&a.setHtml(t.html),a)}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},ao=`\n/* Quote block styles */\n.${N.classNames.block.quote.container} {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 16px 20px;\n margin: 16px 16px 16px 0;\n position: relative;\n}\n\n.${N.classNames.block.quote.text} {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n padding: 4px 6px;\n}\n\n.${N.classNames.block.quote.author} {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n.${N.classNames.block.quote.author}:focus {\n outline: none;\n}\n\n.${N.classNames.block.quote.divider} {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n/* Quote placeholder styles */\n.${N.classNames.block.quote.text}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n.${N.classNames.block.quote.author}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Quote link styles */\n.${N.classNames.block.quote.text} a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.quote.text} a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Quote inline code styling */\n.${N.classNames.block.quote.text} code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n`,oo="\n/* Output quote styles */\n.clepit-output-quote-container {\n background: linear-gradient(135deg, var(--clepit-surface) 0%, var(--clepit-surface-2) 100%);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 12px 14px;\n margin: 20px 0;\n position: relative;\n}\n\n.clepit-output-quote-author {\n color: var(--clepit-text-muted);\n font-size: 0.9em;\n font-style: normal;\n font-family: inherit;\n text-align: right;\n margin-top: 10px;\n}\n\n.clepit-output-quote-divider {\n height: 1px;\n margin: 15px 0;\n background: linear-gradient(to right, transparent, var(--clepit-border-subtle), transparent);\n}\n\n.clepit-output-quote-text {\n font-size: 1.2em;\n line-height: 1.6;\n font-family: cursive, serif;\n font-style: italic;\n margin-bottom: 15px;\n}\n\n.clepit-output-quote-content {\n /* Content styling handled by parent */\n}\n\n/* Output quote link styles */\n.clepit-output-quote a {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n transition: color 0.2s ease;\n}\n\n.clepit-output-quote a:hover {\n color: var(--clepit-primary-hover);\n text-decoration: none;\n}\n\n/* Output quote inline code styling */\n.clepit-output-quote code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n.clepit-output-quote cite code {\n background: var(--clepit-error-bg);\n color: var(--clepit-error);\n padding: 0 4px;\n border-radius: 4px;\n}\n\n/* Output quote marker brush effect */\n.clepit-output-quote mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n\n.clepit-output-quote cite mark {\n background: none;\n position: relative;\n color: inherit;\n display: inline-block;\n z-index: 0;\n white-space: pre-wrap;\n}\n\n.clepit-output-quote cite mark::before {\n content: '';\n position: absolute;\n left: 0;\n right: 0;\n top: 0.15em;\n height: 1.25em;\n transform: rotate(-0.4deg);\n background: url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'><path d='M0,8 C5,2 15,1 25,3 35,5 45,2 55,4 65,6 75,5 85,7 95,9 100,8 100,8 100,14 95,18 85,17 75,16 65,19 55,17 45,15 35,18 25,16 15,14 5,15 0,12 Z' fill='%23FFE047'/></svg>\") no-repeat center / 100% 100%;\n z-index: -1;\n}\n",io=class e{static{this.placeholder="Enter quote..."}static{this.authorPlaceholder="Enter author..."}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector(`.${N.classNames.block.quote.text}`),n=e.querySelector(`.${N.classNames.block.quote.author}`);return{author:F(n?.innerHTML),html:F(t?.innerHTML)}}static render(t,n,a){N.injectStyles("clepit-quote-input-styles",ao);const o=n||{author:"",html:""},i=N.createStyledElement("div",N.classNames.block.quote.container,{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=N.createStyledElement("div",N.classNames.block.quote.text,{classNames:a?.classNames?.text,styles:a?.styles?.text}),s=N.createStyledElement("div",N.classNames.block.quote.author,{classNames:a?.classNames?.author,styles:a?.styles?.author});if(r.innerHTML=o.html||"",r.setAttribute("contenteditable","true"),r.setAttribute("data-placeholder",Y(t,"quoteBodyHint",e.placeholder)),s.innerHTML=o.author||"",s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",Y(t,"quoteAuthorHint",e.authorPlaceholder)),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,s,"keydown",e.handleKeydown),e.addEventListener(t,s,"input",ss.handleInput),i.appendChild(r),o.author){const e=N.createStyledElement("div",N.classNames.block.quote.divider,{classNames:a?.classNames?.divider,styles:a?.styles?.divider});i.appendChild(e)}return i.appendChild(s),i}static handleKeydown(e){const t=e,n=e.currentTarget,a=n.closest(`.${N.classNames.block.container}`),o=ss.getEditorId(a);if(!o)return;const i=ss.getBlockIndex(o,a.getAttribute("data-id")),r=a.querySelector(`.${N.classNames.block.quote.text}`),s=a.querySelector(`.${N.classNames.block.quote.author}`),l=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&ss.moveBlock(o,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=ss.getBlocks(o);t&&i<t.length-1&&ss.moveBlock(o,i,i+1)}else if(l)switch(t.key){case"Delete":case"Backspace":e.preventDefault(),e.stopPropagation(),ss.removeBlock(o,i)}else if("Enter"===t.key)t.preventDefault(),t.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},o,i+1);else if("Backspace"===t.key){if(!R(n.innerHTML))return;t.preventDefault(),t.stopPropagation(),n===r?ss.removeBlock(o,i):n===s&&(R(r.innerHTML)?ss.removeBlock(o,i):r.focus())}else if("ArrowUp"===t.key)if(t.preventDefault(),t.stopPropagation(),n===r){const e=a.previousElementSibling;e&&ss.focusBlock(e)}else r.focus();else if("ArrowDown"===t.key)if(t.preventDefault(),t.stopPropagation(),n===s){const e=a.nextElementSibling;e&&ss.focusBlock(e)}else s.focus()}static handleKeydownInAuthorInput(e){const t=e,n=e.currentTarget,a=n.closest(`.${N.classNames.block.container}`),o=ss.getEditorId(a);if(o)if("Enter"!==t.key||t.shiftKey){if("Backspace"===t.key){if(n.innerHTML?.trim()&&"<br>"!==n.innerHTML.trim())return;t.preventDefault(),t.stopPropagation();const e=a.querySelector(`.${N.classNames.block.quote.text}`);e&&e.focus()}}else{t.preventDefault(),t.stopPropagation();const e=ss.getBlockIndex(o,a.getAttribute("data-id"));ss.insertBlock({data:{html:""},type:"paragraph"},o,e+1)}}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.quote.text}`),n=e.querySelector(`.${N.classNames.block.quote.author}`);let a=!1,o=!1;return t?R(t.innerHTML)&&(a=!0):a=!0,n?R(n.innerHTML)&&(o=!0):o=!0,a&&o}static isEmptyData(e){return R(e.html)&&R(e.author)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ro=class e{static render(t,n,a,o){if(N.injectStyles("clepit-quote-output-styles",oo),!e.validate(t))return V();if(io.isEmptyData(t))return document.createElement("div");const i=t.html,r=t.author||"",s=N.createStyledElement("div","clepit-output-quote-container",{classNames:o?.container,styles:a?.container}),l=N.createStyledElement("div","clepit-output-quote-text",{classNames:o?.text,styles:a?.text}),c=O("div","clepit-output-quote-content");if(i&&i.trim()&&(c.innerHTML=i),l.appendChild(c),s.appendChild(l),r){const e=N.createStyledElement("div","clepit-output-quote-divider",{classNames:o?.divider,styles:a?.divider});s.appendChild(e);const t=N.createStyledElement("div","clepit-output-quote-author",{classNames:o?.author,styles:a?.author});t.textContent=`— ${r}`,s.appendChild(t)}return s.querySelectorAll(`span.${N.classNames.block.tooltip}[data-tooltip]`).forEach(e=>{const t=e;t.hasAttribute("data-tooltip-initialized")||(me(t,String(t.getAttribute("data-tooltip")||""),"above",n?.tooltipClassNames,void 0),t.setAttribute("data-tooltip-initialized","true"))}),s}static draw(t,n=T){if(!e.validate(t)||io.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-quote-container");const o=n.create("div");o.addClass("clepit-output-quote-text");const i=n.create("div");if(i.addClass("clepit-output-quote-content"),t.html?.trim()&&i.setHtml(t.html),o.append(i),a.append(o),t.author){const e=n.create("div");e.addClass("clepit-output-quote-divider"),a.append(e);const o=n.create("div");o.addClass("clepit-output-quote-author"),o.setText(`— ${t.author}`),a.append(o)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.html}},so="\n.clepit-sketch {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n overflow: hidden;\n}\n.clepit-sketch__canvas {\n display: block;\n width: 100%;\n height: 240px;\n touch-action: none;\n}\n.clepit-sketch--input .clepit-sketch__canvas {\n cursor: crosshair;\n}\n",lo=so,co=so,po="http://www.w3.org/2000/svg";function uo(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e.trim())?e.trim():"#000000"}function mo(e){if(e.length<4)return"";const t=[`M ${e[0]} ${e[1]}`];for(let n=2;n+1<e.length;n+=2)t.push(`L ${e[n]} ${e[n+1]}`);return t.join(" ")}var ho=class e{static render(t,n,a,o){if(N.injectStyles("sketch-output",co),!e.validate(t))return V();const i=N.createStyledElement("div","clepit-sketch clepit-output-sketch",{classNames:o?.wrapper,styles:a?.wrapper}),r=document.createElementNS(po,"svg");r.setAttribute("class","clepit-sketch__canvas"),r.setAttribute("viewBox","0 0 1000 240"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("role","img");for(const s of t.strokes??[]){const t=mo(s.points??[]);if(!t)continue;const n=document.createElementNS(po,"path");n.setAttribute("d",t),n.setAttribute("fill","none"),n.setAttribute("stroke",uo(s.color)),n.setAttribute("stroke-width",String(e.safeWidth(s))),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),r.appendChild(n)}return i.appendChild(r),i}static draw(t,n=T){if(!e.validate(t))return null;const a=n.create("div");a.addClass("clepit-sketch","clepit-output-sketch");const o=n.createNS(po,"svg");o.setAttribute("class","clepit-sketch__canvas"),o.setAttribute("viewBox","0 0 1000 240"),o.setAttribute("preserveAspectRatio","none"),o.setAttribute("role","img");for(const i of t.strokes??[]){const t=mo(i.points??[]);if(!t)continue;const a=n.createNS(po,"path");a.setAttribute("d",t),a.setAttribute("fill","none"),a.setAttribute("stroke",uo(i.color)),a.setAttribute("stroke-width",String(e.safeWidth(i))),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),o.append(a)}return a.append(o),a}static safeWidth(e){const t=Number(e.width);return Number.isFinite(t)&&t>0&&t<=64?t:2}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.strokes)}},go=`\n/* Table block styles */\n.clepit-table-container {\n position: relative;\n display: block;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: visible; /* allow buttons to be visible outside */\n margin: 16px 0;\n padding: 20px;\n}\n\n.clepit-table {\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n background: var(--clepit-bg);\n border-radius: 8px;\n border: 1px solid var(--clepit-border);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n.clepit-table-controls {\n display: flex;\n gap: 6px;\n margin: 6px 0;\n}\n\n.clepit-table-btn {\n border: 1px solid var(--clepit-border);\n background: var(--clepit-surface);\n border-radius: 4px;\n padding: 2px 6px;\n font-size: 12px;\n color: var(--clepit-text);\n cursor: pointer;\n}\n\n.clepit-table-btn:hover {\n background: var(--clepit-surface-2);\n}\n\n.clepit-table-corner {\n width: 28px;\n min-width: 28px;\n border-right: 1px solid var(--clepit-border);\n}\n\n.${N.classNames.block.table.headerCell} {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n border-right: 1px solid var(--clepit-border);\n padding: 10px 12px;\n font-weight: 600;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n position: relative;\n}\n\n.${N.classNames.block.table.cell} {\n border-right: 1px solid var(--clepit-border);\n border-bottom: 1px solid var(--clepit-border);\n padding: 10px 12px;\n min-width: 120px;\n vertical-align: top;\n text-align: left;\n}\n\n/* Zebra striping: odd white, even light grey */\n.clepit-table-tbody tr:nth-child(odd) .${N.classNames.block.table.cell} {\n background: var(--clepit-bg);\n}\n\n.clepit-table-tbody tr:nth-child(even) .${N.classNames.block.table.cell} {\n background: var(--clepit-surface);\n}\n\n.${N.classNames.block.table.caption} {\n margin: 8px 0 0 0; /* full width, no horizontal margins */\n width: 100%;\n padding: 10px 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n background: var(--clepit-surface);\n font-size: 13px;\n outline: none;\n flex: 1;\n min-width: 0;\n}\n\n.${N.classNames.block.table.caption}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: rgba(0, 0, 0, 0.6);\n font-style: italic;\n}\n\n/* Table Download Switch Container */\n.clepit-table-download-switch {\n margin: 8px 0 0 0;\n padding: 6px 8px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 13px;\n}\n\n.${N.classNames.block.table.headerCell}:focus,\n.clepit-table-cell:focus {\n outline: 2px solid var(--clepit-primary);\n outline-offset: -2px;\n}\n\n/* Table placeholder styles */\n.${N.classNames.block.table.headerCell}[data-placeholder]:empty::before,\n.${N.classNames.block.table.cell}[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Row handle cell */\n.clepit-table-row-handle {\n position: absolute;\n left: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-handle {\n position: absolute;\n top: -22px;\n left: 50%;\n transform: translateX(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-row-delete {\n position: absolute;\n right: -22px;\n top: 50%;\n transform: translateY(-50%);\n width: 18px;\n height: 18px;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 2px;\n display: none;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n font-size: 10px;\n color: var(--clepit-text-muted);\n z-index: 1001;\n}\n\n.clepit-table-col-delete {\n right: -22px;\n top: calc(50% + 18px);\n transform: translateY(-50%);\n}\n\n/* Show handles on hover/active */\n.clepit-table-row:hover .clepit-row-handle,\n.${N.classNames.block.table.headerCell}:hover .clepit-col-handle,\n.clepit-table-row:hover .clepit-row-delete,\n.${N.classNames.block.table.headerCell}:hover .clepit-col-delete {\n display: flex;\n}\n\n/* Hover/active states like toolbar buttons */\n.clepit-row-handle:hover, .clepit-col-handle:hover,\n.clepit-row-delete:hover, .clepit-col-delete:hover {\n color: var(--clepit-primary);\n}\n\n/* Table menu buttons */\n.clepit-table-row-menu-btn,\n.clepit-table-col-menu-btn {\n position: absolute;\n background: var(--clepit-bg);\n color: var(--clepit-text);\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n padding: 4px 8px;\n font-size: 12px;\n cursor: pointer;\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 1002;\n}\n\n.clepit-table-row-menu-btn:hover,\n.clepit-table-col-menu-btn:hover {\n color: var(--clepit-primary);\n background: var(--clepit-bg);\n border-color: var(--clepit-border);\n}\n\n.clepit-table-row-menu-btn--visible,\n.clepit-table-col-menu-btn--visible {\n display: flex;\n}\n\n/* Table container */\n.clepit-table-container {\n overflow: visible;\n position: relative;\n}\n\n.clepit-table-scroll-container {\n overflow-x: auto;\n overflow-y: visible;\n max-width: 100%;\n}\n\n/* Table caption download container */\n.clepit-table-caption-download-container {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 8px;\n}\n\n.clepit-table-download-switch {\n flex-shrink: 0;\n}\n\n`,bo="\n/* Output table styles */\n.clepit-output-table-container {\n margin: 1rem 0;\n overflow-x: auto;\n}\n\n.clepit-output-table {\n width: 100%;\n border-collapse: collapse;\n border: 1px solid var(--clepit-border);\n border-radius: 8px;\n overflow: hidden;\n background: var(--clepit-bg);\n box-shadow: 0 1px 2px rgba(0,0,0,0.04);\n}\n\n/* House style: rows carry no horizontal dividers and no column rules. Rows are\n * told apart by zebra striping, which is what does that job instead — removing\n * the rules is not a licence to remove the banding too. */\n/* These four rules were assigned from JavaScript, one element at a time, which\n * is a browser call inside a render path. In a stylesheet they cost nothing to\n * a page that draws without a browser, and a caller's own inline style still\n * wins over them exactly as it did before. */\n.clepit-output-table-wrapper {\n overflow: hidden;\n width: 100%;\n border-radius: 4px;\n margin-bottom: 1rem;\n}\n\n.clepit-output-table-scroller {\n overflow-x: auto;\n}\n\n.clepit-output-table {\n table-layout: auto;\n margin-top: 0;\n margin-bottom: 0;\n border-radius: 0;\n}\n\n.clepit-output-table th,\n.clepit-output-table td {\n padding: 10px 12px;\n text-align: left;\n min-width: 120px;\n max-width: 400px;\n}\n\n.clepit-output-table th {\n background: var(--clepit-surface);\n border-bottom: 1px solid var(--clepit-border);\n color: var(--clepit-text);\n font-weight: 600;\n}\n\n.clepit-output-table tbody tr:nth-child(odd) {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table tbody tr:nth-child(even) {\n background: var(--clepit-surface);\n}\n\n/* No hover state: a rendered table is display, not a control. A row that\n * changes colour under the pointer reads as clickable when it is not. */\n\n/* Table Output Caption */\n.clepit-output-table-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Make footer cell neutral so caption styles are visible */\n.clepit-output-table tfoot td,\n.clepit-output-table tfoot .clepit-output-table-caption-cell {\n padding: 0;\n border: 0;\n background: transparent;\n}\n\n.clepit-output-table-download-btn {\n margin-left: auto;\n width: 24px;\n height: 24px;\n border: none;\n outline: none;\n cursor: pointer;\n border-radius: 50%;\n background: transparent;\n transition: all 0.2s ease;\n padding: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.clepit-output-table-download-btn:hover {\n background: var(--clepit-bg);\n}\n\n.clepit-output-table-download-btn:hover .clepit-download-icon {\n stroke: var(--clepit-primary);\n}\n\n.clepit-output-table-download-btn:active {\n transform: scale(0.95);\n}\n\n.clepit-download-icon {\n width: 20px;\n height: 20px;\n stroke: var(--clepit-text-muted);\n transition: stroke 0.2s ease;\n}\n\n.clepit-output-table-footer-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 8px 12px;\n background: var(--clepit-surface);\n border: 1px solid var(--clepit-border);\n border-top: none;\n border-radius: 0 0 8px 8px;\n}\n",fo=class e{static{this.defaultCols=3}static{this.defaultRows=3}static{this.headerPlaceholder="Enter header..."}static{this.cellPlaceholder="Enter text..."}static{this.captionPlaceholder="Add a caption..."}static{this.defaultData={caption:"",data:Array.from({length:e.defaultRows},()=>Array.from({length:e.defaultCols},()=>"")),showDownload:!1}}static{this.eventListenersMap={}}static addEventListener(t,n,a,o,i){n.addEventListener(a,o,i);const r=e.eventListenersMap[t]||[];r.push({element:n,event:a,handler:o,options:i}),e.eventListenersMap[t]=r}static save(t){const n=t.querySelector("table");if(!n)return e.defaultData;const a=n.querySelector("thead tr"),o=a?Array.from(a.querySelectorAll(`.${N.classNames.block.table.headerCell}`)):[],i=[],r=[];for(const e of o){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-col-handle, .clepit-col-delete").forEach(e=>e.remove()),r.push(F(t.innerHTML))}i.push(r);const s=n.querySelectorAll("tbody tr");for(const e of Array.from(s)){const t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),n=[];for(const e of t){const t=e.cloneNode(!0);t.querySelectorAll(".clepit-row-handle, .clepit-row-delete").forEach(e=>e.remove()),n.push(F(t.innerHTML))}i.push(n)}const l=(t.querySelector(".clepit-table-download-switch")?.querySelector('input[type="checkbox"]'))?.checked||!1;return{caption:F(t.querySelector(`.${N.classNames.block.table.caption}`)?.innerHTML||""),data:i,showDownload:l}}static render(t,n,a){N.injectStyles("clepit-table-input-styles",go);const o=n?{...e.defaultData,...n}:e.defaultData,i=N.createStyledElement("div","clepit-table-container",{classNames:a?.classNames?.container,styles:a?.styles?.container}),r=N.createStyledElement("table","clepit-table",{classNames:a?.classNames?.table,styles:a?.styles?.table}),s=N.createStyledElement("thead","clepit-table-thead",{classNames:a?.classNames?.table,styles:a?.styles?.table}),l=e.createRow(t,o.data[0],!0);s.appendChild(l),r.appendChild(s);const d=N.createStyledElement("tbody","clepit-table-tbody",{classNames:a?.classNames?.table,styles:a?.styles?.table});for(let c=1;c<o.data.length;c++){const n=e.createRow(t,o.data[c]);d.appendChild(n)}r.appendChild(d);const p=N.createStyledElement("div","clepit-table-scroll-container");p.appendChild(r),i.appendChild(p);const u=N.createStyledElement("button","clepit-table-btn clepit-row-menu-btn",{classNames:a?.classNames?.rowMenuButton,styles:a?.styles?.rowMenuButton});u.style.position="absolute",u.style.display="none",u.style.zIndex="1000",u.textContent="⋮",i.appendChild(u);const m=N.createStyledElement("button","clepit-table-btn clepit-col-menu-btn",{classNames:a?.classNames?.columnMenuButton,styles:a?.styles?.columnMenuButton});m.style.position="absolute",m.style.display="none",m.style.zIndex="1000",m.textContent="⋯",i.appendChild(m);let h=null,g=-1,b=null;e.addEventListener(t,i,"mouseleave",()=>(u.style.display="none",m.style.display="none",void(b&&(b.remove(),b=null))));const f=e=>{h=e;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.top-n.top+t.height/2-12;u.style.left="4px",u.style.top=`${Math.max(4,a)}px`,u.style.display="flex"},y=e=>{if(g=Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)).indexOf(e),g<0)return;const t=e.getBoundingClientRect(),n=i.getBoundingClientRect(),a=t.left-n.left+t.width/2-12,o=t.top-n.top-20;m.style.left=`${a}px`,m.style.top=`${Math.max(4,o)}px`,m.style.display="flex"};e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest("tr");t&&f(t)}),e.addEventListener(t,s,"mouseover",e=>{const t=e.target.closest(`.${N.classNames.block.table.headerCell}`);t&&y(t)}),e.addEventListener(t,d,"mouseover",e=>{const t=e.target.closest(`.${N.classNames.block.table.cell}`);if(!t)return;const n=t.closest("tr");if(!n)return;const a=Array.from(n.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(t);if(a>=0){const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)[a];e&&y(e)}f(n)});const v=()=>{h&&"none"!==u.style.display&&f(h);const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)[g];e&&"none"!==m.style.display&&y(e)};e.addEventListener(t,window,"scroll",v,{passive:!0}),e.addEventListener(t,p,"scroll",v,{passive:!0}),e.addEventListener(t,u,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),!h)return;const o=Array.from(d.querySelectorAll("tr")),r=o.indexOf(h),s=u.getBoundingClientRect(),c=i.getBoundingClientRect();e.createMenu(t,i,u,m,[{label:"Move up",onClick:()=>{r>0&&(d.insertBefore(h,o[r-1]),ss.saveBlockData(h))},shortcut:ft("up")},{label:"Move down",onClick:()=>{r>=0&&r<o.length-1&&(d.insertBefore(o[r+1],h),ss.saveBlockData(h))},shortcut:ft("down")},{label:"Insert above",onClick:()=>{const n=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));d.insertBefore(a,h),ss.saveBlockData(h)},shortcut:St("up")},{label:"Insert below",onClick:()=>{const n=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`).length||3,a=e.createRow(t,Array.from({length:n},()=>""));h.nextSibling?d.insertBefore(a,h.nextSibling):d.appendChild(a),ss.saveBlockData(h)},shortcut:St("down")},{label:"Delete",onClick:()=>{o.length>1&&(h.remove(),ss.saveBlockData(h))},shortcut:vt()}],s.left-c.left,s.bottom-c.top+4,a,b)}),e.addEventListener(t,m,"click",n=>{if(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation?.(),g<0)return;const o=Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)),r=m.getBoundingClientRect(),s=i.getBoundingClientRect();e.createMenu(t,i,u,m,[{label:"Move left",onClick:()=>{if(g<=0)return;const e=g,t=o[e-1],n=o[e];t&&n&&l.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[e-1],o=n[e];a&&o&&t.insertBefore(o,a)}),g=e-1,ss.saveBlockData(l)},shortcut:ft("left")},{label:"Move right",onClick:()=>{const e=g;if(e<0||e>=o.length-1)return;const t=o[e],n=o[e+1];t&&n&&l.insertBefore(n,t),d.querySelectorAll("tr").forEach(t=>{const n=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[e],o=n[e+1];a&&o&&t.insertBefore(o,a)}),g=e+1,ss.saveBlockData(l)},shortcut:ft("right")},{label:"Insert left",onClick:()=>{const n=g,a=e.createHeaderCell(t,"");l.insertBefore(a,o[n]),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${N.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),ss.saveBlockData(l)},shortcut:St("left")},{label:"Insert right",onClick:()=>{const n=g+1,a=o[g]?.nextSibling||null,i=e.createHeaderCell(t,"");l.insertBefore(i,a),d.querySelectorAll("tr").forEach(a=>{const o=e.createCell(t,""),i=a.querySelectorAll(`.${N.classNames.block.table.cell}`);i[n]?a.insertBefore(o,i[n]):a.appendChild(o)}),ss.saveBlockData(l)},shortcut:St("right")},{label:"Delete",onClick:()=>{const e=l.querySelectorAll(`.${N.classNames.block.table.headerCell}`);if(g<0||e.length<=1)return;const t=e[g];t?.parentElement?.removeChild(t),d.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll(`.${N.classNames.block.table.cell}`);t[g]&&t[g].parentElement?.removeChild(t[g])}),ss.saveBlockData(l)},shortcut:xt()}],r.left-s.left,r.bottom-s.top+4,a,b)});Array.from(d.querySelectorAll("tr")).forEach(n=>(n=>{e.addEventListener(t,n,"mouseenter",()=>f(n))})(n)),Array.from(l.querySelectorAll(`.${N.classNames.block.table.headerCell}`)).forEach(n=>{return a=n,void e.addEventListener(t,a,"mouseenter",()=>y(a));var a});const x=N.createStyledElement("div","clepit-table-caption-download-container",{classNames:a?.classNames?.container,styles:a?.styles?.container});x.style.display="flex",x.style.alignItems="center",x.style.gap="8px",x.style.marginTop="8px";const k=N.createStyledElement("div",`${N.classNames.block.table.caption}`,{classNames:a?.classNames?.caption,styles:a?.styles?.caption});k.contentEditable="true",k.setAttribute("tabindex","0"),k.setAttribute("data-placeholder",Y(t,"tableCaptionHint",e.captionPlaceholder)),k.style.flex="1",k.style.minWidth="0",k.innerHTML=F(o.caption),e.addEventListener(t,k,"input",ss.handleInput),e.addEventListener(t,k,"keydown",e.handleKeydown),e.addEventListener(t,k,"click",e.handleClick),x.appendChild(k);const w=N.createStyledElement("div",`${N.classNames.block.table.downloadSwitch}`);w.style.flexShrink="0";const C=ae.create({checked:o.showDownload||!1,label:"Allow download",onToggle:e=>{const n=i.closest(`.${N.classNames.block.container}`);if(n){const a=n.getAttribute("data-id");a&&c.getState().partialUpdateBlockData(t,ss.getBlockIndex(t,a),{showDownload:e})}}});w.appendChild(C),x.appendChild(w),i.appendChild(x);return e.addEventListener(t,i,"focusin",()=>{const e=document.activeElement;if(e&&i.contains(e))if(e.classList.contains(N.classNames.block.table.cell)){const t=e.closest("tr");t&&(h=t,f(t))}else e.classList.contains(N.classNames.block.table.headerCell)&&y(e)}),i}static createRow(t,n,a){const o=c.getState().getInstance(t),i=o?.config.classNames?.blocks?.table?.row,r=o?.config.styles?.blocks?.table?.row,s=N.createStyledElement("tr",a?`${N.classNames.block.table.headerRow}`:`${N.classNames.block.table.row}`,{classNames:i,styles:r});for(let l=0;l<n.length;l++)s.appendChild(a?e.createHeaderCell(t,n[l]):e.createCell(t,n[l]));return s.querySelector(`.${N.classNames.block.table.cell}`)?.focus(),s}static createCell(t,n){const a=c.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.cell,i=a?.config.styles?.blocks?.table?.cell,r=N.createStyledElement("td",`${N.classNames.block.table.cell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",Y(t,"tableCellHint",e.cellPlaceholder)),r.innerHTML=F(n),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static createHeaderCell(t,n){const a=c.getState().getInstance(t),o=a?.config.classNames?.blocks?.table?.header,i=a?.config.styles?.blocks?.table?.header,r=N.createStyledElement("th",`${N.classNames.block.table.headerCell}`,{classNames:o,styles:i});return r.contentEditable="true",r.setAttribute("tabindex","0"),r.setAttribute("data-placeholder",Y(t,"tableHeaderHint",e.headerPlaceholder)),r.innerHTML=F(n),e.addEventListener(t,r,"input",ss.handleInput),e.addEventListener(t,r,"keydown",e.handleKeydown),e.addEventListener(t,r,"click",e.handleClick),r}static handleAction(t,n){const a=n.querySelector("table");if(a)switch(t){case"addRow":return e.addRow(a);case"removeRow":return e.removeRow(a);case"addColumn":return e.addColumn(a);case"removeColumn":return e.removeColumn(a)}}static addRow(t){const n=t.querySelector("tbody");if(!n)return;const a=ss.getEditorId(t);if(!a)return;const o=t.querySelector("thead tr")?.querySelectorAll("th").length||e.defaultData.data[0].length,i=e.createRow(a,Array.from({length:o},()=>""));n.appendChild(i)}static removeRow(e){const t=e.querySelector("tbody");if(!t)return;const n=t.querySelectorAll("tr");n.length>1&&t.removeChild(n[n.length-1])}static addColumn(t){const n=ss.getEditorId(t);if(!n)return;const a=t.querySelector("thead tr"),o=t.querySelector("tbody");if(!a||!o)return;const i=e.createHeaderCell(n,"");a.appendChild(i),o.querySelectorAll("tr").forEach(t=>{const a=e.createCell(n,"");t.appendChild(a)})}static removeColumn(e){const t=e.querySelector("thead tr"),n=e.querySelector("tbody");if(!t||!n)return;const a=t.querySelectorAll("th");a.length>1&&(t.removeChild(a[a.length-1]),n.querySelectorAll("tr").forEach(e=>{const t=e.querySelectorAll("td");t.length>1&&e.removeChild(t[t.length-1])}))}static createMenu(t,n,a,o,i,r,s,l,c){c&&(c.remove(),c=null);const d=N.createStyledElement("div","clepit-block-operations-menu clepit-table-menu",{classNames:l?.classNames?.menu,styles:l?.styles?.menu});d.classList.add("clepit-block-operations-menu--visible"),d.style.position="absolute",d.style.zIndex="20",d.style.left=`${r}px`,d.style.top=`${s}px`,d.style.minWidth="180px",i.forEach(n=>{const a="delete"===n.label.toLowerCase(),o=N.createStyledElement("div","clepit-menu-item"+(a?" clepit-menu-item--danger":""),{classNames:l?.classNames?.menuItem,styles:l?.styles?.menuItem});o.style.fontSize="14px";const i=N.createStyledElement("span","clepit-menu-icon"),r=n.label.toLowerCase();r.includes("move up")?i.textContent="↑":r.includes("move down")?i.textContent="↓":r.includes("move left")?i.textContent="←":r.includes("move right")?i.textContent="→":r.includes("insert")?i.textContent="+":r.includes("delete")?i.textContent="×":i.textContent="•";const s=N.createStyledElement("span","clepit-menu-text");if(s.textContent=n.label,o.appendChild(i),o.appendChild(s),n.shortcut){const e=N.createStyledElement("span","clepit-menu-shortcut");e.style.marginLeft="auto",e.style.fontSize="9px",e.style.color="#666",e.style.opacity="0.7",e.textContent=n.shortcut,o.appendChild(e)}e.addEventListener(t,o,"click",e=>{e.stopPropagation(),e.stopImmediatePropagation?.(),n.onClick(),c&&(c.remove(),c=null)}),d.appendChild(o)}),n.appendChild(d),c=d;const p=e=>{d.contains(e.target)||e.target===a||e.target===o||(d.remove(),c=null,document.removeEventListener("click",p))};return setTimeout(()=>document.addEventListener("click",p),0),d}static handleClick(e){e.preventDefault(),e.stopPropagation();const t=e.currentTarget.closest(`.${N.classNames.block.container}`);t&&ss.setActiveBlock(t)}static handleKeydown(e){const t=e,n=e.currentTarget,a=ss.getEditorId(n);if(!a)return;const o=n.closest(`.${N.classNames.block.container}`);if(!o)return;const i=ss.getBlockIndex(a,o.getAttribute("data-id")),r=t.metaKey||t.ctrlKey;if(t.shiftKey)switch(t.key){case"ArrowUp":e.preventDefault(),e.stopPropagation(),i>0&&ss.moveBlock(a,i,i-1);break;case"ArrowDown":e.preventDefault(),e.stopPropagation();const t=ss.getBlocks(a);t&&i<t.length-1&&ss.moveBlock(a,i,i+1)}else if(r){const o=n.closest("table"),r=o.querySelector("tbody"),s=o.querySelector("thead tr");switch(t.key){case"ArrowUp":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>0){const e=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(t,a[o-1]),ss.saveBlockData(t);const i=t.querySelectorAll(`.${N.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowDown":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr"),a=Array.from(r.querySelectorAll("tr")),o=a.indexOf(t);if(o>=0&&o<a.length-1){const e=Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n);r.insertBefore(a[o+1],t),ss.saveBlockData(t);const i=t.querySelectorAll(`.${N.classNames.block.table.cell}`)[e];i&&i.focus()}}break;case"ArrowLeft":let t=-1;const l=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))t=l.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(t>0){e.preventDefault(),e.stopPropagation();const a=t,i=l[a-1],r=l[a];if(i&&r&&s.insertBefore(r,i),o.querySelectorAll("tbody tr").forEach(e=>{const t=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),n=t[a-1],o=t[a];n&&o&&e.insertBefore(o,n)}),n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${N.classNames.block.table.cell}`)[a-1];e&&e.focus()}else{r&&r.focus()}ss.saveBlockData(s)}break;case"ArrowRight":let c=-1;const d=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))c=d.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");c=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(c<d.length-1){e.preventDefault(),e.stopPropagation();const t=c,a=d[t],i=d[t+1];if(a&&i&&s.insertBefore(i,a),o.querySelectorAll("tbody tr").forEach(e=>{const n=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)),a=n[t],o=n[t+1];a&&o&&e.insertBefore(o,a)}),n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr").querySelectorAll(`.${N.classNames.block.table.cell}`)[t+1];e&&e.focus()}else{i&&i.focus()}ss.saveBlockData(s)}break;case"Backspace":if(n.classList.contains(N.classNames.block.table.cell)){e.preventDefault(),e.stopPropagation();const t=n.closest("tr");Array.from(r.querySelectorAll("tr")).length>1&&(t.remove(),ss.saveBlockData(t))}else e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i);break;case"Delete":let p=-1;const u=Array.from(s.querySelectorAll(`.${N.classNames.block.table.headerCell}`));if(n.classList.contains(N.classNames.block.table.headerCell))p=u.indexOf(n);else if(n.classList.contains(N.classNames.block.table.cell)){const e=n.closest("tr");p=Array.from(e.querySelectorAll(`.${N.classNames.block.table.cell}`)).indexOf(n)}if(p>=0&&u.length>1){e.preventDefault(),e.stopPropagation();const t=u[p];t?.parentElement?.removeChild(t),o.querySelectorAll("tbody tr").forEach(e=>{const t=e.querySelectorAll(`.${N.classNames.block.table.cell}`);t[p]&&t[p].parentElement?.removeChild(t[p])}),ss.saveBlockData(s)}else e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i)}}else if("Enter"===t.key)e.preventDefault(),e.stopPropagation(),ss.insertBlock({data:{html:""},type:"paragraph"},a,i+1);else if("Backspace"===t.key){const t=n.closest(`.${N.classNames.block.container}`);if(!t)return;Array.from(t.querySelectorAll(`.${N.classNames.block.table.cell},.${N.classNames.block.table.headerCell}`)).every(e=>R(e.innerHTML))&&(e.preventDefault(),e.stopPropagation(),ss.removeBlock(a,i))}else{ss.ensureActiveBlock(a);const o=ss.getBlocks(a);switch(t.key){case"ArrowUp":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(N.classNames.block.table.caption)){const e=n.closest(`.${N.classNames.block.container}`)?.querySelector("table");if(e){const t=e.querySelector("tbody")?.lastElementChild;if(t&&t.cells.length>0){const e=t.cells[t.cells.length-1];return void(e&&e.focus())}}}const t=n.closest("table");if(!t)return;const a=n.closest("tr"),r=Array.from(a?.cells||[]).indexOf(n);if("TBODY"===a?.parentElement?.tagName&&a===a.parentElement.firstElementChild){const e=t.querySelector("thead")?.querySelector("tr");if(e&&e.cells[r])return void e.cells[r].focus()}if(a?.previousElementSibling){const e=a.previousElementSibling.cells[r];e&&e.focus()}else if(i>0){const e=o[i-1];e&&ss.focusBlock(e)}return;case"ArrowDown":if(e.preventDefault(),e.stopPropagation(),n.classList.contains(N.classNames.block.table.caption)){if(i<o.length-1){const e=o[i+1];e&&ss.focusBlock(e)}return}const s=n.closest("table");if(!s)return;const l=n.closest("tr"),c=Array.from(l?.cells||[]).indexOf(n);if("THEAD"===l?.parentElement?.tagName){const e=s.querySelector("tbody")?.firstElementChild;if(e&&e.cells[c])return void e.cells[c].focus()}if(l?.nextElementSibling){const e=l.nextElementSibling.cells[c];e&&e.focus()}else{if("TBODY"===l?.parentElement?.tagName&&l===l.parentElement.lastElementChild){const e=s.closest(`.${N.classNames.block.container}`)?.querySelector(`.${N.classNames.block.table.caption}`);if(e)return void e.focus()}if(i<o.length-1){const e=o[i+1];e&&ss.focusBlock(e)}}return;case"ArrowLeft":if(!U(n,"left"))return;e.preventDefault(),e.stopPropagation();const d=n.closest("table");if(!d)return;const p=n.closest("tr"),u=Array.from(p?.cells||[]).indexOf(n);if(u>0){const e=p?.cells[u-1];e&&e.focus()}else{if("TBODY"===p?.parentElement?.tagName&&p===p.parentElement.firstElementChild){const e=d.querySelector("thead")?.querySelector("tr");if(e&&e.cells.length>0){const t=e.cells[e.cells.length-1];return void(t&&t.focus())}}if(p?.previousElementSibling){const e=p.previousElementSibling,t=e.cells[e.cells.length-1];t&&t.focus()}}return;case"ArrowRight":if(!U(n,"right"))return;e.preventDefault(),e.stopPropagation();const m=n.closest("table");if(!m)return;const h=n.closest("tr"),g=Array.from(h?.cells||[]).indexOf(n);if(g<(h?.cells.length||0)-1){const e=h?.cells[g+1];e&&e.focus()}else{if("THEAD"===h?.parentElement?.tagName){const e=m.querySelector("tbody")?.firstElementChild;if(e&&e.cells.length>0){const t=e.cells[0];return void(t&&t.focus())}}if(h?.nextElementSibling){const e=h.nextElementSibling.cells[0];e&&e.focus()}}return}}}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.table.caption}`),n=e.querySelectorAll(`.${N.classNames.block.table.cell},.${N.classNames.block.table.headerCell}`);let a=!1,o=!1;return t?R(t.innerHTML)&&(a=!0):a=!0,n?Array.from(n).every(e=>R(e.innerHTML))&&(o=!0):o=!0,a&&o}static isEmptyData(e){return R(e.caption)&&e.data.every(e=>e.every(e=>R(e)))}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},yo="http://www.w3.org/2000/svg",vo=["M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15","M12 3V16M12 16L16 11.625M12 16L8 11.625"],xo=/^[=+@\t\r-]/,ko=class e{static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static render(t,n,a,o,i){if(N.injectStyles("clepit-table-output-styles",bo),!e.validate(t))return V();if(fo.isEmptyData(t))return document.createElement("div");const r=e.draw(t,T);if(!r)return document.createElement("div");const s=H(r);o?.container&&s.classList.add(o.container),a?.container&&Object.assign(s.style,a.container);const l=s.querySelector(".clepit-output-table-caption");l&&o?.caption&&l.classList.add(o.caption),l&&a?.caption&&Object.assign(l.style,a.caption);const c=s.querySelector(".clepit-output-table-footer-container");return c&&o?.footerContainer&&c.classList.add(o.footerContainer),c&&a?.footerContainer&&Object.assign(c.style,a.footerContainer),e.attach(s,t,a,o,i),s}static activate(t,n){return!e.validate(n)||fo.isEmptyData(n)?()=>{}:e.attach(t,n)}static attach(t,n,a,o,i){const r=t.querySelector(".clepit-output-table-download-btn");if(!r)return()=>{};o?.downloadButton&&r.classList.add(o.downloadButton),a?.downloadButton&&Object.assign(r.style,a.downloadButton);const s=()=>e.downloadTableAsCSV(n);r.addEventListener("click",s);const l=i?document.getElementById(i):null;if(l){const t=e.eventListenersMap.get(l)??[];t.push({element:r,event:"click",handler:s}),e.eventListenersMap.set(l,t)}const d=i?c.getState().getInstance(i):null,p=me(r,"Download CSV","above",d?.config.classNames?.tooltips,d?.config.styles?.tooltips);return()=>{r.removeEventListener("click",s),p()}}static draw(t,n=T){if(!e.validate(t)||fo.isEmptyData(t))return null;const a=Array.isArray(t.data)&&t.data.length>0?t.data:[];if(0===a.length)return null;const o=n.create("div");o.addClass("clepit-output-table-wrapper");const i=n.create("div");i.addClass("clepit-output-table-scroller");const r=n.create("table");r.addClass("clepit-output-table");const s=n.create("thead"),l=n.create("tr");for(const e of a[0]??[]){const t=n.create("th");t.setText(e),l.append(t)}if(s.append(l),r.append(s),a.length>1){const e=n.create("tbody");for(const t of a.slice(1)){const a=n.create("tr");for(const e of t){const t=n.create("td");t.setText(e),a.append(t)}e.append(a)}r.append(e)}if(i.append(r),o.append(i),t.caption||t.showDownload){const a=n.create("div");if(a.addClass("clepit-output-table-footer-container"),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-table-caption"),t.caption.trim()&&e.setHtml(t.caption),a.append(e)}if(t.showDownload){const t=n.create("button");t.addClass("clepit-output-table-download-btn"),t.setAttribute("type","button"),t.setAttribute("aria-label","Download CSV"),t.append(e.drawDownloadIcon(n)),a.append(t)}o.append(a)}return o}static drawDownloadIcon(e){const t=e.createNS(yo,"svg");t.setAttribute("class","clepit-download-icon"),t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");for(const n of vo){const a=e.createNS(yo,"path");a.setAttribute("d",n),a.setAttribute("stroke","currentColor"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),t.append(a)}return t}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&Array.isArray(e.data)}static downloadTableAsCSV(e){const t=e.data||[];if(0===t.length)return;const n=t.map(e=>e.map(e=>{const t=(e=>xo.test(e)&&Number.isNaN(Number(e))?`'${e}`:e)(e).replace(/"/g,'""');return t.includes(",")||t.includes('"')||t.includes("\n")||t.includes("\r")?`"${t}"`:t}).join(",")).join("\n"),a=new Blob([n],{type:"text/csv;charset=utf-8;"}),o=document.createElement("a"),i=URL.createObjectURL(a);o.setAttribute("href",i),o.setAttribute("download","table-data.csv"),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}static destroy(t){const n=document.getElementById(t);if(!n)return console.warn("TableOutput::destroy: Container not found for containerId:",t);const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n))}},wo="\n.clepit-toc {\n display: block;\n}\n.clepit-toc__entry {\n display: block;\n padding: 2px 0;\n color: inherit;\n text-decoration: none;\n}\n.clepit-toc__entry:hover {\n text-decoration: underline;\n}\n.clepit-toc__empty {\n opacity: 0.55;\n}\n",Co=wo,So=wo,Ao={h1:0,h2:1,h3:2,h4:3,h5:4,h6:5},Eo=class{static render(e,t,n,a){N.injectStyles("toc-output",So);const o=(t?.documentBlocks??[]).filter(e=>"header"===e.type),i=N.createStyledElement("nav","clepit-toc clepit-output-toc",{classNames:a?.list,styles:n?.list});if(0===o.length){const e=document.createElement("div");return e.className="clepit-toc__empty",e.textContent="Table of contents — headings appear here",i.appendChild(e),i}return o.forEach((e,t)=>{const o=e.data,r=N.createStyledElement("a","clepit-toc__entry",{classNames:a?.entry,styles:n?.entry});r.setAttribute("data-toc-index",t.toString());const s=Ao[o.level??"h1"];r.style.paddingLeft=16*s+"px",e.id&&(r.href=`#${e.id}`),r.innerHTML=F(o.html),i.appendChild(r)}),i}static draw(e,t=T,n){if(null==e||"object"!=typeof e)return null;const a=(n?.documentBlocks??[]).filter(e=>"header"===e.type);if(0===a.length)return null;const o=t.create("nav");return o.addClass("clepit-toc","clepit-output-toc"),a.forEach((e,n)=>{const a=e.data,i=t.create("a");i.addClass("clepit-toc__entry"),i.setAttribute("data-toc-index",n.toString()),i.setAttribute("style",`padding-left: ${16*Ao[a.level??"h1"]}px;`),e.id&&i.setAttribute("href",`#${e.id}`),i.setHtml(a.html),o.append(i)}),o}},No="\n.clepit-typeset {\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n padding: 12px;\n}\n.clepit-typeset__kind {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n.clepit-typeset__kind:has(+ .clepit-typeset__title) {\n display: inline-block;\n font-size: 11px;\n font-weight: 700;\n letter-spacing: 0.06em;\n margin-bottom: 0;\n text-transform: uppercase;\n}\n.clepit-typeset__title {\n display: block;\n font-size: 1em;\n font-weight: 600;\n margin: 2px 0 8px;\n opacity: 1;\n}\n.clepit-typeset__title[data-placeholder]:empty::before {\n color: inherit;\n content: attr(data-placeholder);\n font-style: italic;\n font-weight: 400;\n opacity: 0.5;\n pointer-events: none;\n}\n.clepit-typeset__source {\n display: block;\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n}\n.clepit-typeset--input .clepit-typeset__source {\n outline: none;\n}\n.clepit-typeset__diagram {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__node {\n fill: rgba(127, 127, 127, 0.08);\n stroke: currentColor;\n stroke-width: 1.5;\n}\n.clepit-typeset__label {\n fill: currentColor;\n font-size: 13px;\n font-family: inherit;\n}\n.clepit-typeset__edge,\n.clepit-typeset__message,\n.clepit-typeset__lifeline {\n stroke: currentColor;\n fill: none;\n}\n.clepit-typeset__lifeline {\n stroke-dasharray: 4 4;\n opacity: 0.55;\n}\n.clepit-typeset__arrowhead {\n fill: currentColor;\n}\n.clepit-typeset__edge-label {\n fill: currentColor;\n font-size: 12px;\n font-family: inherit;\n}\n.clepit-typeset__activation {\n fill: rgba(127, 127, 127, 0.3);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__note {\n fill: rgba(240, 200, 100, 0.18);\n stroke: currentColor;\n stroke-width: 1;\n}\n.clepit-typeset__formula {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.clepit-typeset__glyph {\n fill: currentColor;\n font-family: ui-serif, Georgia, 'Times New Roman', serif;\n}\n.clepit-typeset__glyph--text {\n font-family: inherit;\n}\n.clepit-typeset__rule,\n.clepit-typeset__radical {\n fill: currentColor;\n}\n.clepit-typeset__radical {\n stroke: currentColor;\n stroke-width: 1.2;\n fill: none;\n}\n.clepit-typeset__fallback-reason {\n display: block;\n opacity: 0.7;\n font-size: 0.85em;\n margin-bottom: 6px;\n}\n",Lo=No,Bo=No,$o=.55,Io=.52,To=(e,t,n)=>e.draw.map(e=>({...e,x:e.x+t,y:e.y+n}));function Mo(e,t=18){switch(e.kind){case"atom":return _o(e.text,e.style,t);case"space":return{depth:0,draw:[],height:0,width:e.width/18*t};case"row":return function(e,t){const n=[];let a=0,o=0,i=0;for(const r of e){const e=Mo(r,t);n.push(...To(e,a,0)),a+=e.width,o=Math.max(o,e.height),i=Math.max(i,e.depth)}return{depth:i,draw:n,height:o,width:a}}(e.items,t);case"script":return function(e,t){const n=Mo(e.base,t),a=Do(t),o=[...n.draw];let i=n.width,r=n.height,s=n.depth;if(null!==e.sup){const s=Mo(e.sup,a),l=Math.max(.62*n.height,.4*t);o.push(...To(s,n.width,-l)),i=Math.max(i,n.width+s.width),r=Math.max(r,l+s.height)}if(null!==e.sub){const r=Mo(e.sub,a),l=Math.max(.5*n.depth,.22*t);o.push(...To(r,n.width,l)),i=Math.max(i,n.width+r.width),s=Math.max(s,l+r.depth)}return{depth:s,draw:o,height:r,width:i}}(e,t);case"fraction":return function(e,t){const n=Mo(e.numerator,t),a=Mo(e.denominator,t),o=.25*t,i=.045*t,r=.18*t,s=Math.max(n.width,a.width)+.3*t,l=-(o+r+n.depth),c=-o+r+a.height;return{depth:c+a.depth,draw:[...To(n,(s-n.width)/2,l),{kind:"rule",thickness:i,width:s,x:0,y:-o},...To(a,(s-a.width)/2,c)],height:-l+n.height,width:s}}(e,t);case"radical":return function(e,t){const n=Mo(e.radicand,t),a=.6*t,o=null===e.index?null:Mo(e.index,Do(Do(t))),i=a+.6*(o?.width??0),r=n.height+.18*t,s=[{height:r+n.depth,kind:"radical",size:t,width:n.width+.2*t,x:i,y:0},...To(n,i+.12*t,0)];null!==o&&s.push(...To(o,.1*t,.55*-r));return{depth:n.depth,draw:s,height:r,width:i+n.width+.3*t}}(e,t);case"bigop":return function(e,t){const n=1.4*t,a=_o(e.symbol,"upright",n),o=Do(t),i=null===e.upper?null:Mo(e.upper,o),r=null===e.lower?null:Mo(e.lower,o),s=Math.max(a.width,i?.width??0,r?.width??0),l=[...To(a,(s-a.width)/2,0)];let c=a.height,d=a.depth;if(null!==i){const e=a.height+i.depth+.16*t;l.push(...To(i,(s-i.width)/2,-e)),c=e+i.height}if(null!==r){const e=a.depth+r.height+.16*t;l.push(...To(r,(s-r.width)/2,e)),d=e+r.depth}return{depth:d,draw:l,height:c,width:s}}(e,t);case"accent":return function(e,t){const n=Mo(e.base,t),a=_o(e.over,"upright",Do(t)),o="_"===e.over;return{depth:o?n.depth+.2*t:n.depth,draw:[...n.draw,...To(a,(n.width-a.width)/2,o?n.depth+.18*t:-(n.height+.04*t))],height:o?n.height:n.height+.2*t,width:n.width}}(e,t);case"delimited":return function(e,t){const n=Mo(e.body,t),a=n.height+n.depth,o=Math.max(t,a*(1/.55)*.62),i=""===e.open?{depth:0,draw:[],height:0,width:0}:_o(e.open,"upright",o),r=""===e.close?{depth:0,draw:[],height:0,width:0}:_o(e.close,"upright",o),s=e=>(n.height-n.depth)/2-(e.height-e.depth)/2;return{depth:Math.max(n.depth,i.depth-s(i),r.depth-s(r)),draw:[...To(i,0,s(i)),...To(n,i.width,0),...To(r,i.width+n.width,s(r))],height:Math.max(n.height,i.height+s(i),r.height+s(r)),width:i.width+n.width+r.width}}(e,t);case"matrix":return function(e,t){const n=e.rows.map(e=>e.map(e=>Mo(e,t))),a=Math.max(...n.map(e=>e.length),0),o=[];for(let v=0;v<a;v+=1)o.push(Math.max(...n.map(e=>e[v]?.width??0),0));const i=n.map(e=>Math.max(...e.map(e=>e.height),0)),r=n.map(e=>Math.max(...e.map(e=>e.depth),0)),s=.6*t,l=.35*t,c=o.reduce((e,t)=>e+t,0)+s*Math.max(a-1,0),d=i.reduce((e,t,n)=>e+t+(r[n]??0),0)+l*Math.max(n.length-1,0),p=[];let u=-d/2;for(const[v,x]of n.entries()){u+=i[v]??0;let e=0;for(const[t,n]of x.entries()){const a=o[t]??0;p.push(...To(n,e+(a-n.width)/2,u)),e+=a+s}u+=(r[v]??0)+l}const[m,h]=qo[e.style],g=Math.max(t,.62*d),b=""===m?{depth:0,draw:[],height:0,width:0}:_o(m,"upright",g),f=""===h?{depth:0,draw:[],height:0,width:0}:_o(h,"upright",g),y=e=>(e.height-e.depth)/2;return{depth:d/2,draw:[...To(b,0,y(b)),...p.map(e=>({...e,x:e.x+b.width})),...To(f,b.width+c,y(f))],height:d/2,width:b.width+c+f.width}}(e,t)}}function _o(e,t,n){const a="italic"===t?$o:Io;return{depth:.22*n,draw:[{kind:"glyph",size:n,style:t,text:e,x:0,y:0}],height:.72*n,width:e.length*a*n}}function Do(e){return Math.max(9,.7*e)}var qo={bracket:["[","]"],"double-pipe":["‖","‖"],paren:["(",")"],pipe:["|","|"],plain:["",""]};var jo={alpha:"α",beta:"β",chi:"χ",Delta:"Δ",delta:"δ",epsilon:"ϵ",eta:"η",Gamma:"Γ",gamma:"γ",iota:"ι",kappa:"κ",Lambda:"Λ",lambda:"λ",mu:"μ",nu:"ν",Omega:"Ω",omega:"ω",Phi:"Φ",Pi:"Π",Psi:"Ψ",phi:"ϕ",pi:"π",psi:"ψ",rho:"ρ",Sigma:"Σ",sigma:"σ",Theta:"Θ",tau:"τ",theta:"θ",Upsilon:"Υ",upsilon:"υ",varepsilon:"ε",varphi:"φ",vartheta:"ϑ",Xi:"Ξ",xi:"ξ",zeta:"ζ"},zo={angle:"∠",approx:"≈",ast:"∗",cap:"∩",cdot:"⋅",cup:"∪",div:"÷",equiv:"≡",exists:"∃",forall:"∀",geq:"≥",in:"∈",infty:"∞",Leftarrow:"⇐",leftarrow:"←",leftrightarrow:"↔",leq:"≤",mp:"∓",nabla:"∇",neg:"¬",neq:"≠",notin:"∉",parallel:"∥",partial:"∂",perp:"⊥",pm:"±",propto:"∝",Rightarrow:"⇒",rightarrow:"→",sim:"∼",simeq:"≃",star:"⋆",subset:"⊂",subseteq:"⊆",supset:"⊃",supseteq:"⊇",times:"×",to:"→"},Ho={bigcap:"⋂",bigcup:"⋃",int:"∫",lim:"lim",oint:"∮",prod:"∏",sum:"∑"},Oo=["arccos","arcsin","arctan","cos","cosh","cot","csc","deg","det","dim","exp","gcd","ln","log","max","min","sec","sin","sinh","tan","tanh"],Po={bar:"‾",ddot:"¨",dot:"˙",hat:"^",tilde:"~",vec:"→"},Ro={",":3,";":5,":":4,"!":-3,qquad:36,quad:18},Fo={".":"","(":"(",")":")","[":"[","]":"]","\\{":"{","\\}":"}","\\|":"‖","|":"|"},Uo=["catcode","csname","def","href","include","input","newcommand","renewcommand","url","write"],Vo={bmatrix:"bracket",matrix:"plain",pmatrix:"paren",Vmatrix:"double-pipe",vmatrix:"pipe"},Wo=/[A-Za-z0-9+\-=<>()[\]|,./!:;]/,Ko=/[A-Za-z]/,Go=/[0-9]/,Jo={mathbf:"bold",mathit:"italic",mathrm:"upright",text:"text"},Xo=class{constructor(e){this.source=e,this.at=0}get done(){return this.at>=this.source.length}peek(e=0){return this.source[this.at+e]??""}take(){const e=this.peek();return this.at+=1,e}skipSpace(){for(;!this.done&&/\s/.test(this.peek());)this.at+=1}readCommand(){if(this.at+=1,!Ko.test(this.peek()))return this.take();let e="";for(;Ko.test(this.peek());)e+=this.take();return e}},Zo=class extends Error{};function Yo(e){const t=new Xo(e);try{const e=Qo(t,null);if(ti(t))throw new Zo("a \\right appears without a matching \\left");if(!t.done)throw new Zo(`"${t.peek()}" is unexpected here`);return{ok:!0,root:e}}catch(n){if(n instanceof Zo)return{ok:!1,reason:n.message};throw n}}function Qo(e,t){const n=[];for(;(e.skipSpace(),!e.done)&&("}"!==t||"}"!==e.peek())&&("]"!==t||"]"!==e.peek())&&("cell"!==t||"&"!==e.peek()&&!ei(e)&&!ni(e))&&!ti(e);){const t=ai(e);if(null===t)break;n.push(t)}return(e=>1===e.length&&void 0!==e[0]?e[0]:{items:e,kind:"row"})(n)}function ei(e){return"\\"===e.peek()&&"\\"===e.peek(1)}function ti(e){return!!e.source.startsWith("\\right",e.at)&&!Ko.test(e.peek(6))}function ni(e){return"\\"===e.peek()&&e.source.startsWith("\\end",e.at)}function ai(e){const t=oi(e);if(null===t)return null;let n=null,a=null;for(;;){e.skipSpace();const t=e.peek();if("^"!==t&&"_"!==t)break;e.take();const o=oi(e);if(null===o)throw new Zo(`"${t}" has nothing after it`);if("^"===t){if(null!==a)throw new Zo("a term carries two superscripts");a=o}else{if(null!==n)throw new Zo("a term carries two subscripts");n=o}}return null===n&&null===a?t:"bigop"===t.kind?{...t,lower:n,upper:a}:{base:t,kind:"script",sub:n,sup:a}}function oi(e){if(e.skipSpace(),e.done)return null;const t=e.peek();if("}"===t||"&"===t||"^"===t||"_"===t)return null;if("{"===t){e.take();const t=Qo(e,"}");if("}"!==e.peek())throw new Zo("a { group is never closed");return e.take(),t}if("\\"===t)return function(e){const t=e.readCommand();if(Uo.includes(t))throw new Zo(`"\\${t}" is refused for safety, not merely unsupported`);if("\\"===t)throw new Zo("a row break appears outside a matrix");if("begin"===t)return function(e){const t=ri(e),n=Vo[t];if(void 0===n)throw new Zo(`the "${t}" environment is not supported yet`);const a=[];let o=[];for(let i=0;i<4096;i+=1)if(o.push(Qo(e,"cell")),e.skipSpace(),"&"!==e.peek()){if(!ei(e)){if(ni(e)){e.at+=4;const i=ri(e);if(i!==t)throw new Zo(`\\begin{${t}} is closed by \\end{${i}}`);return a.push(o),{kind:"matrix",rows:a,style:n}}throw new Zo(`\\begin{${t}} is never closed`)}e.at+=2,a.push(o),o=[]}else e.take();throw new Zo(`\\begin{${t}} is never closed`)}(e);if("end"===t)throw new Zo("an \\end appears without a matching \\begin");if("frac"===t||"dfrac"===t||"tfrac"===t){const t=ii(e);return{denominator:ii(e),kind:"fraction",numerator:t}}if("sqrt"===t)return function(e){e.skipSpace();let t=null;if("["===e.peek()){if(e.take(),t=Qo(e,"]"),"]"!==e.peek())throw new Zo("a \\sqrt index is never closed");e.take()}return{index:t,kind:"radical",radicand:ii(e)}}(e);if("left"===t)return function(e){const t=si(e,"left"),n=Qo(e,null);if(!ti(e))throw new Zo("a \\left has no matching \\right");return e.at+=6,{body:n,close:si(e,"right"),kind:"delimited",open:t}}(e);if("right"===t)throw new Zo("a \\right appears without a matching \\left");const n=Jo[t];if(void 0!==n)return{kind:"atom",style:n,text:ri(e)};const a=Po[t];if(void 0!==a)return{base:ii(e),kind:"accent",over:a};if("overline"===t)return{base:ii(e),kind:"accent",over:"‾"};if("underline"===t)return{base:ii(e),kind:"accent",over:"_"};const o=Ho[t];if(void 0!==o)return{kind:"bigop",lower:null,symbol:o,upper:null};const i=jo[t];if(void 0!==i)return{kind:"atom",style:"italic",text:i};const r=zo[t];if(void 0!==r)return{kind:"atom",style:"upright",text:r};if(Oo.includes(t))return{kind:"atom",style:"upright",text:t};const s=Ro[t];if(void 0!==s)return{kind:"space",width:s};const l=Fo[`\\${t}`];if(void 0!==l)return{kind:"atom",style:"upright",text:l};throw new Zo(`"\\${t}" is not supported yet`)}(e);if(Wo.test(t))return e.take(),{kind:"atom",style:Go.test(t)?"upright":"italic",text:t};throw new Zo(`"${t}" is not a character this engine understands`)}function ii(e){if(e.skipSpace(),"{"!==e.peek()){const t=oi(e);if(null===t)throw new Zo("a command is missing its argument");return t}e.take();const t=Qo(e,"}");if("}"!==e.peek())throw new Zo("a { group is never closed");return e.take(),t}function ri(e){if(e.skipSpace(),"{"!==e.peek())throw new Zo("a text command is missing its { group");e.take();let t="",n=1;for(;!e.done;){const a=e.peek();if("{"===a&&(n+=1),"}"===a&&(n-=1,0===n))return e.take(),t;t+=e.take()}throw new Zo("a text command’s { group is never closed")}function si(e,t){e.skipSpace();const n=e.peek();if("\\"===n){const t=e.readCommand(),n=Fo[`\\${t}`];if(void 0===n)throw new Zo(`"\\${t}" is not a delimiter this engine understands`);return n}const a=Fo[n];if(void 0===a)throw new Zo(`\\${t} is missing a delimiter`);return e.take(),a}var li={bold:{style:"normal",weight:"700"},italic:{style:"italic",weight:"400"},text:{style:"normal",weight:"400"},upright:{style:"normal",weight:"400"}};function ci(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function di(e,t=T){const n=e.width+16,a=e.height+e.depth+16,o=e.height+8,i=ci("svg",{class:"clepit-typeset__formula",height:a,role:"img",viewBox:`0 0 ${n} ${a}`,width:n},t);for(const r of e.draw){if("glyph"===r.kind){const e=li[r.style],n=ci("text",{class:"clepit-typeset__glyph","dominant-baseline":"alphabetic","font-size":r.size,"font-style":e.style,"font-weight":e.weight,x:r.x+8,y:o+r.y},t);"text"===r.style&&n.setAttribute("class","clepit-typeset__glyph clepit-typeset__glyph--text"),n.setText(r.text),i.append(n);continue}"rule"!==r.kind?i.append(pi(r,o,t)):i.append(ci("rect",{class:"clepit-typeset__rule",height:r.thickness,width:r.width,x:r.x+8,y:o+r.y-r.thickness/2},t))}return i}function pi(e,t,n){const a=e.x+8,o=t+e.y-e.height,i=t+e.y,r=.32*e.size;return ci("path",{class:"clepit-typeset__radical",d:[`M ${a-1.6*r} ${i-.45*e.height}`,`L ${a-.9*r} ${i-.55*e.height}`,`L ${a-.2*r} ${i}`,`L ${a+.35*r} ${o}`,`L ${a+e.width} ${o}`].join(" "),fill:"none"},n)}var ui=72,mi=40,hi=28,gi=16;function bi(e){return"flowchart"===e.kind?function(e){const t="LR"===e.direction||"RL"===e.direction,n=function(e){const t=/* @__PURE__ */new Map;for(const a of e.nodes)t.set(a.id,0);const n=function(e){const t=/* @__PURE__ */new Map;for(const o of e.edges)t.set(o.from,[...t.get(o.from)??[],o]);const n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Set;for(const o of e.nodes){if(n.has(o.id))continue;n.set(o.id,"visiting");const e=[{id:o.id,index:0}];for(;e.length>0;){const o=e[e.length-1],i=t.get(o.id)??[];if(o.index>=i.length){n.set(o.id,"done"),e.pop();continue}const r=i[o.index];o.index+=1;const s=n.get(r.to);"visiting"===s?a.add(r):void 0===s&&(n.set(r.to,"visiting"),e.push({id:r.to,index:0}))}}return e.edges.filter(e=>!a.has(e))}(e);for(let a=0;a<e.nodes.length;a+=1){let e=!1;for(const a of n){if(a.from===a.to)continue;const n=(t.get(a.from)??0)+1;n>(t.get(a.to)??0)&&(t.set(a.to,n),e=!0)}if(!e)break}return t}(e),a=/* @__PURE__ */new Map;for(const b of e.nodes){const e=n.get(b.id)??0;a.set(e,[...a.get(e)??[],b.id])}const o=/* @__PURE__ */new Map;for(const b of e.nodes)o.set(b.id,fi(b.label,ui));const i=/* @__PURE__ */new Map,r=[...a.keys()].sort((e,t)=>e-t),s=e=>t?e.length*mi+(e.length-1)*hi:e.reduce((e,t)=>e+(o.get(t)??ui),0)+(e.length-1)*hi,l=Math.max(...r.map(e=>s(a.get(e)??[])),0);for(const b of r){const n=a.get(b)??[],r=gi+b*((t?ui:mi)+64);let c=gi+(l-s(n))/2;for(const a of n){const n=e.nodes.find(e=>e.id===a);if(void 0===n)continue;const s=o.get(a)??ui;i.set(a,{height:mi,id:a,label:n.label,shape:n.shape,width:s,x:t?r:c,y:t?c:r}),c+=(t?mi:s)+hi}}const c=e.nodes.map(e=>i.get(e.id)).filter(e=>void 0!==e),d=Math.max(...c.map(e=>e.x+e.width),0),p=Math.max(...c.map(e=>e.y+e.height),0),u=(t?p:d)+24,m=e.edges.map(e=>function(e,t,n,a){const o=t.get(e.from),i=t.get(e.to);if(void 0===o||void 0===i)return null;if(n?i.x<o.x:i.y<o.y){const t=n?{x:o.x+o.width/2,y:o.y+o.height}:{x:o.x+o.width,y:o.y+o.height/2},r=n?{x:i.x+i.width/2,y:i.y+i.height}:{x:i.x+i.width,y:i.y+i.height/2},s=n?{x:t.x,y:a}:{x:a,y:t.y},l=n?{x:r.x,y:a}:{x:a,y:r.y};return{arrow:e.arrow,label:e.label,labelX:(s.x+l.x)/2,labelY:(s.y+l.y)/2,line:e.line,points:[t,s,l,r]}}const r=n?{x:o.x+o.width,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height},s=n?{x:i.x,y:i.y+i.height/2}:{x:i.x+i.width/2,y:i.y};return{arrow:e.arrow,label:e.label,labelX:(r.x+s.x)/2,labelY:(r.y+s.y)/2,line:e.line,points:[r,s]}}(e,i,t,u)).filter(e=>null!==e),h=m.some(e=>e.points.length>2),g=t?d:Math.max(d,h?u:0);return{edges:m,height:(t?Math.max(p,h?u:0):p)+gi,kind:"flowchart",nodes:c,width:g+gi}}(e):function(e){const t=[];let n=gi;for(const m of e.participants){const e=fi(m.label,96);t.push({actor:m.actor,centerX:n+e/2,headHeight:36,headWidth:e,id:m.id,label:m.label}),n+=e+hi}const a=e=>t.find(t=>t.id===e)?.centerX??null,o=[],i=[],r=[],s=/* @__PURE__ */new Map;let l=100;const c=(e,t)=>{const n=s.get(e),o=a(e);void 0!==n&&null!==o&&(r.push({height:Math.max(t-n,24),width:10,x:o-5,y:n}),s.delete(e))};for(const m of e.steps){if("activation"===m.kind){m.active?s.set(m.participant,l):c(m.participant,l);continue}if("note"===m.kind){const e=m.targets.map(a).filter(e=>null!==e);if(0===e.length)continue;const t=fi(m.text,96),n=Math.min(...e),o=Math.max(...e),r="left"===m.placement?n-t-hi:"right"===m.placement?o+hi:(n+o)/2-t/2;i.push({height:34,text:m.text,width:t,x:r,y:l}),l+=62;continue}const e=a(m.from),t=a(m.to);null!==e&&null!==t&&(m.activate&&s.set(m.to,l),o.push({end:m.end,fromX:e,line:m.line,selfCall:m.from===m.to,text:m.text,toX:t,y:l}),l+=48,m.deactivate&&c(m.to,l))}const d=l;for(const m of[...s.keys()])c(m,d);const p=Math.max(...i.map(e=>e.x+e.width),0),u=Math.max(n-hi+gi,p+gi);return{activations:r,height:d+gi,kind:"sequence",lifelineBottom:d,lifelines:t,messages:o,notes:i,width:u}}(e)}function fi(e,t){return Math.max(t,Math.round(7.2*e.length)+32)}var yi=["BT","LR","RL","TB","TD"],vi=["subgraph","end","click","style","classDef","class","linkStyle","direction"],xi=["loop","alt","else","opt","par","and","critical","option","break","rect","box","autonumber","end"],ki=[{arrow:!0,line:"dotted",token:"-.->"},{arrow:!0,line:"thick",token:"==>"},{arrow:!0,line:"solid",token:"--\x3e"},{arrow:!1,line:"thick",token:"==="},{arrow:!1,line:"solid",token:"---"},{arrow:!1,line:"dotted",token:"-.-"}],wi=[{end:"arrow",line:"dotted",token:"--\x3e>"},{end:"arrow",line:"solid",token:"->>"},{end:"cross",line:"dotted",token:"--x"},{end:"cross",line:"solid",token:"-x"},{end:"none",line:"dotted",token:"--\x3e"},{end:"none",line:"solid",token:"->"}],Ci=[{close:"]]",open:"[[",shape:"subroutine"},{close:"])",open:"([",shape:"stadium"},{close:"))",open:"((",shape:"circle"},{close:"]",open:"[",shape:"rect"},{close:"}",open:"{",shape:"rhombus"},{close:")",open:"(",shape:"round"}],Si=e=>({ok:!1,reason:e});function Ai(e){return e.split(/[\s(]/,1)[0]??""}function Ei(e){const t=function(e){return e.split("\n").map(e=>function(e){const t=e.indexOf("%%");return-1===t?e:e.slice(0,t)}(e).trim()).filter(e=>e.length>0)}(e);if(0===t.length)return Si("the block is empty");const[n,...a]=t,o=Ai(n??"");return"sequenceDiagram"===o?function(e){const t=/* @__PURE__ */new Map,n=[],a=e=>(t.has(e)||t.set(e,{actor:!1,id:e,label:e}),e);for(const o of e){const e=Ai(o);if(xi.includes(e))return Si(`"${e}" is not supported yet`);if("participant"===e||"actor"===e){const n=Ti(o,e);if(null===n)return Si(`"${o}" is not a participant declaration this engine understands`);t.set(n.id,n);continue}if("activate"===e||"deactivate"===e){const t=o.slice(e.length).trim();if(!Ii(t))return Si(`"${o}" does not name a participant to ${e}`);n.push({active:"activate"===e,kind:"activation",participant:a(t)});continue}if("Note"===e||"note"===e){const e=Mi(o);if(null===e)return Si(`"${o}" is not a note this engine understands`);for(const t of e.targets)a(t);n.push(e);continue}const i=_i(o);if(null===i)return Si(`"${o}" is not a message this engine understands`);a(i.from),a(i.to),n.push(i)}return{model:{kind:"sequence",participants:[...t.values()],steps:n},ok:!0}}(a):"flowchart"===o||"graph"===o?function(e,t){const n=e.slice(Ai(e).length).trim();if(0===n.length)return Si('the flowchart header is missing a direction, e.g. "flowchart TD"');const a=yi.find(e=>e===n);if(void 0===a)return Si(`"${n}" is not a supported direction — use TD, TB, BT, LR or RL`);const o=/* @__PURE__ */new Map,i=[];for(const r of t){const e=Ai(r);if(vi.includes(e))return Si(`"${e}" is not supported yet`);if(r.includes("&"))return Si('"&" fan-out is not supported yet');const t=Ni(r,o,i);if(null!==t)return Si(t)}return{model:{direction:a,edges:i,kind:"flowchart",nodes:[...o.values()]},ok:!0}}(n??"",a):Si(`"${o}" diagrams are not supported yet — only flowchart and sequenceDiagram are`)}function Ni(e,t,n){const a=function(e){const t=[],n=[];let a=e.trim();for(let o=0;o<64;o+=1){const e=Li(a);if(null===e)return t.push(a.trim()),t.every(e=>e.length>0)?{links:n,terms:t}:null;t.push(a.slice(0,e.at).trim()),n.push({arrow:e.arrow,label:e.label,line:e.line}),a=a.slice(e.at+e.length)}return null}(e);if(null===a)return`"${e}" is not a node or edge this engine understands`;const o=[];for(const i of a.terms){const e=$i(i);if(null===e)return`"${i}" is not a node declaration this engine understands`;t.has(e.id)||t.set(e.id,e),o.push(e)}for(const[i,r]of a.links.entries()){const t=o[i],a=o[i+1];if(void 0===t||void 0===a)return`"${e}" has a link with nothing on one side of it`;n.push({arrow:r.arrow,from:t.id,label:r.label,line:r.line,to:a.id})}return null}function Li(e){const t=function(e){const t=/--\s+([^->|][^-]*?)\s+(-->|---|-\.->|-\.-|==>|===)/.exec(e);if(null===t||void 0===t.index)return null;const n=ki.find(e=>e.token===t[2]);return void 0===n?null:{arrow:n.arrow,at:t.index,label:(t[1]??"").trim(),length:t[0].length,line:n.line}}(e);if(null!==t)return t;let n=null;for(const a of ki){const t=e.indexOf(a.token);if(-1===t)continue;if(null!==n&&t>=n.at)continue;const o=Bi(e,t+a.token.length);n={arrow:a.arrow,at:t,label:o.label,length:a.token.length+o.consumed,line:a.line}}return n}function Bi(e,t){if("|"!==e[t])return{consumed:0,label:null};const n=e.indexOf("|",t+1);return-1===n?{consumed:0,label:null}:{consumed:n-t+1,label:e.slice(t+1,n).trim()}}function $i(e){const t=e.trim();if(0===t.length)return null;for(const n of Ci){const e=t.indexOf(n.open);if(e<=0||!t.endsWith(n.close))continue;const a=t.slice(0,e).trim(),o=t.slice(e+n.open.length,t.length-n.close.length);if(Ii(a))return{id:a,label:o.trim(),shape:n.shape}}return Ii(t)?{id:t,label:t,shape:"rect"}:null}function Ii(e){return/^[A-Za-z_][\w-]*$/.test(e)}function Ti(e,t){const n=e.slice(t.length).trim(),a=/ as /.exec(n),o=(null===a?n:n.slice(0,a.index)).trim();if(!Ii(o))return null;const i=null===a?o:n.slice(a.index+a[0].length).trim();return{actor:"actor"===t,id:o,label:0===i.length?o:i}}function Mi(e){const t=e.slice(Ai(e).length).trim(),n=t.indexOf(":");if(-1===n)return null;const a=t.slice(0,n).trim(),o=t.slice(n+1).trim(),i=/^over\s+(.+)$/i.exec(a);if(null!==i){const e=(i[1]??"").split(",").map(e=>e.trim());return e.every(Ii)?{kind:"note",placement:"over",targets:e,text:o}:null}const r=/^(left|right)\s+of\s+(.+)$/i.exec(a);if(null===r)return null;const s=(r[2]??"").trim();return Ii(s)?{kind:"note",placement:(r[1]??"").toLowerCase(),targets:[s],text:o}:null}function _i(e){const t=e.indexOf(":");if(-1===t)return null;const n=e.slice(0,t),a=e.slice(t+1).trim();for(const o of wi){const e=n.indexOf(o.token);if(-1===e)continue;const t=n.slice(0,e).trim(),i=n.slice(e+o.token.length).trim(),r=i.startsWith("+")||i.startsWith("-")?i[0]:null,s=null===r?i:i.slice(1).trim();if(Ii(t)&&Ii(s))return{activate:"+"===r,deactivate:"-"===r,end:o.end,from:t,kind:"message",line:o.line,text:a,to:s}}return null}var Di={dotted:"5 4",solid:"",thick:""},qi={dotted:1.5,solid:1.5,thick:3};function ji(e,t,n){const a=n.createNS("http://www.w3.org/2000/svg",e);for(const[o,i]of Object.entries(t))a.setAttribute(o,String(i));return a}function zi(e,t,n,a,o){const i=ji("text",{class:a,"dominant-baseline":"middle","text-anchor":"middle",x:t,y:n},o);return i.setText(e),i}function Hi(e,t=T){const n=ji("svg",{class:"clepit-typeset__diagram",height:e.height,role:"img",viewBox:`0 0 ${e.width} ${e.height}`,width:e.width},t);return n.append(function(e){const t=ji("defs",{},e),n=ji("marker",{id:"clepit-mermaid-arrow",markerHeight:7,markerUnits:"strokeWidth",markerWidth:7,orient:"auto-start-reverse",refX:7,refY:3.5},e);return n.append(ji("path",{class:"clepit-typeset__arrowhead",d:"M 0 0 L 7 3.5 L 0 7 z"},e)),t.append(n),t}(t)),"flowchart"===e.kind?function(e,t,n){for(const a of t.edges)Pi(e,a,n);for(const a of t.nodes)Oi(e,a,n)}(n,e,t):function(e,t,n){for(const a of t.lifelines){e.append(ji("line",{class:"clepit-typeset__lifeline",x1:a.centerX,x2:a.centerX,y1:a.headHeight+16,y2:t.lifelineBottom},n));const o={class:a.actor?"clepit-typeset__node clepit-typeset__actor":"clepit-typeset__node",height:a.headHeight,rx:a.actor?a.headHeight/2:4,ry:a.actor?a.headHeight/2:4,width:a.headWidth,x:a.centerX-a.headWidth/2,y:16};e.append(ji("rect",o,n)),e.append(zi(a.label,a.centerX,16+a.headHeight/2,"clepit-typeset__label",n))}for(const a of t.activations)e.append(ji("rect",{class:"clepit-typeset__activation",height:a.height,width:a.width,x:a.x,y:a.y},n));for(const a of t.messages)Ri(e,a,n);for(const a of t.notes)e.append(ji("rect",{class:"clepit-typeset__note",height:a.height,width:a.width,x:a.x,y:a.y},n)),e.append(zi(a.text,a.x+a.width/2,a.y+a.height/2,"clepit-typeset__label",n))}(n,e,t),n}function Oi(e,t,n){e.append(function(e,t){const{height:n,shape:a,width:o,x:i,y:r}=e,s={class:"clepit-typeset__node"};if("circle"===a)return ji("ellipse",{...s,cx:i+o/2,cy:r+n/2,rx:o/2,ry:n/2},t);if("rhombus"===a){const e=`${i+o/2},${r} ${i+o},${r+n/2} ${i+o/2},${r+n} ${i},${r+n/2}`;return ji("polygon",{...s,points:e},t)}if("stadium"===a)return ji("rect",{...s,height:n,rx:n/2,ry:n/2,width:o,x:i,y:r},t);if("round"===a)return ji("rect",{...s,height:n,rx:10,ry:10,width:o,x:i,y:r},t);if("subroutine"===a){const e=ji("g",{},t);return e.append(ji("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)),e.append(ji("line",{...s,x1:i+6,x2:i+6,y1:r,y2:r+n},t)),e.append(ji("line",{...s,x1:i+o-6,x2:i+o-6,y1:r,y2:r+n},t)),e}return ji("rect",{...s,height:n,rx:8,ry:8,width:o,x:i,y:r},t)}(t,n)),e.append(zi(t.label,t.x+t.width/2,t.y+t.height/2,"clepit-typeset__label",n))}function Pi(e,t,n){const[a,o]=t.points;if(void 0===a||void 0===o)return;const i=t.points.length>2?ji("polyline",{class:"clepit-typeset__edge",fill:"none",points:t.points.map(e=>`${e.x},${e.y}`).join(" "),"stroke-dasharray":Di[t.line],"stroke-width":qi[t.line]},n):ji("line",{class:"clepit-typeset__edge","stroke-dasharray":Di[t.line],"stroke-width":qi[t.line],x1:a.x,x2:o.x,y1:a.y,y2:o.y},n);if(t.arrow&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),null!==t.label){const a=zi(t.label,t.labelX,t.labelY,"clepit-typeset__edge-label",n);a.setAttribute("paint-order","stroke"),e.append(a)}}function Ri(e,t,n){const a={class:"clepit-typeset__message","stroke-dasharray":Di[t.line],"stroke-width":qi[t.line]};if(t.selfCall){const o=`M ${t.fromX} ${t.y} h 28 v 18 h -28`,i=ji("path",{...a,d:o,fill:"none"},n);return"arrow"===t.end&&i.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(i),void e.append(zi(t.text,t.fromX+52,t.y+9,"clepit-typeset__edge-label",n))}const o=ji("line",{...a,x1:t.fromX,x2:t.toX,y1:t.y,y2:t.y},n);if("arrow"===t.end&&o.setAttribute("marker-end","url(#clepit-mermaid-arrow)"),e.append(o),"cross"===t.end){const o=t.toX+(t.toX>t.fromX?-5:5);e.append(ji("line",{...a,x1:o-5,x2:o+5,y1:t.y-5,y2:t.y+5},n)),e.append(ji("line",{...a,x1:o-5,x2:o+5,y1:t.y+5,y2:t.y-5},n))}e.append(zi(t.text,(t.fromX+t.toX)/2,t.y-8,"clepit-typeset__edge-label",n))}var Fi=class e{static render(t,n,a,o,i){if(N.injectStyles("typeset-output",Bo),!e.validate(n))return V();const r=N.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--${t.toLowerCase()}`,{classNames:i?.wrapper,styles:o?.wrapper});if(r.setAttribute("data-language",t.toLowerCase()),n.title){const e=document.createElement("span");e.className="clepit-typeset__title",e.textContent=n.title,e.setAttribute("data-testid","typeset-title"),r.appendChild(e)}if("Mermaid"===t){const a=Ei(n.source);return a.ok?(r.setAttribute("data-rendered","diagram"),r.appendChild(H(Hi(bi(a.model)))),r):e.appendFallback(r,n.source,a.reason,t)}if(0===n.source.trim().length)return e.appendFallback(r,n.source,null,t);const s=Yo(n.source);return s.ok?(r.setAttribute("data-rendered","formula"),r.appendChild(H(di(Mo(s.root)))),r):e.appendFallback(r,n.source,s.reason,t)}static appendFallback(e,t,n,a){e.setAttribute("data-rendered","source");const o=document.createElement("span");if(o.className="clepit-typeset__kind",o.textContent=a,e.prepend(o),null!==n){const t=document.createElement("span");t.className="clepit-typeset__fallback-reason",t.textContent=n,e.appendChild(t)}const i=document.createElement("pre");return i.className="clepit-typeset__source",i.textContent=t,e.appendChild(i),e}static draw(t,n,a=T){if(!e.validate(n))return null;const o=a.create("div");o.addClass("clepit-typeset","clepit-output-typeset",`clepit-typeset--${t.toLowerCase()}`),o.setAttribute("data-language",t.toLowerCase());const i=()=>{if(!n.title)return;const e=a.create("span");e.addClass("clepit-typeset__title"),e.setText(n.title),e.setAttribute("data-testid","typeset-title"),o.append(e)};if("Mermaid"===t){const r=Ei(n.source);return r.ok?(o.setAttribute("data-rendered","diagram"),i(),o.append(Hi(bi(r.model),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}if(0===n.source.trim().length)return e.drawFallback(o,n,null,t,a,i);const r=Yo(n.source);return r.ok?(o.setAttribute("data-rendered","formula"),i(),o.append(di(Mo(r.root),a)),o):e.drawFallback(o,n,r.reason,t,a,i)}static drawFallback(e,t,n,a,o,i){e.setAttribute("data-rendered","source");const r=o.create("span");if(r.addClass("clepit-typeset__kind"),r.setText(a),e.append(r),i(),null!==n){const t=o.create("span");t.addClass("clepit-typeset__fallback-reason"),t.setText(n),e.append(t)}const s=o.create("pre");return s.addClass("clepit-typeset__source"),s.setText(t.source),e.append(s),e}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.source&&(void 0===e.title||"string"==typeof e.title)}},Ui=class{static render(e,t,n,a){return Fi.render("LaTeX",e,t,n,a)}static draw(e,t=T){return Fi.draw("LaTeX",e,t)}},Vi=class{static render(e,t,n,a){return Fi.render("Mermaid",e,t,n,a)}static draw(e,t=T){return Fi.draw("Mermaid",e,t)}},Wi="\n.clepit-updates {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 12px;\n border: 1px solid rgba(127, 127, 127, 0.35);\n border-radius: 8px;\n color: inherit;\n}\n.clepit-updates__icon {\n font-size: 18px;\n line-height: 1;\n}\n.clepit-updates__label {\n opacity: 0.7;\n}\n",Ki=Wi,Gi=Wi,Ji=class{static render(e,t,n,a){N.injectStyles("updates-output",Gi);const o=N.createStyledElement("div","clepit-updates clepit-output-updates",{classNames:a?.wrapper,styles:n?.wrapper});e?.pageId&&o.setAttribute("data-page-id",e.pageId);const i=document.createElement("span");i.className="clepit-updates__icon",i.textContent="🕘",o.appendChild(i);const r=document.createElement("span");return r.className="clepit-updates__label",r.textContent="Updates",o.appendChild(r),o}static draw(e,t=T){if(null==e||"object"!=typeof e)return null;const n=t.create("div");n.addClass("clepit-updates","clepit-output-updates"),e.pageId&&n.setAttribute("data-page-id",e.pageId);const a=t.create("span");a.addClass("clepit-updates__icon"),a.setText("🕘"),n.append(a);const o=t.create("span");return o.addClass("clepit-updates__label"),o.setText("Updates"),n.append(o),n}},Xi=`\n/* Video block styles */\n.clepit-video-container {\n margin: 16px 0;\n text-align: center;\n min-height: 120px;\n position: relative;\n display: block;\n width: 100%;\n box-sizing: border-box;\n}\n\n.clepit-video-wrapper {\n display: flex;\n position: relative;\n cursor: pointer;\n transition: opacity 0.2s ease;\n outline: none;\n}\n\n.clepit-video-wrapper:hover {\n opacity: 0.9;\n}\n\n.clepit-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n display: block;\n}\n\n.clepit-video-wrapper--left {\n justify-content: flex-start;\n}\n\n.clepit-video-wrapper--center {\n justify-content: center;\n}\n\n.clepit-video-wrapper--right {\n justify-content: flex-end;\n}\n\n.clepit-video-caption-container {\n margin-top: 12px;\n text-align: center;\n}\n\n.clepit-video-caption-label {\n font-size: 12px;\n color: var(--clepit-text-muted);\n margin-bottom: 4px;\n font-weight: 500;\n}\n\n.clepit-video-caption-input {\n width: 100%;\n max-width: 400px;\n padding: 8px 12px;\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n font-size: 14px;\n background: var(--clepit-bg);\n outline: none;\n transition: border-color 0.2s ease;\n pointer-events: auto;\n user-select: text;\n}\n\n.clepit-video-caption-input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n/* Video caption styling */\n.clepit-video-caption-editable {\n border: 1px solid var(--clepit-border-subtle);\n border-radius: 4px;\n padding: 8px 12px;\n min-height: 40px;\n font-size: 14px;\n line-height: 1.4;\n outline: none;\n transition: border-color 0.2s ease;\n}\n\n/* Video caption placeholder styles */\n.clepit-video-caption-editable[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Video Drop Area */\n.clepit-video-drop-area {\n border: 2px dashed var(--clepit-border);\n border-radius: 8px;\n padding: 40px 20px;\n text-align: center;\n background: var(--clepit-surface);\n cursor: pointer;\n transition: all 0.2s ease;\n margin: 16px 0;\n user-select: none;\n pointer-events: auto;\n outline: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n position: relative;\n}\n\n.clepit-video-drop-area:hover {\n border-color: var(--clepit-primary);\n background: var(--clepit-surface);\n}\n\n.clepit-video-drop-area--dragover {\n border-color: var(--clepit-primary);\n background: var(--clepit-primary-bg);\n transform: scale(1.02);\n}\n\n.clepit-video-drop-icon {\n font-size: 48px;\n margin-bottom: 16px;\n opacity: 0.6;\n}\n\n.clepit-video-drop-text {\n font-size: 16px;\n color: var(--clepit-text-muted);\n line-height: 1.5;\n}\n\n.clepit-video-click-text {\n color: var(--clepit-primary);\n text-decoration: none;\n cursor: pointer;\n}\n\n/* Video Loading State */\n.clepit-video-loading {\n text-align: center;\n padding: 40px 20px;\n margin: 16px 0;\n}\n\n.clepit-video-loading-spinner {\n width: 32px;\n height: 32px;\n border: 3px solid var(--clepit-surface);\n border-top: 3px solid var(--clepit-primary);\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 16px;\n}\n\n@keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n.clepit-video-loading-text {\n font-size: 14px;\n color: var(--clepit-text-muted);\n}\n\n/* Video Error State */\n.clepit-video-error {\n text-align: center;\n padding: 20px;\n margin: 16px 0;\n border: 1px solid var(--clepit-error);\n border-radius: 8px;\n background: var(--clepit-error-bg);\n}\n\n.clepit-video-error-icon {\n font-size: 24px;\n margin-bottom: 8px;\n}\n\n.clepit-video-error-text {\n font-size: 14px;\n color: var(--clepit-error);\n margin-bottom: 12px;\n}\n\n.clepit-video-error-retry {\n background: var(--clepit-error);\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n transition: background-color 0.2s ease;\n}\n\n.clepit-video-error-retry:hover {\n background: var(--clepit-error);\n}\n\n/* Video caption placeholder */\n.clepit-video-caption-placeholder {\n color: var(--clepit-text-subtle);\n}\n\n/* Video delete button */\n.${N.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.${N.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Video drop area delete button */\n.clepit-video-drop-area .${N.classNames.block.videoDeleteBtn} {\n position: absolute;\n top: 8px;\n right: 8px;\n border: 1px solid var(--clepit-border);\n border-radius: 50%;\n width: 24px;\n height: 24px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: var(--clepit-bg);\n cursor: pointer;\n color: var(--clepit-text-muted);\n transition: color 0.2s ease;\n}\n\n.clepit-video-drop-area .${N.classNames.block.videoDeleteBtn}:hover {\n color: var(--clepit-error);\n}\n\n/* Drop area positioning */\n.clepit-drop-area {\n position: relative;\n}\n\n/* Hidden input */\n.clepit-hidden-input {\n display: none;\n}\n\n`,Zi="\n/* Output video styles */\n.clepit-output-video-container {\n margin: 1rem 0;\n text-align: center;\n}\n\n.clepit-output-video {\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}\n\n.clepit-output-video-caption {\n margin-top: 0.5rem;\n font-size: 0.875rem;\n color: var(--clepit-text-muted);\n font-style: italic;\n text-align: center;\n}\n\n/* Output video alignment */\n.clepit-output-video-wr--left {\n justify-content: flex-start;\n}\n\n.clepit-output-video-wr--center {\n justify-content: center;\n}\n\n.clepit-output-video-wr--right {\n justify-content: flex-end;\n}\n",Yi=class e{static{this.placeholder="Add a caption..."}static{this.eventListenersMap={}}static{this.validTypes=["video/mp4","video/webm","video/ogg","video/ogv"]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.querySelector("video"),n=e.querySelector("iframe"),a=e.querySelector(`.${N.classNames.block.video.captionEditable}`),o=e.querySelector(`.${N.classNames.block.video.wrapper}`);let i="center";o&&(i=o.classList.contains("clepit-video-wrapper--left")?"left":o.classList.contains("clepit-video-wrapper--right")?"right":"center");let r="",s="";return t?(r=t.getAttribute("src")||"",s=t.getAttribute("alt")||""):n&&(r=n.getAttribute("src")||"",s="Embedded video"),{alignment:i,alt:s,caption:F(a?.innerHTML),url:r}}static render(t,n,a,o){N.injectStyles("clepit-video-input-styles",Xi);const i=a||{alt:"",caption:"",url:""},r=N.createStyledElement("div",N.classNames.block.video.container,{classNames:o?.classNames?.container,styles:o?.styles?.container});return i.url?e.renderVideo(r,i,t,n,o):e.renderDropArea(r,t,n,o),r}static renderVideo(t,n,a,o,i){t.innerHTML="";const r=N.createStyledElement("div",N.classNames.block.video.wrapper,{classNames:i?.classNames?.container,styles:i?.styles?.container});switch(r.setAttribute("tabindex","-1"),n?.alignment||"center"){case"left":r.classList.add("clepit-video-wrapper--left");break;case"center":r.classList.add("clepit-video-wrapper--center");break;case"right":r.classList.add("clepit-video-wrapper--right")}const s=lt(n?.url||""),l=ct(n?.url||"");if(s||l){const e=N.createStyledElement("iframe",N.classNames.block.video.iframe,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.src=n?.url||"",e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",r.appendChild(e)}else{const e=N.createStyledElement("video",N.classNames.block.video.video,{classNames:i?.classNames?.container,styles:i?.styles?.container});e.setAttribute("alt",n?.alt||""),e.src=n?.url||"",e.controls=!0,r.appendChild(e)}const c=N.createStyledElement("div","clepit-video-caption-container",{classNames:i?.classNames?.caption,styles:i?.styles?.caption});c.classList.add("clepit-video-caption-container");const d=N.createStyledElement("div",N.classNames.block.video.captionEditable,{classNames:i?.classNames?.caption,styles:i?.styles?.caption});d.setAttribute("contenteditable","true"),d.setAttribute("data-placeholder",Y(o,"mediaCaptionHint",e.placeholder)),d.innerHTML=n?.caption||"",e.addEventListener(o,d,"input",ss.handleInput),e.addEventListener(o,d,"keydown",ss.handleKeydown),e.addEventListener(o,r,"click",()=>e.handleFileSelect(t,a,o,i)),c.appendChild(d),t.appendChild(r),t.appendChild(c),d.focus()}static renderDropArea(t,n,a,o){t.innerHTML="";const i=N.createStyledElement("div",N.classNames.block.video.dropArea,{classNames:o?.classNames?.dropArea?.container,styles:o?.styles?.dropArea?.container});i.setAttribute("tabindex","0"),i.classList.add("clepit-drop-area");const r=N.createStyledElement("div","clepit-video-drop-icon",{classNames:o?.classNames?.dropArea?.icon,styles:o?.styles?.dropArea?.icon});r.textContent="🎥";const s=N.createStyledElement("div","clepit-video-drop-text",{classNames:o?.classNames?.dropArea?.text,styles:o?.styles?.dropArea?.text});s.innerHTML='<strong>Drop a video here</strong><br>or <span class="clepit-video-click-text">click to select</span>';const l=N.createStyledElement("button",`${N.classNames.block.videoDeleteBtn}`,{classNames:o?.classNames?.dropArea?.deleteButton,styles:o?.styles?.dropArea?.deleteButton});l.type="button",l.textContent="✕",i.appendChild(r),i.appendChild(s),i.appendChild(l),e.addEventListener(a,l,"click",e=>{e.preventDefault(),e.stopPropagation();const t=l.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");t&&ss.removeBlock(a,ss.getBlockIndex(a,t))}),e.addEventListener(a,i,"click",()=>e.handleFileSelect(t,n,a,o)),e.addEventListener(a,i,"dragleave",()=>{i.classList.remove("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"dragover",e=>{e.preventDefault(),e.stopPropagation(),i.classList.add("clepit-video-drop-area--dragover")}),e.addEventListener(a,i,"drop",r=>{r.preventDefault(),r.stopPropagation(),i.classList.remove("clepit-video-drop-area--dragover"),e.handleFileDrop(r,t,n,a,o)}),e.addEventListener(a,i,"focus",e=>{e.preventDefault(),e.stopPropagation()}),e.addEventListener(a,i,"mousedown",e=>{e.preventDefault(),e.stopPropagation()});const d=a?c.getState().getInstance(a):null,p=d?.config.classNames?.tooltips,u=d?.config.styles?.tooltips;me(l,"Delete block","below",p,u),t.appendChild(i)}static handleFileDrop(t,n,a,o,i){const r=t.dataTransfer?.files;if(r&&r.length>0){const t=r[0];e.isValidVideoFile(t)?e.processVideoFile(t,n,a,o,i):e.showError(n,"Please select a valid video file (MP4, WebM, OGV)")}}static handleFileSelect(t,n,a,o){const i=document.createElement("input");i.type="file",i.accept="video/*",i.style.display="none",i.addEventListener("change",()=>{const r=i.files;if(r&&r.length>0){const i=r[0];e.isValidVideoFile(i)?e.processVideoFile(i,t,n,a,o):e.showError(t,"Please select a valid video file (MP4, WebM, OGV)")}}),document.body.appendChild(i),i.click(),document.body.removeChild(i)}static isValidVideoFile(t){return e.validTypes.includes(t.type)||t.type.startsWith("video/")}static async processVideoFile(t,n,a,o,i){e.showLoading(n);try{let r=await a(t);if(r){e.renderVideo(n,{alignment:"center",alt:t.name,caption:"",url:r},a,o,i);const s=n.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id");s&&c.getState().updateBlockData(o,ss.getBlockIndex(o,s),ss.getBlockData(s).data)}else e.showError(n,"Failed to upload video. Please try again.")}catch(r){console.error("Video upload error:",r),e.showError(n,"Failed to upload video. Please try again.")}}static showLoading(e){e.innerHTML="";const t=N.createStyledElement("div","clepit-video-loading",void 0);t.textContent="Uploading video...",e.appendChild(t)}static showError(e,t){e.innerHTML="";const n=N.createStyledElement("div","clepit-video-error",void 0);n.textContent=t,e.appendChild(n)}static setAlignment(e,t){const n=e.querySelector(".clepit-video-wrapper");n&&(n.classList.remove("clepit-video-wrapper--left","clepit-video-wrapper--center","clepit-video-wrapper--right"),n.classList.add(`clepit-video-wrapper--${t}`));const a=ss.getEditorId(e);if(!a)return;const o=e.getAttribute("data-id");o&&c.getState().partialUpdateBlockData(a,ss.getBlockIndex(a,o),{alignment:t})}static isEmpty(e){const t=e.querySelector(`.${N.classNames.block.video.wrapper} video`),n=e.querySelector(`.${N.classNames.block.video.wrapper} iframe`),a=e.querySelector(`.${N.classNames.block.video.captionEditable}`);let o=!1,i=!1,r=!1;return t&&t.getAttribute("src")?.trim()||(o=!0),n&&n.getAttribute("src")?.trim()||(i=!0),a?R(a.innerHTML)&&(r=!0):r=!0,o&&i&&r}static isEmptyData(e){return!e.url?.trim()&&R(e.caption)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Qi=class e{static render(t,n,a,o){if(N.injectStyles("clepit-video-output-styles",Zi),!e.validate(t))return V();if(Yi.isEmptyData(t))return document.createElement("div");const i=t.url,r=t.caption,s=t.alignment||"center",l=N.createStyledElement("div","clepit-output-video-container",{classNames:o?.container,styles:a?.container}),c=N.createStyledElement("div","clepit-output-video-wrapper");switch(s){case"left":c.classList.add("clepit-output-video-wrapper--left");break;case"center":c.classList.add("clepit-output-video-wrapper--center");break;case"right":c.classList.add("clepit-output-video-wrapper--right")}const d=lt(i),p=ct(i);if(d||p){const e=O("iframe","clepit-output-video-iframe");e.src=i,e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","true"),e.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"),e.style.maxWidth="100%",e.style.width="560px",e.style.height="315px",e.style.display="block",e.style.borderRadius="8px",c.appendChild(e),l.appendChild(c)}else{const e=O("video","clepit-output-video");e.src=i,e.controls=!0,e.preload="metadata",e.style.maxWidth="100%",e.style.height="auto",e.style.display="block",c.appendChild(e),l.appendChild(c)}if(r){const e=N.createStyledElement("figcaption","clepit-output-video-caption",{classNames:o?.caption,styles:a?.caption}),n=t.caption;e.innerHTML=n&&n!==r?n:r,l.appendChild(e)}if(a&&(a.container&&Object.assign(l.style,a.container),a.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&Object.assign(e.style,a.caption)}if(o&&(o.container&&l.classList.add(o.container),o.caption)){const e=l.querySelector(".clepit-output-video-caption");e&&e.classList.add(o.caption)}return l}static draw(t,n=T){if(!e.validate(t)||Yi.isEmptyData(t))return null;const a=n.create("div");a.addClass("clepit-output-video-container");const o=n.create("div");o.addClass("clepit-output-video-wrapper");const i=t.alignment??"center";i&&o.addClass(`clepit-output-video-wrapper--${i}`);const r=n.create("video");if(r.addClass("clepit-output-video"),r.setAttribute("src",t.url),r.setAttribute("controls","controls"),o.append(r),a.append(o),t.caption){const e=n.create("figcaption");e.addClass("clepit-output-video-caption"),e.setHtml(t.caption),a.append(e)}return a}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"string"==typeof e.url}},er=(e,t,n)=>{const a=tr(e,t,n);return a&&(a.setAttribute("data-block-type",e.type),e.id&&(a.setAttribute("data-clepit-block-id",e.id),n?.anchorTargets&&a.setAttribute("id",e.id))),a},tr=(e,t,n)=>{switch(e.type){case"alert":return bn.draw(e.data,t);case"audio":return kn.draw(e.data,t);case"checklist":return En.draw(e.data,t);case"code":return be.draw(e.data,t,n);case"collapsible":return ar.draw(e.data,t,n);case"collection":return jn.draw(e.data,t);case"columns":return Pn.draw(e.data,t,n);case"date":return Kn.draw(e.data,t);case"delimiter":return Xn.draw(e.data,t);case"doc_card":return ea.draw(e.data,t,n);case"embed":return Xe.draw(e.data,t,n);case"file":return ia.draw(e.data,t);case"glance":return la.draw(e.data,t);case"header":return pa.draw(e.data,t);case"image":return ba.draw(e.data,t);case"issues":return xa.draw(e.data,t,n);case"latex":return Ui.draw(e.data,t);case"list":return Ca.draw(e.data,t);case"mermaid":return Vi.draw(e.data,t);case"openapi":return Qa.draw(e.data,t);case"paragraph":return no.draw(e.data,t);case"quote":return ro.draw(e.data,t);case"sketch":return ho.draw(e.data,t);case"table":return ko.draw(e.data,t);case"toc":return Eo.draw(e.data,t,n);case"updates":return Ji.draw(e.data,t);case"video":return Qi.draw(e.data,t);default:return nr(e)}},nr=e=>(console.warn("drawBlock: no drawer for block",e),null),ar=class e{static render(t,n,a,o){if(N.injectStyles("collapsible-output",In),!e.validate(t))return V();const i=N.createStyledElement("details","clepit-collapsible clepit-output-collapsible",{classNames:o?.section,styles:a?.section});i.open=t.open??!1;const r=document.createElement("summary"),s=document.createElement("span");s.innerHTML=F(t.html),r.appendChild(s),i.appendChild(r);const l=document.createElement("div");l.className="clepit-collapsible__children";for(const c of t.children??[])l.appendChild(e.renderChild(c,n));return i.appendChild(l),i}static renderChild(e,t){const n=Zr.find(t=>t.type===e.type);if(!n){const t=document.createElement("div");return t.className="clepit-collapsible__unknown-child",t.textContent=`Unsupported block: ${e.type}`,t}return n.output.render(e.data,t)}static draw(t,n=T,a){if(!e.validate(t))return null;const o=n.create("details");o.addClass("clepit-collapsible","clepit-output-collapsible"),t.open&&o.setAttribute("open","");const i=n.create("summary"),r=n.create("span");r.setHtml(t.html),i.append(r),o.append(i);const s=n.create("div");s.addClass("clepit-collapsible__children");for(const e of t.children??[]){const t=er(e,n,a);t&&s.append(t)}return o.append(s),o}static validate(e){return void 0!==e&&"object"==typeof e&&null!==e&&"html"in e&&"string"==typeof e.html&&(void 0===e.children||Array.isArray(e.children))}},or={icon:"▸",get input(){return Mn},label:"Collapsible section",get output(){return ar},shortcut:Ct("E"),testId:"block-type-collapsible",type:"collapsible"},ir=/* @__PURE__ */new WeakMap,rr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-collection")?e:e.querySelector(".clepit-collection");if(t){const e=ir.get(t);if(e)return e;const n=t.getAttribute("data-collection-id");if(n)return{collectionId:n}}return{collectionId:""}}static render(e,t,n){N.injectStyles("collection-input",Dn);const a=t??{collectionId:""},o=jn.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-collection--input"),o.setAttribute("contenteditable","false"),ir.set(o,a),o}static isEmpty(t){return""===e.save(t).collectionId}static isEmptyData(e){return!e.collectionId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},sr={icon:"▦",get input(){return rr},label:"Collection",get output(){return jn},shortcut:Ct("G"),testId:"block-type-collection",type:"collection"},lr=/* @__PURE__ */new WeakMap;var cr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-columns")?e:e.querySelector(".clepit-columns");if(!t)return{columns:[[],[]]};const n=lr.get(t)??[],a=[];return t.querySelectorAll(":scope > .clepit-columns__column").forEach((e,t)=>{const o=n[t]??[],i=[];e.querySelectorAll(":scope > .clepit-columns__child").forEach((e,t)=>{const n=o[t],a=e.getAttribute("data-child-type")??n?.type,r=a?function(e){return Zr.find(t=>t.type===e)}(a):void 0;if(r){const t=r.input.save(e);i.push({...n?.id?{id:n.id}:{},data:t,type:r.type})}else n&&i.push(n)}),a.push(i)}),{columns:a.length>=2?a:[[],[]]}}static render(t,n,a){N.injectStyles("columns-input",Hn);const o=n&&Array.isArray(n.columns)&&n.columns.length>=2?n:{columns:[[],[]]},i=N.createStyledElement("div","clepit-columns clepit-columns--input",{classNames:a?.classNames?.container,styles:a?.styles?.container});return lr.set(i,o.columns.map(e=>[...e])),o.columns.forEach(n=>{const o=N.createStyledElement("div","clepit-columns__column",{classNames:a?.classNames?.column,styles:a?.styles?.column});n.forEach(n=>{o.appendChild(e.renderChild(t,n))}),i.appendChild(o)}),i}static renderChild(e,t){const n=document.createElement("div");n.className="clepit-columns__child";const a=ss.renderTool(t.type,t.data,e);if(a)n.setAttribute("data-child-type",t.type),n.appendChild(a);else{const e=document.createElement("div");e.className="clepit-columns__unknown-child",e.textContent=`Unsupported block: ${t.type}`,n.appendChild(e)}return n}static isEmpty(e){const t=e.querySelector(".clepit-columns");return!t||0===t.querySelectorAll(".clepit-columns__child").length}static isEmptyData(e){return(e.columns??[]).every(e=>0===e.length)}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},dr={icon:"▥",get input(){return cr},label:"Columns",get output(){return Pn},shortcut:Ct("L"),testId:"block-type-columns",type:"columns"},pr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){return{date:(e.matches('input[type="date"]')?e:e.querySelector('input[type="date"]'))?.value??""}}static render(t,n,a){N.injectStyles("date-input",Fn);const o=N.createStyledElement("input","clepit-date clepit-date--input",{classNames:a?.classNames?.pill,styles:a?.styles?.pill});return o.type="date",n?.date&&Wn(n.date)&&(o.value=n.date),e.addEventListener(t,o,"keydown",e=>{e.stopPropagation()}),o}static isEmpty(t){return""===e.save(t).date}static isEmptyData(e){return!e.date}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},ur={icon:"▤",get input(){return pr},label:"Date",get output(){return Kn},shortcut:Ct("D"),testId:"block-type-date",type:"date"},mr={icon:"—",get input(){return Jn},label:"Delimiter",get output(){return Xn},shortcut:Ct("D"),testId:"block-type-delimiter",type:"delimiter"},hr=/* @__PURE__ */new WeakMap,gr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-doc-card")?e:e.querySelector(".clepit-doc-card");if(t){const e=hr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n,title:t.querySelector(".clepit-doc-card__title")?.textContent??""}}return{pageId:"",title:""}}static render(e,t,n){N.injectStyles("doc-card-input",Yn);const a=t??{pageId:"",title:""},o=ea.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-doc-card--input"),o.setAttribute("contenteditable","false"),hr.set(o,a),o}static isEmpty(t){return""===e.save(t).pageId}static isEmptyData(e){return!e.pageId}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},br={icon:"🗎",get input(){return gr},label:"Doc card",get output(){return ea},shortcut:Ct("K"),testId:"block-type-doc-card",type:"doc_card"},fr={icon:"🔗",get input(){return at},label:"Embed",get output(){return Xe},shortcut:Ct("M"),testId:"block-type-embed",type:"embed"},yr=/* @__PURE__ */new WeakMap,vr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static save(e){const t=e.classList.contains("clepit-file-host")?e:e.querySelector(".clepit-file-host");if(t){const e=yr.get(t);if(e)return e}return{name:"",url:""}}static render(t,n,a,o){N.injectStyles("file-input",na);const i=document.createElement("div");return i.className="clepit-file-host",i.setAttribute("contenteditable","false"),a?.url&&a.name&&yr.set(i,a),e.renderState(i,t,n,o),i}static renderState(t,n,a,o){t.innerHTML="";const i=yr.get(t);if(!i){const i=document.createElement("button");return i.type="button",i.className="clepit-file__upload",i.setAttribute("data-testid","file-upload-button"),i.textContent="Upload file",e.addEventListener(a,i,"click",()=>{e.pick(t,n,a,o)}),void t.appendChild(i)}const r=ia.render(i,void 0,o?.styles,o?.classNames);r.removeAttribute("href"),t.appendChild(r)}static pick(t,n,a,o){const i=document.createElement("input");i.type="file",i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;const s=await n(r);yr.set(t,{contentType:r.type||void 0,name:r.name,size:r.size,url:s}),e.renderState(t,n,a,o)}),i.click()}static isEmpty(t){return""===e.save(t).url}static isEmptyData(e){return!e.url}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},xr={icon:"📎",get input(){return vr},label:"File",get output(){return ia},shortcut:Ct("F"),testId:"block-type-file",type:"file"},kr={html:"",label:""},wr=class e{static{this.placeholder="At a glance"}static save(e){const t=e.classList.contains("clepit-glance")?e:e.querySelector(".clepit-glance");if(!t)return{rows:[]};const n=[...t.querySelectorAll(".clepit-glance-label")],a=[...t.querySelectorAll(".clepit-glance-value")],o=n.map((e,t)=>({html:F(a[t]?.innerHTML??""),label:e.textContent??""})),i=t.getAttribute("data-variant")??"plain",r=t.querySelector(".clepit-glance-caption")?.textContent??"";return r?{caption:r,rows:o,variant:i}:{rows:o,variant:i}}static render(e,t,n){N.injectStyles("clepit-glance-input-styles","\n.clepit-glance--input {\n cursor: text;\n}\n\n.clepit-glance--input .clepit-glance-label:empty::before,\n.clepit-glance--input .clepit-glance-value:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const a=t?.rows?.length?t:{rows:[kr]},o=la.render(a,void 0,n?.styles,n?.classNames);o.classList.add("clepit-glance--input");for(const i of o.querySelectorAll(".clepit-glance-label"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(e,"glanceLabelHint","Label"));for(const i of o.querySelectorAll(".clepit-glance-value"))i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(e,"glanceValueHint","Value"));return o}static changeVariant(t,n,a){const o=c.getState().getInstance(a);if(!o)return;if((t.getAttribute("data-variant")??"plain")===n)return;const i=ss.getBlockIndex(a,t.closest(`.${N.classNames.block.container}`)?.getAttribute("data-id")),r={...e.save(t),variant:n},s={classNames:o.config.classNames?.blocks?.glance,margins:o.config.margins,styles:o.config.styles?.blocks?.glance},l=e.render(a,r,s);t.replaceWith(l),c.getState().updateBlockData(a,i,r)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return!e?.rows?.length||e.rows.every(e=>""===e.label.trim()&&""===F(e.html).trim())}static destroy(e){}},Cr={icon:"≡",get input(){return wr},label:"At a glance",get output(){return la},shortcut:Ct("N"),testId:"block-type-glance",type:"glance"},Sr={icon:"H",get input(){return da},label:"Header",get output(){return pa},shortcut:Ct("H"),testId:"block-type-header",type:"header"},Ar={icon:"𝑖",get input(){return ga},label:"Image",get output(){return ba},shortcut:Ct("I"),testId:"block-type-image",type:"image"},Er={},Nr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){N.injectStyles("issues-input",fa);const a=c.getState().getInstance(e)?.config,o=c.getState().getData(e)?.blocks??[],i=xa.render({},{documentBlocks:o,issueLabels:a?.issueLabels,issues:Er[e]},n?.styles,n?.classNames);return i.classList.add("clepit-issues--input"),i.setAttribute("contenteditable","false"),i}static refresh(t,n){Er[t]={...Er[t],...n};const a=document.getElementById(t);if(a)for(const o of Array.from(a.querySelectorAll(`.${N.classNames.block.container}[data-tool="issues"]`))){const n=o.querySelector(`.${N.classNames.block.content}`);if(!n)continue;const a=c.getState().getInstance(t),i={classNames:a?.config.classNames?.blocks?.issues,styles:a?.config.styles?.blocks?.issues};n.replaceChildren(e.render(t,{},i))}}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){delete Er[t];const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Lr={icon:"☑",get input(){return Nr},label:"Linked issues",get output(){return xa},shortcut:Ct("J"),testId:"block-type-issues",type:"issues"},Br={icon:"•",get input(){return wa},label:"List",get output(){return Ca},shortcut:Ct("L"),testId:"block-type-list",type:"list"},$r="clepit-openapi__source",Ir=(e,t)=>{const n=e.trim();if(""===n)return{};if(/^https?:\/\//i.test(n))return{url:n};try{return{spec:JSON.parse(n)}}catch{return t??{}}},Tr=class e{static{this.placeholder="Paste an OpenAPI document, or a URL to one…"}static{this.dataMap=/* @__PURE__ */new WeakMap}static render(t,n,a){N.injectStyles("clepit-openapi-input-styles","\n.clepit-openapi-input {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.clepit-openapi__source {\n background: var(--clepit-code-bg);\n border: 1px solid var(--clepit-code-border);\n border-radius: 6px;\n color: var(--clepit-code-text);\n font-family: 'SF Mono', 'Monaco', 'Roboto Mono', monospace;\n font-size: 13px;\n max-height: 240px;\n overflow: auto;\n padding: 12px;\n white-space: pre-wrap;\n}\n\n.clepit-openapi__source[data-placeholder]:empty::before {\n color: var(--clepit-text-subtle);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n}\n");const o=O("div","clepit-openapi-input"),i=O("div",$r);i.setAttribute("contenteditable","true"),i.setAttribute("data-placeholder",Y(t,"openApiSourceHint",e.placeholder)),i.setAttribute("data-testid","openapi-source"),i.textContent=n?.url??(n?.spec?JSON.stringify(n.spec,null,2):"");const r=O("div","clepit-openapi-input__preview");return r.setAttribute("data-testid","openapi-preview"),n&&r.appendChild(Qa.render(n)),i.addEventListener("input",()=>{const t=Ir(i.textContent??"",e.dataMap.get(o));e.dataMap.set(o,t),r.replaceChildren(Qa.render(t))}),n&&e.dataMap.set(o,n),o.appendChild(i),o.appendChild(r),o}static save(t){const n=(e=>e.classList.contains($r)?e:e.querySelector(`.${$r}`))(t),a=t.classList.contains("clepit-openapi-input")?t:t.querySelector(".clepit-openapi-input"),o=a?e.dataMap.get(a):void 0;return Ir(n?.textContent??"",o)}static isEmpty(t){return e.isEmptyData(e.save(t))}static isEmptyData(e){return void 0===e.spec&&!e.url}static destroy(e){}},Mr={icon:"⇄",get input(){return Tr},label:"API reference",get output(){return Qa},shortcut:Ct("A"),testId:"block-type-openapi",type:"openapi"},_r={icon:"¶",get input(){return to},label:"Paragraph",get output(){return no},shortcut:Ct("P"),testId:"block-type-paragraph",type:"paragraph"},Dr={icon:"“",get input(){return io},label:"Quote",get output(){return ro},shortcut:Ct("Q"),testId:"block-type-quote",type:"quote"},qr=/* @__PURE__ */new WeakMap,jr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-sketch")?e:e.querySelector(".clepit-sketch");return(t?qr.get(t):void 0)??{strokes:[]}}static render(t,n,a){N.injectStyles("sketch-input",lo);const o=n??{strokes:[]},i=ho.render(o,void 0,a?.styles,a?.classNames);return i.classList.add("clepit-sketch--input"),i.setAttribute("contenteditable","false"),qr.set(i,o),e.attachDrawing(t,i),i}static attachDrawing(t,n){const a=n.querySelector("svg");if(!a)return;let o=null;const i=e=>{const t=a.getBoundingClientRect(),n=0===t.width?0:(e.clientX-t.left)/t.width*1e3,o=0===t.height?0:(e.clientY-t.top)/t.height*240;return[Math.round(100*n)/100,Math.round(100*o)/100]},r=()=>{const e=qr.get(n)??{strokes:[]},t=o&&o.length>=4?{strokes:[...e.strokes,{points:o}]}:e,i=ho.render(t).querySelector("svg");i&&a.replaceChildren(...Array.from(i.childNodes))},s=[],l=(e,t)=>{a.addEventListener(e,t),s.push({element:a,event:e,handler:t})};l("pointerdown",e=>{o=i(e),e.target.setPointerCapture?.(e.pointerId)}),l("pointermove",e=>{o&&(o.push(...i(e)),r())});const c=()=>{if(o&&o.length>=4){const e=qr.get(n)??{strokes:[]};qr.set(n,{strokes:[...e.strokes,{points:o}]})}o=null,r()};l("pointerup",c),l("pointercancel",c),e.eventListenersMap[t]=[...e.eventListenersMap[t]??[],...s]}static isEmpty(t){return 0===e.save(t).strokes.length}static isEmptyData(e){return 0===(e.strokes??[]).length}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},zr={icon:"✏️",get input(){return jr},label:"Sketch",get output(){return ho},shortcut:Ct("W"),testId:"block-type-sketch",type:"sketch"},Hr={icon:"⊞",get input(){return fo},label:"Table",get output(){return ko},shortcut:Ct("T"),testId:"block-type-table",type:"table"},Or=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){return{}}static render(e,t,n){N.injectStyles("toc-input",Co);const a=c.getState().getData(e)?.blocks??[],o=Eo.render({},{documentBlocks:a},n?.styles,n?.classNames);return o.classList.add("clepit-toc--input"),o.setAttribute("contenteditable","false"),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Pr={icon:"≡",get input(){return Or},label:"Table of contents",get output(){return Eo},shortcut:Ct("T"),testId:"block-type-toc",type:"toc"},Rr={latex:"LaTeX",mermaid:"Mermaid"};function Fr(e){const t=e.classList.contains("clepit-typeset")?e:e.querySelector(".clepit-typeset"),n=t?.querySelector(".clepit-typeset__source"),a=t?.querySelector(".clepit-typeset__title")?.textContent?.trim();return a?{source:n?.textContent??"",title:a}:{source:n?.textContent??""}}function Ur(e,t,n,a){N.injectStyles("typeset-input",Lo);const o=n??{source:""},i=N.createStyledElement("div",`clepit-typeset clepit-output-typeset clepit-typeset--input clepit-typeset--${e}`,{classNames:a?.classNames?.wrapper,styles:a?.styles?.wrapper});i.setAttribute("data-language",e),i.setAttribute("data-rendered","source");const r=O("span","clepit-typeset__kind");r.textContent=Rr[e],i.appendChild(r);const s=O("span","clepit-typeset__title");s.setAttribute("data-testid","typeset-title"),s.setAttribute("contenteditable","true"),s.setAttribute("data-placeholder",t),s.textContent=o.title??"",i.appendChild(s);const l=O("pre","clepit-typeset__source");return l.setAttribute("contenteditable","true"),l.textContent=o.source,i.appendChild(l),i}var Vr=class{static{this.placeholder=""}static save(e){return Fr(e)}static render(e,t,n){return Ur("latex",Y(e,"formulaTitleHint","What does this formula show?"),t,n)}static isEmpty(e){return""===Fr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Wr=class{static{this.placeholder=""}static save(e){return Fr(e)}static render(e,t,n){return Ur("mermaid",Y(e,"diagramTitleHint","What does this diagram show?"),t,n)}static isEmpty(e){return""===Fr(e).source.trim()}static isEmptyData(e){return!e.source.trim()}static destroy(e){}},Kr={icon:"∑",get input(){return Vr},label:"LaTeX",get output(){return Ui},shortcut:Ct("X"),testId:"block-type-latex",type:"latex"},Gr={icon:"◈",get input(){return Wr},label:"Mermaid",get output(){return Vi},shortcut:Ct("Y"),testId:"block-type-mermaid",type:"mermaid"},Jr=/* @__PURE__ */new WeakMap,Xr=class e{static{this.placeholder=""}static{this.eventListenersMap={}}static save(e){const t=e.classList.contains("clepit-updates")?e:e.querySelector(".clepit-updates");if(t){const e=Jr.get(t);if(e)return e;const n=t.getAttribute("data-page-id");if(n)return{pageId:n}}return{}}static render(e,t,n){N.injectStyles("updates-input",Ki);const a=t??{},o=Ji.render(a,void 0,n?.styles,n?.classNames);return o.classList.add("clepit-updates--input"),o.setAttribute("contenteditable","false"),Jr.set(o,a),o}static isEmpty(e){return!1}static isEmptyData(e){return!1}static destroy(t){const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[])}},Zr=[fn,wn,Nn,Ln,or,sr,{icon:"🕘",get input(){return Xr},label:"Updates",get output(){return Ji},shortcut:Ct("U"),testId:"block-type-updates",type:"updates"},dr,ur,mr,br,fr,xr,Cr,Sr,Ar,Lr,Br,Mr,_r,Dr,zr,Kr,Gr,Hr,Pr,{icon:"▶",get input(){return Yi},label:"Video",get output(){return Qi},shortcut:Ct("V"),testId:"block-type-video",type:"video"}],Yr="clepit-block-type-selector",Qr="clepit-code-language-submenu",es="clepit-code-theme-submenu",ts="clepit-convert-submenu",ns="clepit-block-operations-menu";function as(e){return Yt.includes(e)}function os(e,t,n){return e?.[t]??n}var is,rs=class e{static{this.defaultClassName="clepit-block-toolbar"}static{this.menuAnchor="--clepit-block-toolbar"}static{this.submenuAnchorSeq=0}static{this.eventListenersMap=/* @__PURE__ */new WeakMap}static{this.documentListeners=[]}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap.get(t)||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap.set(t,i)}static addDocumentEventListener(t,n){const a=e=>n(e);document.addEventListener(t,a),e.documentListeners.push({event:t,handler:a})}static create({containerId:t,block:n}){const a=c.getState().getInstance(t);if(!a)return console.error("BlockToolbar::create: Instance not found for containerId:",t);const o=document.getElementById(t);if(!o)return console.error("BlockToolbar::create: Container not found for containerId:",t);e.eventListenersMap.has(o)||e.eventListenersMap.set(o,[]);const i=void 0!==a.config.audioUploader,r=void 0!==a.config.imageUploader,s=void 0!==a.config.videoUploader,l=a.config.classNames?.blockToolbar,d=a.config.classNames?.blockTypeMenu,p=a.config.classNames?.convertSubmenu,u=a.config.classNames?.operationsMenu,m=a.config.styles?.blockToolbar,h=a.config.styles?.blockTypeMenu,g=a.config.styles?.convertSubmenu,b=a.config.styles?.operationsMenu;e.remove(n),N.injectStyles("clepit-block-toolbar-styles",'\n/* Block Toolbar */\n.clepit-block-toolbar {\n position: absolute;\n left: 4px;\n top: 4px;\n z-index: 1000;\n display: none;\n gap: 4px;\n flex-shrink: 0;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-toolbar--visible {\n display: flex !important;\n transform: translateY(0) !important;\n pointer-events: auto !important;\n}\n\n.clepit-block-toolbar--hidden {\n display: none !important;\n pointer-events: none !important;\n}\n\n.clepit-block--active .clepit-block-toolbar,\n.clepit-block:focus-within .clepit-block-toolbar,\n.clepit-block-toolbar[style*="display: flex"] {\n display: flex;\n pointer-events: auto;\n}\n\n.clepit-block-toolbar-add,\n.clepit-block-toolbar-ops {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n}\n\n.clepit-block-toolbar-add:hover,\n.clepit-block-toolbar-ops:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-block-toolbar-add:active,\n.clepit-block-toolbar-ops:active {\n transform: scale(0.95);\n}\n\n/* Block toolbar positioning and display classes */\n.clepit-block-toolbar--positioned {\n position: absolute;\n}\n\n.clepit-block-toolbar--menu-positioned {\n position: absolute;\n z-index: 1001;\n}\n\n.clepit-block-toolbar--submenu-positioned {\n position: absolute;\n z-index: 998;\n}\n\n.clepit-block-toolbar--item-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--item-visible {\n display: flex;\n}\n\n.clepit-block-toolbar--separator-hidden {\n display: none;\n}\n\n.clepit-block-toolbar--separator-visible {\n display: block;\n}\n\n.clepit-block-toolbar--delete-disabled {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.clepit-block-toolbar--delete-enabled {\n color: var(--clepit-error);\n}\n\n/* The toolbar stays absolutely positioned at every width. It used to go\n * position: static below 768px, which made it a flex item of .clepit-block —\n * and because it is appended after the content it landed to the RIGHT of the\n * text rather than above it, taking a further 60px off an already narrow\n * column. Absolute keeps it inside the gutter the block opens for it. */\n');const f=O("div",e.defaultClassName);f.id=`${t}-block-toolbar`,f.innerHTML="",N.applyStyling(f,{classNames:l?.container,styles:m?.container});const y=O("button","clepit-block-toolbar-add",{"data-testid":"toolbar-add-button",type:"button"});y.innerHTML="+",N.applyStyling(y,{classNames:l?.button,styles:m?.button}),e.addEventListener(o,y,"click",()=>e.showBlockTypeMenu({audioIsEnabled:i,block:n,classNames:d,containerId:t,imageIsEnabled:r,menuLabels:a.config.blockToolbarLabels,styles:h,toolLabels:a.config.blockToolLabels,videoIsEnabled:s}));const v=O("button","clepit-block-toolbar-ops",{"data-testid":"toolbar-operations-button",type:"button"});v.innerHTML="⋯",N.applyStyling(v,{classNames:l?.button,styles:m?.button}),e.addEventListener(o,v,"click",()=>e.showOperationsMenu({audioIsEnabled:i,block:n,classNames:u,containerId:t,convertSubmenuClassNames:p,convertSubmenuStyles:g,imageIsEnabled:r,operationLabels:a.config.blockToolbarLabels,styles:b,toolLabels:a.config.blockToolLabels,videoIsEnabled:s})),f.appendChild(y),f.appendChild(v),e.addEventListener(o,f,"click",e=>e.stopPropagation()),n.appendChild(f)}static showBlockTypeMenu({containerId:t,block:n,imageIsEnabled:a,videoIsEnabled:o,audioIsEnabled:i,classNames:r,styles:s,menuLabels:l,toolLabels:d}){e.closeAllMenus();const p=document.querySelector(`.${Yr}`);if(p)return p.classList.remove(`${Yr}--visible`),p.classList.add(`${Yr}--hidden`),void setTimeout(()=>p.remove(),200);const u=O("div",Yr);N.applyStyling(u,{classNames:r?.container,styles:s?.container});const m=O("input","",{placeholder:os(l,"searchBlocks","Search blocks..."),type:"text"});m.setAttribute("data-testid","block-type-search"),N.applyStyling(m,{classNames:r?.input,styles:s?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=O("div",`${Yr}-items`),b=l=>{g.innerHTML="",l.forEach(l=>{if("image"===l.type&&!a)return;if("video"===l.type&&!o)return;if("audio"===l.type&&!i)return;const c=O("div","clepit-menu-item clepit-block-type-item");c.setAttribute("data-testid",`block-type-${l.type}`),N.applyStyling(c,{classNames:r?.item?.container,styles:s?.item?.container});const p=O("span","clepit-menu-icon "+("image"===l.type?"clepit-menu-icon--italic":""));p.textContent=l.icon,N.applyStyling(p,{classNames:r?.item?.icon,styles:s?.item?.icon}),c.appendChild(p);const m=O("span","clepit-menu-label");if(m.textContent=(as(l.type)?d?.[l.type]:void 0)??l.label,N.applyStyling(m,{classNames:r?.item?.text,styles:s?.item?.text}),c.appendChild(m),l.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=l.shortcut,N.applyStyling(e,{classNames:r?.item?.shortcut,styles:s?.item?.shortcut}),c.appendChild(e)}e.addEventListener(h,c,"click",e=>{if(e.stopPropagation(),n){const e=ss.getBlockIndex(t,n.getAttribute("data-id")||"");ss.insertBlock({data:{html:""},type:l.type},t,e+1)}u.hidePopover()}),g.appendChild(c)})},f=((e,t)=>t.filter(t=>pt(e,t.type)))(c.getState().getInstance(t)?.config,Zr);if(b(f),e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",()=>{const e=m.value.toLowerCase(),t=f.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e));if(b(t),0===t.length&&""!==e.trim()){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=os(l,"noBlockTypesFound","No block types found"),g.appendChild(e)}}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.hidePopover()}),u.appendChild(g),u.classList.add(Yr),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${Yr}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||u.remove()})):u.showPopover()}static showOperationsMenu({containerId:t,block:n,classNames:a,styles:o,convertSubmenuClassNames:i,convertSubmenuStyles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:c,operationLabels:d,toolLabels:p}){e.closeAllMenus();const u=O("div",ns);o?.container&&N.applyStyling(u,{classNames:a?.container,styles:o.container}),a?.container&&u.classList.add(a.container);const m=O("input","",{placeholder:os(d,"searchOperations","Search operations..."),type:"text"});m.setAttribute("data-testid","operations-search"),N.applyStyling(m,{classNames:a?.input,styles:o?.input}),u.appendChild(m);const h=document.querySelector(`#${t}`),g=O("div",`${ns}-items`),b=n.getAttribute("data-tool");if(!b)return;const f=(e,t)=>os(d,e,t),y=[{hasSubmenu:!0,icon:"↻",label:f("convert","Convert To"),testId:"operation-convert",value:"convert"},{icon:"↑",label:f("moveUp","Move Up"),shortcut:"⌘⇧↑",testId:"operation-moveUp",value:"moveUp"},{icon:"↓",label:f("moveDown","Move Down"),shortcut:"⌘⇧↓",testId:"operation-moveDown",value:"moveDown"},{icon:"×",label:f("delete","Delete"),shortcut:"⌘⇧⌫",testId:"operation-delete",value:"delete"}],v=[{icon:"←",label:f("alignLeft","Align Left"),testId:"image-align-left",value:"imageAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"image-align-center",value:"imageAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"image-align-right",value:"imageAlignRight"}],x=[{icon:"←",label:f("alignLeft","Align Left"),testId:"video-align-left",value:"videoAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"video-align-center",value:"videoAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"video-align-right",value:"videoAlignRight"}],k=[{icon:"←",label:f("alignLeft","Align Left"),testId:"audio-align-left",value:"audioAlignLeft"},{icon:"↔",label:f("alignCenter","Align Center"),testId:"audio-align-center",value:"audioAlignCenter"},{icon:"→",label:f("alignRight","Align Right"),testId:"audio-align-right",value:"audioAlignRight"}],w=[{hasSubmenu:!0,icon:"⌘",label:f("codeLanguage","Language"),testId:"code-language",value:"codeLanguage"},{hasSubmenu:!0,icon:"◆",label:f("codeTheme","Theme"),testId:"code-theme",value:"codeTheme"}],C="embed"===b&&at.save(n).issue?[{icon:"▭",label:f("embedShowChip","Show as chip"),testId:"embed-show-chip",value:"embedShowChip"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}]:[{icon:"▣",label:f("embedShowLive","Show live"),testId:"embed-show-live",value:"embedShowLive"},{icon:"▭",label:f("embedShowCard","Show as card"),testId:"embed-show-card",value:"embedShowCard"},{icon:"↗",label:f("embedShowLink","Show as link"),testId:"embed-show-link",value:"embedShowLink"},{icon:"⧉",label:f("embedCopyLink","Copy link"),testId:"embed-copy-link",value:"embedCopyLink"}];y.forEach(m=>{const b=O("div","clepit-menu-item clepit-block-operation-item");b.setAttribute("data-testid",`operation-${m.value}`),N.applyStyling(b,{classNames:a?.item?.container,styles:o?.item?.container}),b.setAttribute("data-testid",m.testId);const f=O("span","clepit-menu-icon");f.textContent=m.icon,N.applyStyling(f,{classNames:a?.item?.icon,styles:o?.item?.icon}),b.appendChild(f);const y=O("span","clepit-menu-label");if(y.textContent=m.label,N.applyStyling(y,{classNames:a?.item?.text,styles:o?.item?.text}),b.appendChild(y),m.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=m.shortcut,N.applyStyling(e,{classNames:a?.item?.shortcut,styles:o?.item?.shortcut}),b.appendChild(e)}if(m.hasSubmenu){const e=O("span","clepit-menu-arrow");e.textContent="›",b.appendChild(e)}"delete"===m.value&&(b.classList.add("clepit-block-toolbar--delete-enabled"),1===h.querySelectorAll(".clepit-block").length&&(b.classList.add("clepit-block-toolbar--delete-disabled"),b.title="Cannot delete the last block")),e.addEventListener(h,b,"click",a=>{a.stopPropagation(),m.hasSubmenu?(document.querySelector(`.${Qr}`)?.remove(),document.querySelector(`.${es}`)?.remove(),e.showConvertSubmenu({audioIsEnabled:c,block:n,classNames:i,containerId:t,imageIsEnabled:s,menuLabels:d,parentItem:b,parentMenu:u,styles:r,toolLabels:p,videoIsEnabled:l})):(e.handleOperationSelect(m.value,n,t),u.remove())}),g.appendChild(b)});const S=()=>{const e=O("div","clepit-menu-divider");N.applyStyling(e,{classNames:a?.divider,styles:o?.divider}),g.appendChild(e)};if("image"===b&&(S(),v.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("imageAlign")){const e=n.querySelector(".clepit-image-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("imageAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"video"===b&&(S(),x.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("videoAlign")){const e=n.querySelector(".clepit-video-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("videoAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"audio"===b&&(S(),k.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");if(l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),i.value.startsWith("audioAlign")){const e=n.querySelector(".clepit-audio-wrapper");if(e){const t=e.style.textAlign;("left"===t?"left":"right"===t?"right":"center")===i.value.replace("audioAlign","").toLowerCase()&&r.classList.add("active")}}e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"code"===b&&(S(),w.forEach(s=>{const l=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(l,{classNames:a?.item?.container,styles:o?.item?.container}),l.setAttribute("data-testid",s.testId);const c=O("span","clepit-menu-icon");c.textContent=s.icon,N.applyStyling(c,{classNames:a?.item?.icon,styles:o?.item?.icon}),l.appendChild(c);const p=O("span","clepit-menu-label");if(p.textContent=s.label,N.applyStyling(p,{classNames:a?.item?.text,styles:o?.item?.text}),l.appendChild(p),s.hasSubmenu){const e=O("span","clepit-menu-arrow");e.textContent="›",l.appendChild(e)}e.addEventListener(h,l,"click",a=>{a.stopPropagation(),s.hasSubmenu?"codeLanguage"===s.value?e.showCodeLanguageSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):"codeTheme"===s.value&&e.showCodeThemeSubmenu({block:n,classNames:i,containerId:t,menuLabels:d,parentItem:l,parentMenu:u,styles:r}):(e.handleOperationSelect(s.value,n,t),u.remove())}),g.appendChild(l)})),"embed"===b&&(S(),C.forEach(i=>{const r=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(r,{classNames:a?.item?.container,styles:o?.item?.container}),r.setAttribute("data-testid",i.testId);const s=O("span","clepit-menu-icon");s.textContent=i.icon,N.applyStyling(s,{classNames:a?.item?.icon,styles:o?.item?.icon}),r.appendChild(s);const l=O("span","clepit-menu-label");l.textContent=i.label,N.applyStyling(l,{classNames:a?.item?.text,styles:o?.item?.text}),r.appendChild(l),e.addEventListener(h,r,"click",a=>{a.stopPropagation(),e.handleOperationSelect(i.value,n,t),u.remove()}),g.appendChild(r)})),"header"===b){S();const i=e.getCurrentHeadingLevel(n);[{icon:"H1",label:f("headingH1","Heading 1"),value:"heading-h1"},{icon:"H2",label:f("headingH2","Heading 2"),value:"heading-h2"},{icon:"H3",label:f("headingH3","Heading 3"),value:"heading-h3"},{icon:"H4",label:f("headingH4","Heading 4"),value:"heading-h4"},{icon:"H5",label:f("headingH5","Heading 5"),value:"heading-h5"},{icon:"H6",label:f("headingH6","Heading 6"),value:"heading-h6"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===`heading-${i}`&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(r.value,n,t),u.remove()}),g.appendChild(s)})}if("list"===b){S();const i=n.querySelector(".clepit-list")?.getAttribute("data-type")||"unordered";[{icon:"•",label:f("listUnordered","Unordered"),value:"unordered"},{icon:"1.",label:f("listOrdered","Ordered"),value:"ordered"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`listType${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("alert"===b){S();const i=n.querySelector(".clepit-alert")?.getAttribute("data-variant")||"info";[{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"},{icon:"—",label:f("variantPlain","Plain"),value:"plain"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`alertVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("glance"===b){S();const i=n.querySelector(".clepit-glance")?.getAttribute("data-variant")||"plain";[{icon:"—",label:f("variantPlain","Plain"),value:"plain"},{icon:"i",label:f("variantInfo","Info"),value:"info"},{icon:"!",label:f("variantWarning","Warning"),value:"warning"},{icon:"×",label:f("variantError","Error"),value:"error"},{icon:"✓",label:f("variantSuccess","Success"),value:"success"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,l.style.color=e.getAlertIconColor(r.value),N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`glanceVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}if("delimiter"===b){S();const i=n.querySelector(".clepit-delimiter")?.getAttribute("data-variant")||"line";[{icon:"—",label:f("delimiterLine","Line"),value:"line"},{icon:"***",label:f("delimiterStars","Stars"),value:"stars"}].forEach(r=>{const s=O("div","clepit-menu-item clepit-block-operation-item");N.applyStyling(s,{classNames:a?.item?.container,styles:o?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=r.icon,N.applyStyling(l,{classNames:a?.item?.icon,styles:o?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");c.textContent=r.label,N.applyStyling(c,{classNames:a?.item?.text,styles:o?.item?.text}),s.appendChild(c),r.value===i&&s.classList.add("active"),e.addEventListener(h,s,"click",a=>{a.stopPropagation(),e.handleOperationSelect(`delimiterVariant${r.value}`,n,t),u.remove()}),g.appendChild(s)})}const A=g.querySelectorAll(".clepit-block-operation-item"),E=g.querySelectorAll(".clepit-menu-divider");if(e.addEventListener(h,m,"click",e=>e.stopPropagation()),e.addEventListener(h,m,"focus",e=>e.stopPropagation()),e.addEventListener(h,m,"input",e=>{(e=>{let t=0;A.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=g.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=f("noOperationsFound","No operations found"),g.appendChild(e)}}else n&&n.remove();E.forEach(t=>{""!==e.trim()?(t.classList.remove("clepit-block-toolbar--separator-visible"),t.classList.add("clepit-block-toolbar--separator-hidden")):(t.classList.remove("clepit-block-toolbar--separator-hidden"),t.classList.add("clepit-block-toolbar--separator-visible"))})})(e.target.value)}),e.addEventListener(h,m,"keydown",e=>{"Escape"===e.key&&u.remove()}),u.appendChild(g),u.classList.add(ns),u.setAttribute("popover","auto"),m.setAttribute("autofocus",""),n){const t=n.querySelector(`.${e.defaultClassName}`);t&&t.style.setProperty("anchor-name",e.menuAnchor)}e.menuHost(t).appendChild(u),u.addEventListener("toggle",e=>{"closed"===e.newState&&u.remove()}),"function"!=typeof u.showPopover?(u.classList.add(`${ns}--visible`),m.focus(),e.addDocumentEventListener("click",e=>{const t=e.target;u.contains(t)||n?.contains(t)||t.closest?.(".clepit-block-toolbar-ops")||u.remove()})):u.showPopover()}static showConvertSubmenu({containerId:t,block:n,parentItem:a,parentMenu:o,classNames:i,styles:r,imageIsEnabled:s,videoIsEnabled:l,audioIsEnabled:d,menuLabels:p,toolLabels:u}){const m=document.querySelector(`.${ts}`);m&&m.remove();const h=n.getAttribute("data-tool");if(!h)return;const g=O("div",ts);g.classList.add(ts),g.classList.add(`${ts}--hidden`),r?.container&&N.applyStyles(g,r.container),i?.container&&g.classList.add(i.container);const b=O("input","",{placeholder:os(p,"searchConvertOptions","Search convert options..."),type:"text"});b.setAttribute("data-testid","convert-search"),N.applyStyling(b,{classNames:i?.input,styles:r?.input}),g.appendChild(b),setTimeout(()=>b.focus(),10);const f=document.querySelector(`#${t}`),y=O("div",`${ts}-items`),v=e=>(as(e.type)?u?.[e.type]:void 0)??e.label,x=c.getState().getInstance(t)?.config;Zr.filter(e=>e.type!==h&&(!!pt(x,e.type)&&(!("image"===e.type&&!s||"video"===e.type&&!l||"audio"===e.type&&!d)||void 0))).sort((e,t)=>v(e).localeCompare(v(t))).forEach(a=>{const s=O("div","clepit-menu-item clepit-convert-option-item");s.setAttribute("data-testid",a.testId),N.applyStyling(s,{classNames:i?.item?.container,styles:r?.item?.container});const l=O("span","clepit-menu-icon");l.textContent=a.icon,N.applyStyling(l,{classNames:i?.item?.icon,styles:r?.item?.icon}),s.appendChild(l);const c=O("span","clepit-menu-label");if(c.textContent=v(a),N.applyStyling(c,{classNames:i?.item?.text,styles:r?.item?.text}),s.appendChild(c),a.shortcut){const e=O("span","clepit-menu-shortcut");e.textContent=a.shortcut,N.applyStyling(e,{classNames:i?.item?.shortcut,styles:r?.item?.shortcut}),s.appendChild(e)}e.addEventListener(f,s,"click",e=>{e.stopPropagation();const i=n?.getAttribute("data-tool");if(!i)return;let r;if(n){const e=n.querySelector(".clepit-block-content");"paragraph"===i?r=e.querySelector(".clepit-paragraph")?.innerText||"":"quote"===i?r=e.querySelector(".clepit-quote-text")?.innerText||"":"list"===i?r=Array.from(e.querySelectorAll(".clepit-list-item")).map(e=>e.innerText.trim()).filter(Boolean).join("\n"):"alert"===i?r=e.querySelector(".clepit-alert")?.innerText||"":"header"===i&&(r=e.querySelector(".clepit-header")?.innerText||"")}const s=n?.getAttribute("data-id");s&&ss.convertBlock(s,a.type,t),setTimeout(()=>{if(!n)return;const e=n.getAttribute("data-tool");if(r&&r.trim()){const t=n.querySelector(".clepit-block-content");if("paragraph"===e){const e=t.querySelector(".clepit-paragraph");e&&(e.innerText=r)}else if("quote"===e){const e=t.querySelector(".clepit-quote-text");e&&(e.innerText=r)}else if("list"===e){const e=t.querySelector(".clepit-list");e&&(e.innerHTML="",r.split("\n").forEach(t=>{const n=document.createElement("li");n.className="clepit-list-item",n.setAttribute("contenteditable","true"),n.innerText=t,e.appendChild(n)}))}else if("alert"===e){const e=t.querySelector(".clepit-alert");e&&(e.innerText=r)}else if("header"===e){const e=t.querySelector(".clepit-header");e&&(e.innerText=r)}}},0),o.remove()}),y.appendChild(s)});const k=y.querySelectorAll(".clepit-convert-option-item");e.addEventListener(f,b,"click",e=>e.stopPropagation()),e.addEventListener(f,b,"focus",e=>e.stopPropagation()),e.addEventListener(f,b,"input",e=>{(e=>{let t=0;k.forEach(n=>{(n.querySelector(".clepit-menu-label")?.textContent?.toLowerCase()||"").includes(e.toLowerCase())?(n.classList.remove("clepit-block-toolbar--item-hidden"),n.classList.add("clepit-block-toolbar--item-visible"),t++):(n.classList.remove("clepit-block-toolbar--item-visible"),n.classList.add("clepit-block-toolbar--item-hidden"))});const n=y.querySelector(".clepit-not-found-message");if(0===t&&""!==e.trim()){if(!n){const e=O("div","clepit-not-found-message",{style:"padding: 8px 12px; color: #666; font-style: italic; text-align: center;"});e.textContent=os(p,"noConvertOptionsFound","No convert options found"),y.appendChild(e)}}else n&&n.remove()})(e.target.value)}),e.addEventListener(f,b,"keydown",t=>{"Escape"===t.key&&e.closeMenu(ts)}),g.appendChild(y);const w="--clepit-convert-parent-"+e.submenuAnchorSeq++;a.style.setProperty("anchor-name",w),g.style.setProperty("position-anchor",w),g.classList.remove(`${ts}--hidden`),g.setAttribute("popover","auto"),e.menuHost(t).appendChild(g),g.addEventListener("toggle",e=>{"closed"===e.newState&&g.remove()}),"function"!=typeof g.showPopover?(o.appendChild(g),g.classList.add(`${ts}--visible`),e.addDocumentEventListener("click",e=>{const t=e.target;g.contains(t)||a.contains(t)||o.contains(t)||g.remove()})):g.showPopover()}static handleOperationSelect(e,t,n){if(!t)return;const a=document.querySelector(`#${n}`);if(e.startsWith("convertTo")){const a=e.replace("convertTo",""),o=t.getAttribute("data-id");return void(o&&ss.convertBlock(o,a,n))}if(e.startsWith("heading-")){const n=e.replace("heading-","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector('[contenteditable="true"]');return void(o&&da.changeLevel(o,n,a.id))}if(e.startsWith("listType")){const n=e.replace("listType","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-list");return void(o&&wa.changeType(o,n,a.id))}if(e.startsWith("alertVariant")){const n=e.replace("alertVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-alert");return void(o&&gn.changeVariant(o,n,a.id))}if(e.startsWith("glanceVariant")){const n=e.replace("glanceVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-glance");return void(o&&wr.changeVariant(o,n,a.id))}if(e.startsWith("delimiterVariant")){const n=e.replace("delimiterVariant","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;const o=t.querySelector(".clepit-delimiter");if(!o)return;return Jn.changeVariant(o,n,a.id)}if(e.startsWith("tableAction")){const n=e.replace("tableAction",""),a=t.querySelector(`.${N.classNames.block.content}`);if(!a)return;return fo.handleAction(n,a)}if(e.startsWith("embed"))return at.handleOperation(e,t,a.id);if(e.startsWith("imageAlign"))return ga.setAlignment(t,e.replace("imageAlign","").toLowerCase());if(e.startsWith("videoAlign"))return Yi.setAlignment(t,e.replace("videoAlign","").toLowerCase());if(e.startsWith("audioAlign"))return xn.setAlignment(t,e.replace("audioAlign","").toLowerCase());if(e.startsWith("codeLanguage")){const n=e.replace("codeLanguage","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;return oe.updateLanguage(t,n)}if(e.startsWith("codeTheme")){const n=e.replace("codeTheme","");if(-1===ss.getBlockIndex(a.id,t.getAttribute("data-id")))return;return oe.updateTheme(t,n)}const o=ss.getBlockIndex(a.id,t.getAttribute("data-id"));if(-1!==o)switch(e){case"delete":ss.removeBlock(a.id,o);break;case"moveUp":o>0&&ss.moveBlock(a.id,o,o-1);break;case"moveDown":o<ss.getBlocks(a.id).length-1&&ss.moveBlock(a.id,o,o+1);break;default:console.warn(`Unknown block operation: ${e}`)}}static showCodeLanguageSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${Qr}`);l&&l.remove();const c=document.querySelector(`.${es}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${N.classNames.block.code.container}`)?.getAttribute("data-language")||"javascript",u=N.createStyledElement("div",Qr,{classNames:i?.container,styles:s?.container});u.classList.add(ts,"clepit-block-toolbar--submenu-positioned");const m=O("input","",{placeholder:os(r,"searchLanguages","Search languages..."),type:"text"});m.setAttribute("data-testid","language-search"),u.appendChild(m);const h=oe.supportedLanguages;Object.entries(h).forEach(([t,r])=>{const l=N.createStyledElement("div","clepit-menu-item clepit-code-language-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-language-${t}`);const c=N.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeLanguage${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-language-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${Qr}--hidden`),u.classList.add(`${Qr}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${Qr}--visible`),u.classList.add(`${Qr}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static showCodeThemeSubmenu({parentItem:t,parentMenu:n,block:a,containerId:o,classNames:i,menuLabels:r,styles:s}){const l=document.querySelector(`.${es}`);l&&l.remove();const c=document.querySelector(`.${Qr}`);c&&c.remove();const d=document.getElementById(o);if(!d)return;const p=a?.querySelector(`.${N.classNames.block.code.container}`)?.getAttribute("data-theme")||"default",u=N.createStyledElement("div",es,{classNames:i?.container,styles:s?.container});u.classList.add(ts,"clepit-block-toolbar--submenu-positioned");const m=O("input","",{placeholder:os(r,"searchThemes","Search themes..."),type:"text"});m.setAttribute("data-testid","theme-search"),u.appendChild(m);const h=oe.supportedThemes;Object.entries(h).forEach(([t,r])=>{const l=N.createStyledElement("div","clepit-menu-item clepit-code-theme-item",{classNames:i?.item?.container,styles:s?.item?.container});l.setAttribute("data-testid",`code-theme-${t}`);const c=N.createStyledElement("span","",{classNames:i?.item?.text,styles:s?.item?.text});c.textContent=r.name,l.appendChild(c),t===p&&l.classList.add("active"),e.addEventListener(d,l,"click",i=>{i.stopPropagation(),e.handleOperationSelect(`codeTheme${t}`,a,o),n.remove()}),u.appendChild(l)});const g=u.querySelectorAll(".clepit-code-theme-item");e.addEventListener(d,m,"click",e=>e.stopPropagation()),e.addEventListener(d,m,"input",e=>{const t=e.target.value.toLowerCase();g.forEach(e=>{const n=e.querySelector("span")?.textContent?.toLowerCase()||"";e.classList.toggle("clepit-block-toolbar--item-hidden",!n.includes(t))})}),n.appendChild(u);const b=t.getBoundingClientRect(),f=n.getBoundingClientRect();u.style.top=b.top-f.top+"px",u.style.left=b.right-f.left+4+"px",setTimeout(()=>{u.classList.remove(`${es}--hidden`),u.classList.add(`${es}--visible`)},10),setTimeout(()=>{const t=e=>{const a=e.target,o=u.contains(a),i=n.contains(a);o||i||(u.classList.remove(`${es}--visible`),u.classList.add(`${es}--hidden`),setTimeout(()=>u.remove(),200),document.removeEventListener("click",t))};e.addDocumentEventListener("click",t)},0)}static show(t,n){e.closeAllMenus(),e.hideAllToolbars(t);const a=n.querySelector(`.${e.defaultClassName}`);a&&(a.classList.add("clepit-block-toolbar--visible"),a.classList.remove("clepit-block-toolbar--hidden"))}static hide(t){document.querySelector(`.${Yr}, .${ns}, .${ts}`)||e.hideAllToolbars(t)}static menuHost(e){return document.getElementById(e)?.closest("dialog")??document.body}static hideAllToolbars(t){const n=document.getElementById(t);n&&n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>{e.classList.remove("clepit-block-toolbar--visible"),e.classList.add("clepit-block-toolbar--hidden")})}static getCurrentHeadingLevel(e){if(!e)return"h1";const t=e.querySelector(".clepit-header");if(!t)return"h1";const n=t.getAttribute("data-level");if(n)return n;const a=t.tagName.toLowerCase();return a||"h1"}static closeMenu(e){const t=document.querySelector(`.${e}`);t&&(t.matches(":popover-open")&&"function"==typeof t.hidePopover?t.hidePopover():t.remove())}static closeAllMenus(){e.closeMenu(Yr),e.closeMenu(ns),e.closeMenu(ts)}static getAlertIconColor(e){switch(e){case"info":return"#2196f3";case"warning":return"#ff9800";case"error":return"#f44336";case"success":return"#4caf50";default:return"#666"}}static remove(t){t.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}static destroy(t){const n=document.getElementById(t);if(!n)return;const a=e.eventListenersMap.get(n);a&&(a.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap.delete(n)),e.documentListeners.forEach(({event:e,handler:t})=>{document.removeEventListener(e,t)}),e.documentListeners=[],n.querySelectorAll(`.${e.defaultClassName}`).forEach(e=>e.remove())}},ss=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static createBlockElement(t,n){const a=c.getState().getInstance(n);if(!a)return console.error("BlockManager::createBlockElement: Instance not found for containerId:",n),null;const o=O("div",N.classNames.block.container);o.setAttribute("data-container-id",n),o.setAttribute("data-id",t.id??crypto.randomUUID()),o.setAttribute("data-tool",t.type),o.setAttribute("data-indent","0");const i={classNames:a.config.classNames?.blocks?.[t.type],styles:a.config.styles?.blocks?.[t.type]};let r,s;if(i.margins&&(r=i.margins.top,s=i.margins.bottom),void 0===r&&i.styles){const e=i.styles;if(e.marginTop){const t=e.marginTop;"string"==typeof t&&t.endsWith("px")?r=parseInt(t.replace("px",""),10):"number"==typeof t&&(r=t)}}if(void 0===s&&i.styles){const e=i.styles;if(e.marginBottom){const t=e.marginBottom;"string"==typeof t&&t.endsWith("px")?s=parseInt(t.replace("px",""),10):"number"==typeof t&&(s=t)}}void 0===r&&void 0!==a.config.margins?.top&&(r=a.config.margins.top),void 0===s&&void 0!==a.config.margins?.bottom&&(s=a.config.margins.bottom),void 0!==r&&(o.style.marginTop=`${r}px`),void 0!==s&&(o.style.marginBottom=`${s}px`),rs.create({block:o,containerId:n});const l=O("div",N.classNames.block.content),d=e.renderTool(t.type,t.data,n);return d?(l.appendChild(d),e.addEventListener(n,o,"click",t=>e.focusBlock(t.currentTarget)),o.appendChild(l),o):(console.error("BlockManager::createBlockElement: Rendered element not found for type:",t.type),null)}static insertBlock(t,n,a){e.adoptStartingBlock(n);const o=e.createBlockElement(t,n);if(!o)return null;e.renderBlock(o,n,a);const i=e.getBlockData(o.getAttribute("data-id"));return c.getState().addBlock(n,i,e.getBlockIndex(n,o.getAttribute("data-id"))),o}static removeBlock(t,n){const a=e.getBlocks(t);if(n<0||n>=a.length||1===a.length)return null;if(n>0){const t=e.getBlock(a[n-1].getAttribute("data-id"));t&&e.focusBlock(t)}else if(0===n&&a.length>1){const t=e.getBlock(a[n+1].getAttribute("data-id"));t&&e.focusBlock(t)}a[n].remove(),c.getState().removeBlock(t,n)}static replaceBlock(t,n,a){e.insertBlock(a,t,n+1),e.removeBlock(t,n)}static moveBlock(t,n,a){const o=e.getBlocks(t);if(n<0||n>=o.length||a<0||a>=o.length)return;const i=c.getState().getData(t);if(!i)return;const r=c.getState().getContentElement(t);if(!r)return;const s=o[n];o.splice(n,1),o.splice(a,0,s),0===a?r.insertBefore(s,r.firstChild):a>=o.length-1?r.appendChild(s):r.insertBefore(s,o[a+1]);const l=o.map(t=>e.getBlockData(t.getAttribute("data-id"))),d={...i,blocks:l};c.getState().setData(t,d),e.focusBlock(s)}static getBlock(e){return document.querySelector(`[data-id="${e}"]`)}static getBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${N.classNames.block.container}`);return Array.from(n)}static getActiveBlocks(e){const t=document.getElementById(e);if(!t)return[];const n=t.querySelectorAll(`.${N.classNames.block.active}`);return Array.from(n)}static getBlockIndex(t,n){return e.getBlocks(t).findIndex(e=>e.getAttribute("data-id")===n)}static getTool(e){return Zr.find(t=>t.type===e)||null}static getBlockData(t){const n=e.getBlock(t);if(!n)return{data:{html:""},type:"paragraph"};const a=n.getAttribute("data-tool"),o=a?e.getTool(a):null;if(!o)return{data:{html:""},id:t,type:"paragraph"};const i=n.querySelector(`.${N.classNames.block.content}`);return i?{data:o.input.save(i),id:t,tunes:e.getBlockTunes(n),type:a}:{data:{html:""},id:t,tunes:e.getBlockTunes(n),type:a}}static extractData(t){return{blocks:e.getBlocks(t).map(t=>e.getBlockData(t.getAttribute("data-id"))),time:Date.now(),version:"1.0.0"}}static renderTool(e,t,n){const a=c.getState().getInstance(n);if(!a)return null;const o={classNames:a.config.classNames?.blocks?.[e],styles:a.config.styles?.blocks?.[e]};switch(e){case"alert":return gn.render(n,t,o);case"audio":return a.config.audioUploader?xn.render(a.config.audioUploader,n,t,o):(console.error("BlockManager::renderTool: Audio uploader not found for containerId:",n),null);case"code":return oe.render(n,t,o);case"collapsible":return Mn.render(n,t,o);case"columns":return cr.render(n,t,o);case"date":return pr.render(n,t,o);case"delimiter":return Jn.render(n,t,o);case"collection":return rr.render(n,t,o);case"doc_card":return gr.render(n,t,o);case"embed":return at.render(n,t,o);case"openapi":return Tr.render(n,t,o);case"sketch":return jr.render(n,t,o);case"latex":return Vr.render(n,t,o);case"mermaid":return Wr.render(n,t,o);case"file":return a.config.fileUploader?vr.render(a.config.fileUploader,n,t,o):(console.error("BlockManager::renderTool: File uploader not found for containerId:",n),null);case"header":return da.render(n,t,o);case"image":return a.config.imageUploader?ga.render(a.config.imageUploader,n,t,o):(console.error("BlockManager::renderTool: Image uploader not found for containerId:",n),null);case"list":return wa.render(n,t,o);case"checklist":return An.render(n,t,o);case"paragraph":return to.render(n,t,o);case"quote":return io.render(n,t,o);case"table":return fo.render(n,t,o);case"toc":return Or.render(n,t,o);case"issues":return Nr.render(n,t,o);case"video":return a.config.videoUploader?Yi.render(a.config.videoUploader,n,t,o):(console.error("BlockManager::renderTool: Video uploader not found for containerId:",n),null);default:return null}}static focusBlock(t){const n=t.querySelector('[contenteditable="true"]');n&&n.focus({preventScroll:!0}),e.setActiveBlock(t)}static setActiveBlock(t){const n=t.getAttribute("data-container-id");for(const a of e.getActiveBlocks(n))a.classList.remove(N.classNames.block.active);t.classList.add(N.classNames.block.active),rs.show(n,t)}static getActiveBlock(e){const t=document.getElementById(e);return t?t.querySelector(`.${N.classNames.block.active}`):null}static convertBlock(t,n,a){const o=e.getBlock(t);if(!o)return console.error("BlockManager::convertBlock: Block not found for blockId:",t);e.adoptStartingBlock(a);const i=e.getBlockData(t),r=e.getTool(n);if(!r)return console.error("BlockManager::convertBlock: New tool not found for newType:",n);const s=e.getBlockIndex(a,t);let l=i.data;if("list"===n){const e=i.data,t=e.html||e.text||"";l={items:t?[t]:[""],type:"unordered"}}else if("header"===n){const e=i.data;l={html:e.html||e.text||"",level:"h1"}}const d={data:l,id:t,type:r.type},p=e.createBlockElement(d,a);if(!p)return console.error("BlockManager::convertBlock: New block element not found for newType:",n);o.replaceWith(p);const u=e.getBlockData(p.getAttribute("data-id"));c.getState().updateBlock(a,s,u),e.focusBlock(p)}static getBlockTunes(e){const t={},n=e.querySelectorAll("[data-tune]");for(const a of n){const e=a.getAttribute("data-tune");e&&(t[e]=a.getAttribute("data-value")||!0)}return Object.keys(t).length>0?t:void 0}static updateStateFromRange(t){const n=mn.getInstanceAndTargetFromRange(t);if(!n)return;const a=n.target.closest(`.${N.classNames.block.container}`);if(!a)return;e.adoptStartingBlock(n.instance.config.containerId);const o=e.getBlockIndex(n.instance.config.containerId,a.getAttribute("data-id"));c.getState().updateBlock(n.instance.config.containerId,o,e.getBlockData(a.getAttribute("data-id")))}static renderBlock(t,n,a){const o=e.getBlocks(n),i=c.getState().getContentElement(n);if(!i)return console.error("BlockManager::renderBlock: Container not found for containerId:",n);if(void 0!==a&&a>=0)if(a<o.length){const e=o[a];i.insertBefore(t,e),o.splice(a,0,t)}else i.appendChild(t),o.push(t);else i.appendChild(t),o.push(t);e.focusBlock(t);const r=c.getState().getInstance(n);r&&Jt.initializeElements(t,{classNames:r.config.classNames?.blocks?.tooltip,styles:r.config.styles?.blocks?.tooltip})}static setBlocks(t,n){e.removeAllBlocks(n),t.forEach((t,a)=>e.insertBlock(t,n,a)),c.getState().updateData(n,{blocks:t})}static renderBlocks(t,n){for(const o of e.getBlocks(n))o.remove();const a=(t,a)=>{const o=e.createBlockElement(t,n);o&&e.renderBlock(o,n,a)};if(0===t.length)return a({data:{html:""},type:"paragraph"},0);t.forEach(a)}static adoptStartingBlock(t){const n=c.getState().getInstance(t)?.data.blocks,a=e.getBlocks(t);!n||n.length>0||1!==a.length||c.getState().seedBlocks(t,[e.getBlockData(a[0].getAttribute("data-id"))])}static removeAllBlocks(t){for(const n of e.getBlocks(t))n.remove();c.getState().setData(t,{blocks:[],time:Date.now(),version:"1.0.0"})}static resetBlocks(t){e.removeAllBlocks(t),e.insertBlock({data:{html:""},type:"paragraph"},t,0)}static getEditorId(e){const t=e.closest(`.${N.classNames.editor.container}`);return t?t.id:null}static handleKeydown(t){const n=t,a=t.currentTarget,o=a.closest(`.${N.classNames.block.container}`),i=e.getEditorId(o);if(!i)return;const r=e.getBlockIndex(i,o.getAttribute("data-id")),s=n.metaKey||n.ctrlKey;if(n.shiftKey)switch(n.key){case"ArrowUp":t.preventDefault(),t.stopPropagation(),r>0&&e.moveBlock(i,r,r-1);break;case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=e.getBlocks(i);n&&r<n.length-1&&e.moveBlock(i,r,r+1)}else if(s)switch(n.key){case"Delete":case"Backspace":t.preventDefault(),t.stopPropagation(),e.removeBlock(i,r)}else if("Enter"===n.key)n.preventDefault(),n.stopPropagation(),e.insertBlock({data:{html:""},type:"paragraph"},i,r+1);else if("Backspace"===n.key){if(!R(a.innerHTML))return;n.preventDefault(),n.stopPropagation(),e.removeBlock(i,r)}else{e.ensureActiveBlock(i);const a=e.getBlocks(i);switch(n.key){case"ArrowUp":if(t.preventDefault(),t.stopPropagation(),r>0){const t=a[r-1];t&&e.focusBlock(t)}return;case"ArrowDown":if(t.preventDefault(),t.stopPropagation(),r<a.length-1){const t=a[r+1];t&&e.focusBlock(t)}return}}}static handleInput(t){e.saveBlockData(t.currentTarget)}static ensureActiveBlock(t){const n=e.getBlocks(t);let a=e.getActiveBlock(t);if(!a){const t=document.activeElement;if(!t)return;const o=t.closest(`.${N.classNames.block.container}`);if(o)a=o,e.setActiveBlock(a);else{if(0===n.length)return;a=n[0],e.setActiveBlock(a)}}}static saveBlockData(t){const n=t.closest(`.${N.classNames.block.container}`),a=e.getEditorId(n);if(!a)return;e.adoptStartingBlock(a);const o=n.getAttribute("data-id");c.getState().updateBlockData(a,e.getBlockIndex(a,o),e.getBlockData(o).data)}static updateBlockData(t,n,a){e.adoptStartingBlock(a);const o=e.getBlock(t);if(o){const t=o.querySelector(`.${N.classNames.block.content}`);t&&(t.innerHTML="");const i=e.renderTool(o.getAttribute("data-tool"),n,a);i&&t.appendChild(i)}c.getState().updateBlockData(a,e.getBlockIndex(a,t),n)}static destroy(t){if(!document.getElementById(t))return;const n=e.eventListenersMap[t];n&&(n.forEach(({element:e,event:t,handler:n})=>e.removeEventListener(t,n)),e.eventListenersMap[t]=[]),Zr.forEach(e=>e.input.destroy(t));for(const a of e.getBlocks(t))a.remove()}},ls=class e{static{this.eventListenersMap={}}static addEventListener(t,n,a,o){n.addEventListener(a,o);const i=e.eventListenersMap[t]||[];i.push({element:n,event:a,handler:o}),e.eventListenersMap[t]=i}static create(t){const n=c.getState().getInstance(t);if(!n)return console.error("ActionBar::create: Instance not found for containerId:",t);N.injectStyles("clepit-action-bar-styles","\n/* View Toggle */\n.clepit-action-bar {\n position: relative;\n z-index: 1000;\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: -14px; /* Position buttons so exactly half is inside and half outside */\n pointer-events: none;\n padding: 0 100px;\n}\n\n.clepit-action-bar-group {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-action-bar-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-action-bar-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-action-bar-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-action-bar-button:active {\n transform: scale(0.95);\n}\n\n.clepit-action-bar-button.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n/* Action Buttons */\n.clepit-view-actions {\n display: flex;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n overflow: hidden;\n padding: 4px;\n gap: 4px;\n}\n\n.clepit-view-action-button {\n width: 24px;\n height: 24px;\n border: none;\n border-radius: 4px;\n background: transparent;\n color: var(--clepit-text-muted);\n font-size: 14px;\n font-weight: bold;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n pointer-events: auto;\n}\n\n.clepit-view-action-button:first-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:last-child {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:not(:first-child):not(:last-child) {\n border-radius: 4px;\n}\n\n.clepit-view-action-button:hover {\n background: var(--clepit-toolbar-button-hover-bg, var(--clepit-selection-bg));\n color: var(--clepit-toolbar-button-hover-color, var(--clepit-primary));\n transform: scale(1.05);\n}\n\n.clepit-view-action-button:active {\n transform: scale(0.95);\n}\n\n/* Copy button feedback animation */\n.clepit-view-action-button--copy-feedback {\n transform: scale(0.95) !important;\n background-color: var(--clepit-success) !important;\n color: var(--clepit-bg) !important;\n}\n");const a=document.getElementById(t);if(!a)return;const o=!1!==n.config.hasViewSwitcher,i=!1!==n.config.hasDocumentActions;if(!o&&!i)return;const r=n.config.styles?.controls?.group,s=n.config.classNames?.controls?.group,l=n.config.styles?.controls?.button,d=n.config.classNames?.controls?.button,p=n.config.styles?.tooltips,u=n.config.classNames?.tooltips,m=O("div",N.classNames.actionBar.container);e.createButtonGroup(a,m,{buttonClassNames:d,buttonStyles:l,currentView:n.currentView,groupClassNames:s,groupStyles:r,hasDocumentActions:i,hasViewSwitcher:o,labels:n.config.controlLabels,tooltipClassNames:u,tooltipStyles:p}),a.insertBefore(m,a.firstChild)}static createButtonGroup(t,n,a){const o=(e,t)=>a.labels?.[e]||t,i=o("editView","Edit Mode"),r=o("previewView","Preview Mode"),s=o("jsonView","JSON Output"),l=o("copyJson","Copy JSON to Clipboard"),c=o("downloadJson","Download JSON File"),d=o("clearEditor","Clear Editor");if(a.hasViewSwitcher){const o=O("div",N.classNames.actionBar.group);N.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const l=O("button",N.classNames.actionBar.button,{"aria-label":i,"data-testid":"action-bar-edit-button","data-view":"edit",id:P(t.id,N.idSuffixes.actionBar.editButton),type:"button"});l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',N.applyStyling(l,{classNames:a.buttonClassNames,styles:a.buttonStyles});const c=O("button",N.classNames.actionBar.button,{"aria-label":r,"data-testid":"action-bar-preview-button","data-view":"preview",id:P(t.id,N.idSuffixes.actionBar.previewButton),type:"button"});c.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',N.applyStyling(c,{classNames:a.buttonClassNames,styles:a.buttonStyles});const d=O("button",N.classNames.actionBar.button,{"aria-label":s,"data-testid":"action-bar-json-button","data-view":"json",id:P(t.id,N.idSuffixes.actionBar.jsonButton),type:"button"});d.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14,2 14,8 20,8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10,9 9,9 8,9"/></svg>',N.applyStyling(d,{classNames:a.buttonClassNames,styles:a.buttonStyles}),"edit"===a.currentView?l.classList.add("active"):"preview"===a.currentView?c.classList.add("active"):"json"===a.currentView&&d.classList.add("active"),e.addEventListener(t.id,l,"click",e.handleViewChange),e.addEventListener(t.id,c,"click",e.handleViewChange),e.addEventListener(t.id,d,"click",e.handleViewChange),o.appendChild(l),o.appendChild(c),o.appendChild(d),n.appendChild(o),me(l,i,"above",a.tooltipClassNames,a.tooltipStyles),me(c,r,"above",a.tooltipClassNames,a.tooltipStyles),me(d,s,"above",a.tooltipClassNames,a.tooltipStyles)}if(a.hasDocumentActions){const o=O("div",N.classNames.actionBar.action);N.applyStyling(o,{classNames:a.groupClassNames,styles:a.groupStyles});const i=O("button",N.classNames.actionBar.actionButton,{"aria-label":l,"data-testid":"view-copy-button",id:P(t.id,N.idSuffixes.actionBar.copyButton),type:"button"});i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',N.applyStyling(i,{classNames:a.buttonClassNames,styles:a.buttonStyles});const r=O("button",N.classNames.actionBar.actionButton,{"aria-label":c,"data-testid":"view-download-button",id:P(t.id,N.idSuffixes.actionBar.downloadButton),type:"button"});r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',N.applyStyling(r,{classNames:a.buttonClassNames,styles:a.buttonStyles});const s=O("button",N.classNames.actionBar.actionButton,{"aria-label":d,"data-testid":"view-clear-button",id:P(t.id,N.idSuffixes.actionBar.clearButton),type:"button"});s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',N.applyStyling(s,{classNames:a.buttonClassNames,styles:a.buttonStyles}),e.addEventListener(t.id,i,"click",e.handleCopyJson),e.addEventListener(t.id,r,"click",e.handleDownloadJson),e.addEventListener(t.id,s,"click",e.handleClearEditor),o.appendChild(i),o.appendChild(r),o.appendChild(s),n.appendChild(o),me(i,l,"above",a.tooltipClassNames,a.tooltipStyles),me(r,c,"above",a.tooltipClassNames,a.tooltipStyles),me(s,d,"above",a.tooltipClassNames,a.tooltipStyles)}}static getCurrentView(e){const t=document.getElementById(e);if(!t)return console.error("ActionBar::getCurrentView: Container not found for containerId:",e),null;const n=t.querySelector(`.${N.classNames.actionBar.group}`);if(!n)return console.error("ActionBar::getCurrentView: View toggle group not found for container:",t.id),null;const a=n.querySelector(".active");return a?a.getAttribute("data-view"):(console.error("ActionBar::getCurrentView: Active button not found for container:",t.id),null)}static updateButtonStates(e,t){const n=document.getElementById(e);if(!n)return;const a=n.querySelector(`.${N.classNames.actionBar.container}`);a&&a.querySelectorAll(`#${P(e,N.idSuffixes.actionBar.editButton)}, #${P(e,N.idSuffixes.actionBar.previewButton)}, #${P(e,N.idSuffixes.actionBar.jsonButton)}`).forEach(e=>{e.getAttribute("data-view")===t?e.classList.add("active"):e.classList.remove("active")})}static handleViewChange(t){const n=t.currentTarget,a=ss.getEditorId(n);if(!a)return;const o=n.getAttribute("data-view");o&&(c.getState().setCurrentView(a,o),e.updateButtonStates(a,o))}static handleCopyJson(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=c.getState().getInstance(n);a&&(navigator.clipboard.writeText(JSON.stringify(a.data,null,2)),t.classList.add(N.classNames.actionBar.copyFeedback),setTimeout(()=>t.classList.remove(N.classNames.actionBar.copyFeedback),200))}static handleClearEditor(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=c.getState().getInstance(n)?.config.onClearRequest;a?a().then(e=>{e&&ss.resetBlocks(n)},e=>console.error("Clear was not confirmed, the page is unchanged:",e)):ss.resetBlocks(n)}static handleDownloadJson(e){const t=e.currentTarget,n=ss.getEditorId(t);if(!n)return;const a=ss.getBlocks(n).map(e=>ss.getBlockData(e.getAttribute("data-id"))),o=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${n}--content.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}static destroy(e){const t=document.getElementById(e);if(!t)return;const n=t.querySelector(`.${N.classNames.actionBar.container}`);n&&n.remove()}},cs=`\n/* Editor Container */\n.${N.classNames.editor.container} {\n position: relative;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n line-height: 1.6;\n color: var(--clepit-text);\n padding: 20px; /* Normal padding - no extra left padding needed */\n outline: none;\n box-sizing: border-box;\n width: 100%;\n}\n\n.${N.classNames.editor.container}:focus {\n outline: none;\n}\n\n.${N.classNames.editor.container}[data-readonly="true"] {\n background: var(--clepit-surface);\n color: var(--clepit-text-muted);\n cursor: not-allowed;\n}\n\n/* Editor Content Container */\n.${N.classNames.editor.content} {\n border: 1px solid var(--clepit-border);\n border-radius: 4px;\n overflow-y: auto;\n padding: 16px 24px; /* Increased horizontal padding for better preview content spacing */\n background: var(--clepit-bg);\n height: 100%;\n max-height: var(--clepit-max-height, 410px);\n min-height: var(--clepit-min-height, 200px);\n}\n\n/* JSON Output */\n.${N.classNames.editor.jsonOutput} {\n margin: 0;\n padding: 16px;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 13px;\n line-height: 1.4;\n color: var(--clepit-text); /* default readonly is black */\n overflow-x: auto;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: none;\n min-height: 100%;\n}\n\n.${N.classNames.editor.jsonOutput}:focus {\n outline: none;\n}\n\n/* Editable (allowed) -> green text */\n.${N.classNames.editor.jsonOutput}.clepit-json-editable {\n color: var(--clepit-success);\n}\n\n/* Invalid JSON -> red text */\n.${N.classNames.editor.jsonOutput}.clepit-json-error {\n color: var(--clepit-error);\n background-color: transparent;\n}\n\n.${N.classNames.editor.jsonEmpty} {\n padding: 16px;\n text-align: center;\n color: var(--clepit-text-muted);\n font-style: italic;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* Container and content each carried their own inset, so a phone spent 80px\n * of a ~400px editor on nested padding before a single character. */\n .${N.classNames.editor.container} {\n padding: 8px;\n }\n\n .${N.classNames.editor.content} {\n padding: 12px;\n }\n}\n`,ds=class e{static{this.timers={}}static{this.focusHandlers={}}static start(t){if(e.stop(t),!(c.getState().getInstance(t)?.config)?.resolveIssues)return;e.run(t),e.timers[t]=setInterval(()=>{e.run(t)},3e5);const n=()=>{e.run(t)};window.addEventListener("focus",n),e.focusHandlers[t]=n}static stop(t){const n=e.timers[t];n&&clearInterval(n),delete e.timers[t];const a=e.focusHandlers[t];a&&window.removeEventListener("focus",a),delete e.focusHandlers[t]}static urls(e){const t=document.getElementById(e);if(!t)return[];const n=/* @__PURE__ */new Set;for(const a of Te.collect(t))n.add(Te.read(a).url);for(const a of ss.getBlocks(e)){if("embed"!==a.getAttribute("data-tool"))continue;const e=at.save(a);e.issue&&n.add(e.url)}return n.delete(""),[...n]}static async run(t){const n=e.urls(t);if(0===n.length)return;const a=await ot(t,n),o=document.getElementById(t),i=c.getState().getInstance(t)?.config;if(o&&i&&0!==Object.keys(a).length){Te.refreshAll(o,a,i.issueLabels);for(const e of ss.getBlocks(t)){if("embed"!==e.getAttribute("data-tool"))continue;const n=at.save(e),o=n.issue?a[n.url]:void 0;o&&at.refreshIssue(e,t,o)}Nr.refresh(t,a)}}},ps=class{static render(e){const t=c.getState().getInstance(e);t&&(ln.create(e),N.injectStyles("clepit-block-manager-styles",'\n/* Blocks */\n.clepit-block {\n position: relative;\n margin: var(--block-margin-top, 8px) 0 var(--block-margin-bottom, 16px) 0;\n padding: 8px 0;\n padding-left: 54px;\n border-radius: 4px;\n transition: background-color 0.2s ease;\n display: flex;\n align-items: flex-start;\n gap: 6px;\n}\n\n.clepit-block:hover {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block--active {\n background-color: var(--clepit-block-highlight-bg);\n}\n\n.clepit-block-content {\n outline: none;\n min-height: 1.2em;\n flex: 1;\n min-width: 0; /* Allow content to shrink */\n}\n\n/* Remove focus outline from editable elements */\n.clepit-block-content [contenteditable="true"] {\n outline: none;\n}\n\n/* Placeholder styles for all text elements */\n.clepit-block-content:empty::before {\n content: attr(data-placeholder);\n color: var(--clepit-text-subtle);\n pointer-events: none;\n font-style: italic;\n}\n\n/* Menu animation classes */\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Block Operations Menu */\n.clepit-block-operations-menu {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 200px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-operations-menu--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-operations-menu--hidden {\n display: none;\n}\n\n/* Block Type Selector */\n.clepit-block-type-selector {\n position: absolute;\n top: 100%;\n left: 0;\n z-index: 1001;\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 150px;\n margin-top: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-block-type-selector--visible {\n display: block;\n transform: translateY(0);\n}\n\n.clepit-block-type-selector--hidden {\n display: none;\n}\n\n/* Default menu item styles - package doesn\'t care about theme */\n.clepit-menu-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.clepit-menu-item .clepit-menu-icon {\n width: 16px;\n height: 16px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n}\n\n.clepit-menu-item:hover {\n background-color: var(--clepit-selection-bg);\n}\n\n.clepit-menu-item.active {\n background-color: var(--clepit-primary-bg);\n color: var(--clepit-primary);\n font-weight: bold;\n}\n\n.clepit-menu-item--danger {\n color: var(--clepit-error);\n}\n\n/* Block type menu items - match font size with operations menu */\n.clepit-block-type-item {\n font-size: 14px;\n}\n\n/* Default menu divider styles */\n.clepit-menu-divider {\n height: 1px;\n background: linear-gradient(to right, transparent, var(--clepit-border), transparent);\n margin: 8px 0;\n}\n\n/* Default menu arrow styles */\n.clepit-menu-arrow {\n margin-left: auto;\n font-size: 12px;\n color: var(--clepit-text-muted);\n}\n\n/* Input styles for block type selector */\n.clepit-block-type-selector input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-type-selector input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-type-selector input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-type-selector-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-menu-icon {\n font-size: 14px;\n min-width: 20px;\n text-align: center;\n font-weight: bold;\n}\n\n.clepit-menu-shortcut {\n margin-left: auto;\n font-size: 9px;\n color: var(--clepit-text-muted);\n opacity: 0.7;\n}\n\n.clepit-menu-positioned {\n position: absolute;\n z-index: 1001;\n top: var(--menu-top, 0);\n left: var(--menu-left, 0);\n}\n\n/* The block menus are popovers in the top layer. Anchor positioning puts them\n * under the block toolbar without JavaScript measuring anything.\n *\n * Guarded: anchor positioning is Baseline 2026 (Chrome 125+, Firefox 132+,\n * Safari 18.2+), roughly 91% of traffic. Browsers without it get the popover\'s\n * default centred placement rather than a second JS positioning path — the menu\n * stays usable, just not adjacent to its button. */\n.clepit-block-type-selector:popover-open,\n.clepit-block-operations-menu:popover-open {\n /* The base menu rules above still say display:none from the pre-popover\n * mechanism, and an author rule outranks the UA\'s popover reveal. Without\n * an explicit display here every menu opens into the top layer invisible. */\n display: block;\n margin: 0;\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n background: var(--clepit-bg);\n padding: 8px;\n overflow: visible;\n}\n\n.clepit-convert-submenu:popover-open {\n display: block;\n}\n\n@supports (anchor-name: --a) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-anchor: --clepit-block-toolbar;\n position-area: block-end span-inline-end;\n margin-block-start: 5px;\n inset: auto;\n }\n}\n\n@supports (position-try-fallbacks: flip-block) {\n .clepit-block-type-selector:popover-open,\n .clepit-block-operations-menu:popover-open {\n position-try-fallbacks: flip-block;\n }\n}\n\n/* Convert Submenu */\n@supports (anchor-name: --a) {\n .clepit-convert-submenu:popover-open {\n position: fixed;\n position-area: inline-end span-block-end;\n margin: 0 0 0 4px;\n inset: auto;\n }\n\n .clepit-convert-submenu:popover-open {\n position-try-fallbacks: flip-inline;\n }\n}\n\n.clepit-convert-submenu {\n position: absolute;\n top: var(--submenu-top, 0);\n left: var(--submenu-left, 100%);\n z-index: var(--submenu-z-index, 1002);\n background: var(--clepit-bg);\n border: 1px solid var(--clepit-border);\n border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n padding: 8px;\n min-width: 140px;\n margin-left: 4px;\n display: none;\n transition: transform 0.2s ease;\n}\n\n.clepit-convert-submenu--visible {\n display: block;\n opacity: 1;\n transform: translateX(0);\n}\n\n.clepit-convert-submenu--hidden {\n display: none;\n opacity: 0;\n transform: translateX(-10px);\n}\n\n/* Input styles for convert submenu */\n.clepit-convert-submenu input {\n width: 100%;\n padding: 6px 8px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 12px;\n outline: none;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-convert-submenu input:focus {\n border-color: var(--clepit-input-focus-border, var(--clepit-primary));\n box-shadow: 0 0 0 2px var(--clepit-input-focus-shadow, var(--clepit-primary-bg));\n}\n\n.clepit-convert-submenu input::placeholder {\n color: var(--clepit-input-placeholder, var(--clepit-text-subtle));\n}\n\n.clepit-convert-submenu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-block-operation-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Input styles for operations menu */\n.clepit-block-operations-menu input {\n width: 100%;\n padding: 8px 12px;\n border: 1px solid var(--clepit-input-border, var(--clepit-border));\n border-radius: 4px;\n font-size: 14px;\n margin-bottom: 8px;\n outline: none;\n transition: border-color 0.2s;\n background-color: var(--input-bg, var(--clepit-bg));\n color: var(--input-color, var(--clepit-text));\n}\n\n.clepit-block-operations-menu input:focus {\n border-color: var(--clepit-primary);\n box-shadow: 0 0 0 2px var(--clepit-primary-bg);\n}\n\n.clepit-block-operations-menu input::placeholder {\n color: var(--placeholder-color, var(--clepit-text-subtle));\n}\n\n.clepit-block-operations-menu-items {\n max-height: 200px;\n overflow-y: auto;\n}\n\n.clepit-block-operation-item[data-operation="delete"] {\n color: var(--clepit-error);\n}\n\n/* Convert submenu items */\n.clepit-convert-option-item {\n padding: 8px 12px;\n cursor: pointer;\n border-radius: 4px;\n transition: background-color 0.2s;\n font-size: 14px;\n}\n\n.clepit-convert-option-item:hover {\n background-color: var(--clepit-hover-bg, var(--clepit-selection-bg));\n}\n\n/* Indentation */\n.clepit-block[data-indent="1"] .clepit-block-content {\n margin-left: 20px;\n}\n\n.clepit-block[data-indent="2"] .clepit-block-content {\n margin-left: 40px;\n}\n\n.clepit-block[data-indent="3"] .clepit-block-content {\n margin-left: 60px;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n /* The 54px gutter exists to hold the block toolbar, which is only ever\n * displayed on the active block. On a phone that reserved a seventh of the\n * editor\'s width on every idle block at once, pushing the text into a narrow\n * column with empty space either side. Give the width back and let the\n * gutter open only under the block whose toolbar is actually showing. */\n /* No transition on padding-left. The block element is re-created as you\n * interact with it, so an animated gutter restarts from 0 every time and\n * never reaches its end value — the toolbar would sit on top of the text. */\n .clepit-block {\n padding-left: 0;\n }\n\n .clepit-block--active,\n .clepit-block:focus-within,\n .clepit-block:has(.clepit-block-toolbar--visible) {\n padding-left: 54px;\n }\n}\n'),ss.renderBlocks(t.data.blocks,e))}},us=class e{static render(t){const n=c.getState().getInstance(t);if(!n)return;const a=document.getElementById(n.contentId);if(a)if(a.innerHTML="",n.data&&n.data.blocks&&n.data.blocks.length>0){const t=N.createStyledElement("pre",N.classNames.editor.jsonOutput);t.textContent=JSON.stringify(n.data,null,2),t.setAttribute("data-testid","json-editable-textarea"),n.config.allowJsonViewEditing&&(t.setAttribute("contenteditable","true"),t.classList.add(N.classNames.editor.jsonEditable),setTimeout(()=>t.focus(),0),e.addEventListeners(t)),a.appendChild(t)}else{const e=N.createStyledElement("div",N.classNames.editor.jsonEmpty);e.textContent="No content to display",a.appendChild(e)}}static addEventListeners(t){t.addEventListener("input",e.handleJsonInput),t.addEventListener("blur",e.validateAndUpdateJson),t.addEventListener("keydown",e.validateAndUpdateJson)}static removeEventListeners(t){t.removeEventListener("input",e.handleJsonInput),t.removeEventListener("blur",e.validateAndUpdateJson),t.removeEventListener("keydown",e.validateAndUpdateJson)}static handleJsonInput(e){const t=e.target,n=t.textContent||"",a=ss.getEditorId(t);if(a)try{const e=JSON.parse(n);if("object"==typeof e&&null!==e){e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);const t=c.getState().getInstance(a);if(t){const n=document.querySelector(`#${t.contentId} .${N.classNames.editor.jsonOutput}`);n&&(n.classList.remove(N.classNames.editor.jsonError),t.config.allowJsonViewEditing&&n.classList.add("clepit-json-editable"));const o=t.currentView;c.getState().setData(a,e),"json"===o&&c.getState().setCurrentView(a,"json"),console.log("Store updated successfully")}}}catch{const e=c.getState().getInstance(a);if(e){const t=document.querySelector(`#${e.contentId} .${N.classNames.editor.jsonOutput}`);t&&(t.classList.add("clepit-json-error"),t.classList.remove("clepit-json-editable"))}}}static validateAndUpdateJson(e){const t=e.target,n=t.textContent||"",a=ss.getEditorId(t);if(!a)return;const o=c.getState().getInstance(a);if(o)try{const e=JSON.parse(n);if("object"!=typeof e||null===e)throw new Error("Invalid JSON structure");{e.blocks&&Array.isArray(e.blocks)||(e.blocks=[]);try{ln.hide(a),rs.hide(a)}catch{}const t=o.currentView;c.getState().setData(a,e),"json"===t&&c.getState().setCurrentView(a,"json");const n=document.querySelector(`#${o.contentId} .${N.classNames.editor.jsonOutput}`);n&&(n.classList.remove("clepit-json-error"),o.config.allowJsonViewEditing?n.classList.add("clepit-json-editable"):n.classList.remove("clepit-json-editable")),o.config.onChange&&o.config.onChange(e)}}catch{const e=document.querySelector(`#${o.contentId} .${N.classNames.editor.jsonOutput}`);e&&(e.classList.add("clepit-json-error"),e.classList.remove("clepit-json-editable"))}}static destroy(t){const n=c.getState().getInstance(t);if(!n)return;const a=document.querySelector(`#${n.contentId} .${N.classNames.editor.jsonOutput}`);a&&e.removeEventListeners(a)}},ms=/* @__PURE__ */new Set(["alert.html","audio.alt","audio.caption","checklist.items","header.html","image.alt","image.caption","list.items","paragraph.html","quote.html","table.caption","table.data","video.alt","video.caption"]),hs=(e,t)=>ms.has(`${e}.${t}`),gs=/* @__PURE__ */new Set(["checklist.items","list.items","table.data"]),bs=(e,t)=>gs.has(`${e}.${t}`),fs=(e,t,n,a)=>{if(!Array.isArray(t))return t;let o=!1;const i=e=>{const t=((e,t,n)=>{const a=vs(e,t,n);return null===a?e:a.value})(e,n,a);return t!==e&&(o=!0),t},r=t.map(t=>{if("table"===e)return Array.isArray(t)?t.map(i):t;if("checklist"===e){if("object"!=typeof t||null===t)return t;const e=t,n=i(e.text);return n===e.text?t:{...e,text:n}}return i(t)});return o?r:t},ys=(e,t,n,a)=>{let o=!1;const i={};for(const[r,s]of Object.entries(t)){if(bs(e,r)){const t=fs(e,s,n,a);i[r]=t,t!==s&&(o=!0);continue}if(!hs(e,r)){i[r]=s;continue}const t=vs(s,n,a);null!==t?(i[r]=t.value,t.value!==s&&(o=!0)):i[r]=s}return o?i:t},vs=(e,t,n)=>{if(void 0===e)return null;if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return{isFallback:t!==n,locale:n,value:e};const a=e[t];if(void 0!==a)return{isFallback:!1,locale:t,value:a};const o=e[n];if(void 0!==o)return{isFallback:!0,locale:n,value:o};const i=Object.keys(e).sort()[0];return void 0===i?null:{isFallback:!0,locale:i,value:e[i]}},xs="clepit-theme-styles",ks=".clepit-editor, .clepit-renderer-content, body[data-clepit-theme]",ws=`@layer clepit.reset, clepit.tokens, clepit.blocks, clepit.overrides;\n\n${is=S,Object.keys(A).map(e=>`@property ${A[e]} {\n syntax: '<color>';\n inherits: true;\n initial-value: ${is[e]};\n}`).join("\n\n")}\n\n@layer clepit.tokens {\n${E(S,{bg:"#161b22",blockHighlightBg:"rgba(0, 0, 0, 0.25)",border:"rgba(240, 246, 252, 0.1)",borderSubtle:"rgba(240, 246, 252, 0.06)",codeBg:"#1e242c",codeBorder:"rgba(240, 246, 252, 0.10)",codeComment:"rgba(240, 246, 252, 0.42)",codeFunction:"#d2a8ff",codeGutter:"rgba(240, 246, 252, 0.42)",codeKeyword:"#ff7b72",codeNumber:"#79c0ff",codePunctuation:"rgba(240, 246, 252, 0.62)",codeSelectionBg:"rgba(124, 124, 255, 0.18)",codeString:"#7ee787",codeText:"rgba(240, 246, 252, 0.92)",codeType:"#ffa657",error:"#f87171",errorBg:"rgba(248, 113, 113, 0.12)",info:"#60a5fa",infoBg:"rgba(96, 165, 250, 0.12)",marker:"rgba(255, 224, 71, 0.28)",primary:"#7c7cff",primaryBg:"rgba(124, 124, 255, 0.14)",primaryHover:"#9494ff",selectionBg:"rgba(124, 124, 255, 0.18)",success:"#4ade80",successBg:"rgba(74, 222, 128, 0.12)",surface:"#1c222a",surface2:"#222a33",text:"rgba(240, 246, 252, 0.92)",textMuted:"rgba(240, 246, 252, 0.62)",textSubtle:"rgba(240, 246, 252, 0.42)",warning:"#fbbf24",warningBg:"rgba(251, 191, 36, 0.12)"},ks)}\n\n${ks} {\n color-scheme: light;\n}\n\n.clepit-editor[data-clepit-theme='auto'], .clepit-renderer-content[data-clepit-theme='auto'], body[data-clepit-theme='auto'] {\n color-scheme: light dark;\n}\n\n.clepit-editor[data-clepit-theme='dark'], .clepit-renderer-content[data-clepit-theme='dark'], body[data-clepit-theme='dark'] {\n color-scheme: dark;\n}\n\n.clepit-editor[data-clepit-theme='light'], .clepit-renderer-content[data-clepit-theme='light'], body[data-clepit-theme='light'] {\n color-scheme: light;\n}\n}\n\n@layer clepit.blocks {\n[data-clepit-block-id]:target {\n background: var(--clepit-block-highlight-bg);\n border-radius: 6px;\n scroll-margin-top: 24px;\n}\n}\n`,Cs=class e{static render(t){const n=document.getElementById(t.containerId);if(!n)throw new Error(`Container element with ID '${t.containerId}' not found`);return N.injectStyles(xs,ws),N.injectStyles(zt,Ht),N.injectStyles(fe,ye),n.classList.add(N.classNames.renderer.content),N.registerEditor(t.containerId,t.theme??"auto",t.themeOverrides),n.innerHTML="",Te.applyParts(n,t.issueChip),t.data?.blocks&&Array.isArray(t.data.blocks)?(t.data.blocks.forEach((a,o)=>{const i=e.renderBlock(e.localize(a,t),o,t);i&&n.appendChild(i)}),t.issues&&Te.refreshAll(n,t.issues,t.issueLabels),n):n}static localize(e,t){if(!t.locale)return e;const n=ys(e.type,e.data,t.locale,t.defaultLocale??t.locale);return n===e.data?e:{...e,data:n}}static renderBlock(e,t,n){const a=O("div",N.classNames.block.output);a.setAttribute("data-block-type",e.type),a.setAttribute("data-block-index",t.toString()),e.tunes&&Object.entries(e.tunes).forEach(([e,t])=>{a.setAttribute(`data-tune-${e}`,String(t))});const o=n.styles?.[e.type],i=n.classNames?.[e.type];let r,s,l,c=n.configs?.[e.type];if("paragraph"===e.type&&n.editorClassNames?.tooltips&&(c={...c,tooltipClassNames:n.editorClassNames.tooltips}),c?.margins&&(r=c.margins.top,s=c.margins.bottom),void 0===r&&void 0!==n.margins?.top&&(r=n.margins.top),void 0===s&&void 0!==n.margins?.bottom&&(s=n.margins.bottom),void 0!==r){const e=parseFloat(a.style.marginTop||"0")||0;a.style.marginTop=`${e+r}px`}if(void 0!==s){const e=parseFloat(a.style.marginBottom||"0")||0;a.style.marginBottom=`${e+s}px`}switch(e.type){case"alert":l=bn.render(e.data,c,o,i);break;case"audio":l=kn.render(e.data,c,o,i);break;case"code":l=be.render(e.data,c,o,i);break;case"collapsible":l=ar.render(e.data,c,o,i);break;case"columns":l=Pn.render(e.data,c,o,i);break;case"date":l=Kn.render(e.data,c,o,i);break;case"delimiter":l=Xn.render(e.data,c,o,i);break;case"collection":l=jn.render(e.data,c,o,i);break;case"updates":l=Ji.render(e.data,c,o,i);break;case"glance":l=la.render(e.data,c,o,i);break;case"embed":l=Xe.render(e.data,{...c,issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"sketch":l=ho.render(e.data,c,o,i);break;case"latex":l=Ui.render(e.data,c,o,i);break;case"mermaid":l=Vi.render(e.data,c,o,i);break;case"openapi":l=Qa.render(e.data,c,o,i);break;case"doc_card":l=ea.render(e.data,c,o,i);break;case"file":l=ia.render(e.data,c,o,i);break;case"header":l=pa.render(e.data,c,o,i);break;case"image":l=ba.render(e.data,c,o,i);break;case"list":l=Ca.render(e.data,c,o,i);break;case"checklist":l=En.render(e.data,c,o,i);break;case"paragraph":l=no.render(e.data,c,o,i);break;case"quote":l=ro.render(e.data,c,o,i);break;case"table":l=ko.render(e.data,c,o,i);break;case"toc":l=Eo.render(e.data,{...c,documentBlocks:n.data?.blocks??[]},o,i);break;case"issues":l=xa.render(e.data,{...c,documentBlocks:n.data?.blocks??[],issueLabels:n.issueLabels,issues:n.issues},o,i);break;case"video":l=Qi.render(e.data,c,o,i);break;default:l=null}return l?(a.appendChild(l),Jt.initializeElements(a,{classNames:n.classNames?.tooltip,styles:n.styles?.tooltip}),a):null}},Ss=class{static render(e){const t=c.getState().getInstance(e);t&&Cs.render({classNames:t.config.classNames?.blocks,containerId:t.contentId,data:t.data,editorClassNames:t.config.classNames,margins:t.config.margins,styles:t.config.styles?.blocks})}},As=class e{static create(t){return e.teardown(t.containerId),e.initialize(t),ls.create(t.containerId),e.render(t.containerId),mn.addListeners(t.containerId),ds.start(t.containerId),c.getState().setIsReady(t.containerId,!0),c.subscribe(e=>e.instances,(n,a)=>{const o=n[t.containerId];if(!o)return;const i=a[t.containerId];i&&o.currentView!==i.currentView&&e.render(t.containerId)}),{blocks:{convert:(e,n)=>ss.convertBlock(e,n,t.containerId),count:()=>ss.getBlocks(t.containerId).length,get:e=>ss.getBlock(e)?ss.getBlockData(e):null,getAll:()=>ss.getBlocks(t.containerId).map(e=>ss.getBlockData(e.getAttribute("data-id"))),insert:(e,n,a,o)=>ss.insertBlock({data:n,id:o??Math.random().toString(36).substring(2,11),type:e},t.containerId,a),move:(e,n)=>ss.moveBlock(t.containerId,e,n),remove:e=>ss.removeBlock(t.containerId,e),update:(e,n)=>ss.updateBlockData(e,n,t.containerId)},blur:()=>{const e=document.activeElement;e&&document.getElementById(t.containerId)?.contains(e)&&e.blur()},data:{clear:()=>{c.getState().clearData(t.containerId),ss.destroy(t.containerId)},clearContent:()=>ss.destroy(t.containerId),clearStorage:()=>c.getState().clearData(t.containerId),extract:()=>ss.extractData(t.containerId),set:e=>ss.setBlocks(e.blocks,t.containerId)},destroy:()=>e.destroy(t.containerId),focus:()=>{const e=ss.getBlocks(t.containerId)[0];e&&ss.focusBlock(e)},selection:{clear:()=>window.getSelection()?.removeAllRanges(),get:()=>window.getSelection(),set:e=>{const t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e.getRangeAt(0)))}},ui:{hideBlockMenu:()=>rs.hide(t.containerId),hideToolbar:()=>ln.hide(t.containerId),showBlockMenu:e=>rs.show(t.containerId,e),showToolbar:(e,n)=>ln.show(t.containerId,e,n)},view:{getCurrentView:e=>c.getState().getCurrentView(e),switchView:(e,t)=>c.getState().setCurrentView(e,t)}}}static initialize(t){console.info("Editor::initialize: Creating editor instance for containerId:",t.containerId);const n=document.getElementById(t.containerId);if(!n)throw`Unable to find container with ID ${t.containerId}`;N.injectStyles(xs,ws),N.injectStyles("clepit-editor-container-styles",cs),N.injectStyles(Bt,$t),N.injectStyles(Wt,Kt),N.injectStyles(Dt,qt),N.injectStyles(fe,ye);const a={allowJsonViewEditing:!1,initialView:"edit",maxHeight:0,minHeight:300,placeholder:"Start writing...",...t};n.className=N.classNames.editor.container,n.setAttribute("contenteditable","false"),Te.applyParts(n,a.issueChip),N.registerEditor(t.containerId,a.theme??"auto",a.themeOverrides),a.minHeight&&n.style.setProperty("--clepit-min-height",`${a.minHeight}px`),a.maxHeight&&n.style.setProperty("--clepit-max-height",`${a.maxHeight}px`),N.applyStyles(n,a.styles?.container),N.applyClassNames(n,a.classNames?.container),a.margins&&(void 0!==a.margins.top&&n.style.setProperty("--block-margin-top",`${a.margins.top}px`),void 0!==a.margins.bottom&&n.style.setProperty("--block-margin-bottom",`${a.margins.bottom}px`));const o=`${a.containerId}-${N.idSuffixes.editorContent}`,i=O("div",N.classNames.editor.content);i.id=o,i.setAttribute("data-testid","editor-content-container"),i.setAttribute("data-container-id",t.containerId),N.applyStyles(i,a.styles?.editorContent),N.applyClassNames(i,a.classNames?.editorContent),n.appendChild(i),c.getState().addInstance(t.containerId,{config:a,contentId:o,currentView:a.initialView||"edit",data:e.localizeData(a.initialData,a),isReady:!1})}static localizeData(e,t){const n=e||{blocks:[],time:Date.now(),version:"1.0.0"},a=t.locale;if(!a)return n;const o=t.defaultLocale??a;return{...n,blocks:n.blocks.map(e=>{const n=e.data;for(const r of(e=>Array.from(ms).filter(t=>t.startsWith(`${e}.`)).map(t=>t.slice(e.length+1)).sort())(e.type)){const i=vs(n[r],a,o);i?.isFallback&&t.onLocaleFallback?.({blockId:e.id??"",field:r,requested:a,showing:i.locale})}const i=ys(e.type,n,a,o);return i===n?e:{...e,data:i}})}}static render(e){const t=c.getState().getInstance(e);if(!t)return;const n=document.getElementById(t.contentId);n&&(us.destroy(e),n.innerHTML=""),"edit"===t.currentView?ps.render(e):"preview"===t.currentView?Ss.render(e):"json"===t.currentView&&us.render(e),t.config.onReady&&t.config.onReady()}static teardown(e){ds.stop(e),un.dismiss(e),mn.removeListeners(e),ls.destroy(e),rs.destroy(e),ln.destroy(e),ss.destroy(e),N.unregisterEditor(e);const t=document.getElementById(e);t&&(t.innerHTML="")}static destroy(t){e.teardown(t),c.getState().removeInstance(t)}},Es=e=>e.replace(/["\\]/g,"\\$&"),Ns=e=>e.flatMap(e=>"collapsible"===e.type?[e,...Ns(e.data.children??[])]:"columns"===e.type?[e,...Ns(e.data.columns?.flat()??[])]:[e]),Ls=(e,t)=>{const n=[];for(const a of Ns(t)){if(!a.id)continue;if("code"!==a.type&&"openapi"!==a.type&&"table"!==a.type)continue;const t=e.querySelector(`[data-clepit-block-id="${Es(a.id)}"]`);if(!t||t.hasAttribute("data-clepit-activated"))continue;t.setAttribute("data-clepit-activated","");const o="code"===a.type?be.activate(t,a.data):"openapi"===a.type?Qa.activate(t):ko.activate(t,a.data);n.push(()=>{o(),t.removeAttribute("data-clepit-activated")})}return()=>{for(const e of n)e()}},Bs=/* @__PURE__ */new Set(["strong","b","em","i","u","s","del","mark","code","a","span"]),$s=/* @__PURE__ */new Set(["href","target","title","contenteditable","data-tooltip","data-status","data-status-variant","data-user-id","data-page-id","data-issue-tool","data-issue-key","data-issue-title","data-issue-state","data-issue-category","data-issue-assignee","data-issue-avatar","data-issue-updated","data-issue-url","data-issue-pull","data-issue-reason","class"]),Is=/* @__PURE__ */new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Ts=/([a-zA-Z_:][-a-zA-Z0-9_:.]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g,Ms=e=>{const t=/* @__PURE__ */new Map;Ts.lastIndex=0;let n=Ts.exec(e);for(;null!==n;)t.set(n[1].toLowerCase(),n[2]??n[3]??n[4]??""),n=Ts.exec(e);return t},_s=e=>{const t=e.trim().toLowerCase().replace(/[\x00-\x20]/g,"");return!t.startsWith("javascript:")&&!t.startsWith("data:")&&!t.startsWith("vbscript:")},Ds=e=>{if(!e)return"";const t=[],n=[];for(const a of(e=>{const t=[],n=/<\/?([a-zA-Z][a-zA-Z0-9-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;let a=0,o=n.exec(e);for(;null!==o;){o.index>a&&t.push({type:"text",value:e.slice(a,o.index)});const i=o[1].toLowerCase();o[0].startsWith("</")?t.push({tag:i,type:"close"}):t.push({attributes:Ms(o[2]??""),selfClosing:(o[2]??"").trimEnd().endsWith("/"),tag:i,type:"open"}),a=o.index+o[0].length,o=n.exec(e)}return a<e.length&&t.push({type:"text",value:e.slice(a)}),t})(e)){if("text"===a.type){t.push(a.value);continue}if("close"===a.type){if(!Bs.has(a.tag))continue;const e=n.lastIndexOf(a.tag);if(-1===e)continue;t.push(`</${a.tag}>`),n.splice(e,1);continue}if(!Bs.has(a.tag))continue;const e=[];for(const[t,n]of a.attributes)$s.has(t)&&("href"!==t||_s(n))&&e.push(`${t}="${D(n)}"`);"a"===a.tag&&e.push('target="_blank"','rel="noopener noreferrer"'),t.push(`<${[a.tag,...e].join(" ")}>`),a.selfClosing||Is.has(a.tag)||n.push(a.tag)}for(const a of[...n].reverse())t.push(`</${a}>`);return t.join("")},qs=()=>".clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}",js=e=>`<aside class="clepit-public-page__notice" data-testid="public-page-notice" role="note"><p class="clepit-public-page__notice-title">${_(e.title)}</p><p class="clepit-public-page__notice-body">${_(e.body)}</p></aside>`,zs=e=>[e.description?`<meta name="description" content="${D(e.description)}">`:"",e.canonicalUrl?`<link rel="canonical" href="${D(e.canonicalUrl)}">`:"",...(e.alternates??[]).map(e=>`<link rel="alternate" hreflang="${D(e.hreflang)}" href="${D(e.href)}">`),`<meta property="og:title" content="${D(e.title)}">`,e.description?`<meta property="og:description" content="${D(e.description)}">`:""].join(""),Hs=()=>[ws,hn,vn,Sn,Z,se(),In,qn,On,Un,Gn,Qn,$,aa,ra,ca,ma,ye,ka,Sa,eo,oo,co,bo,So,Bo,Gi,Zi].join("\n"),Os=(e,t)=>{const n=j(Ds),a={...t,documentBlocks:t?.documentBlocks??e},o=e.map(e=>er(e,n,a)).filter(e=>null!==e).map(e=>z(e)).join("\n");return je(o,t?.issues,t?.issueChip,t?.issueLabels,Ds)},Ps=(e,t)=>{const n=_(e.title),a=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',e.scheme?`<meta name="color-scheme" content="${D(e.scheme)}">`:"",`<title>${n}</title>`,zs(e),`<style>${Hs()}</style>`,e.notice?"<style>.clepit-public-page__notice{display:flex;flex-direction:column;gap:4px;margin:0 0 16px;padding:8px 12px;background:color-mix(in oklab, var(--clepit-info) 8%, transparent);border:1px solid color-mix(in oklab, var(--clepit-info) 35%, transparent);border-radius:8px}.clepit-public-page__notice-title{margin:0;font-size:12px;font-weight:600;color:var(--clepit-info)}.clepit-public-page__notice-body{margin:0;font-size:12px;line-height:1.55;color:var(--clepit-text-muted)}</style>":""].filter(Boolean);return["<!doctype html>",`<html lang="${D(e.locale??"en")}">`,`<head>${a.join("")}</head>`,e.scheme?`<body data-clepit-theme="${D(e.scheme)}">`:"<body>",'<main class="clepit-public-page">',`<h1 class="clepit-public-page__title">${n}</h1>`,...e.notice?[js(e.notice)]:[],Os(e.blocks,{...t,anchorTargets:!0}),"</main>","</body>","</html>"].join("\n")};export{Yt as BLOCK_TOOLS,nn as CONTROL_LABELS,an as DIALOG_LABELS,Oe as EMBED_ENGLISH,tn as EMBED_LABELS,Pe as EMBED_TOOL_NAMES,b as EMBED_WIRE_KEYS,As as Editor,on as INLINE_REWRITE_ACTIONS,Zt as INLINE_TOOLS,ve as ISSUE_ENGLISH,en as ISSUE_LABELS,Qt as ISSUE_TOOLS,xe as ISSUE_TOOL_NAMES,Te as IssueChip,Cs as Renderer,N as StyleManager,ha as UploadRefusal,Ls as activateBlocks,qe as chipsInHtml,tt as classifyIssueUrl,T as domBacking,er as drawBlock,Re as embedLabel,f as isEmbedProviderDisabled,we as issueLabel,Ce as issueToolName,qs as noticeStylesheet,zs as pageMetadata,Hs as pageStylesheet,Va as parseOpenApi,De as readChipMarkup,je as refreshChipsInHtml,Os as renderBlocks,js as renderNotice,Ps as renderPage,z as renderToString,k as resolveEmbed,Ds as sanitizeHtmlWithoutDom,j as stringBacking,H as toDomElement,E as tokensToLightDarkBlock};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|