var T=Object.defineProperty;var v=(o,t,a)=>t in o?T(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a;var i=(o,t,a)=>v(o,typeof t!="symbol"?t+"":t,a);import{_ as n}from"./Dp1pzeXC.js";import{t as b,a as k}from"./CUaqldoV.js";import{p as E,a as P,M as x,K as L,g as I}from"./BSRAYoh9.js";import{p as A}from"./B-Of7g02.js";import{o as S}from"./D-iKpGTB.js";import{s as d}from"./BYuKR2PY.js";class j{constructor({api:t}){i(this,"button");i(this,"api");i(this,"tag");i(this,"class");i(this,"_state");this.api=t,this.button=null,this._state=!1,this.tag="MARK",this.class="cdx-marker"}static get isInline(){return!0}static get sanitize(){return{mark:{class:"cdx-marker"}}}get state(){return this._state}set state(t){this._state=t,this.button.classList.toggle(this.api.styles.inlineToolButtonActive,t)}render(){return this.button=document.createElement("button"),this.button.type="button",this.button.innerHTML='<svg width="20" height="18"><path d="M10.458 12.04l2.919 1.686-.781 1.417-.984-.03-.974 1.687H8.674l1.49-2.583-.508-.775.802-1.401zm.546-.952l3.624-6.327a1.597 1.597 0 0 1 2.182-.59 1.632 1.632 0 0 1 .615 2.201l-3.519 6.391-2.902-1.675zm-7.73 3.467h3.465a1.123 1.123 0 1 1 0 2.247H3.273a1.123 1.123 0 1 1 0-2.247z"/></svg>',this.button.classList.add(this.api.styles.inlineToolButton),this.button}surround(t){if(console.log("surround",t),this.state){this.unwrap(t);return}this.wrap(t)}wrap(t){console.log("wrap",t);const a=t.extractContents(),r=document.createElement(this.tag);r.classList.add(this.class),r.appendChild(a),t.insertNode(r),this.api.selection.expandToTag(r)}unwrap(t){console.log("unwrap",t);const a=this.api.selection.findParentTag(this.tag,this.class),r=t.extractContents();a.remove(),t.insertNode(r)}checkState(){console.log("checkState");const t=this.api.selection.findParentTag(this.tag);this.state=!!t}}async function z(o,t){const a=await fetch(o,t);if(!a.ok){if(console.error(`🚨 Fetch error: ${a.status} ${o}`),a.status===400){const r=await a.json();d({type:"danger",message:`Błąd danych wejściowych. Sprawdź ponownie wprowadzone dane. ${r.error}`});return}d({type:"danger",message:"Błąd serwera. Spróbuj ponownie lub skontaktuj się z Administratorem."})}return a}var B=b('<div class="form-control"><div id="editorjs"></div></div>');function F(o,t){E(t,!0);let a=A(t,"value",15),r=L(null);S(async()=>{try{const{default:l}=await n(async()=>{const{default:e}=await import("./CyFQPCrr.js");return{default:e}},[],import.meta.url),{default:p}=await n(async()=>{const{default:e}=await import("./B174FzUh.js");return{default:e}},[],import.meta.url),{default:m}=await n(async()=>{const{default:e}=await import("./BvFXJ-fC.js");return{default:e}},[],import.meta.url),{default:h}=await n(async()=>{const{default:e}=await import("./ClT3_yd8.js");return{default:e}},[],import.meta.url),{default:f}=await n(async()=>{const{default:e}=await import("./D9CEDbhX.js");return{default:e}},[],import.meta.url),{default:g}=await n(async()=>{const{default:e}=await import("./BL-tFSEj.js");return{default:e}},[],import.meta.url),_=p,w=g,c=h;c.save=e=>({text:e.innerHTML}),x(r,new l({holder:"editorjs",inlineToolbar:["link","bold","italic"],data:a(),tools:{header:{class:_,config:{placeholder:"Wprowadź tytuł",levels:[2,3,4],defaultLevel:2}},paragraph:{class:c,inlineToolbar:["bold","link","italic"],config:{preserveBlank:!0}},centeredParagraph:{class:f,inlineToolbar:["marker"],config:{placeholder:"Start writing…"}},marker:j,list:m,image:{class:w,config:{uploader:{uploadByFile(e){return console.log(e),z("/mgr/api/upload-image",{method:"POST",body:e,headers:{"Content-Type":e.type,"X-Filename":e.name}}).then(s=>s.json()).then(s=>(console.log(s),s)).then(s=>({success:1,file:{url:s.file.url}})).catch(()=>({success:0}))}},types:"image/*",features:{caption:"optional"},captionPlaceholder:"Dodaj podpis",buttonContent:"Wybierz obraz"}}},onChange:async(e,s)=>{const y=await I(r).save();a(y)}}),!0)}catch(l){console.error("Failed to load EditorJS:",l)}});var u=B();k(o,u),P()}export{F as E,z as f};
