From 7f021ab11423317019edee91c48c8d89025fbc5a Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 4 Jul 2026 16:42:58 +0200 Subject: [PATCH] feat(post-form): Field Notes styling, disclosure, feedback states (U5) Migrate Get Location/Weather + required-field validation out of the template's inline scripts into the bundle: generalize the field lookup so weather_desc (now a "},h.paragraph=function(l){return"

"+l+`

`},h.table=function(l,u){return u&&(u=""+u+""),` @@ -72,16 +72,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho `+u+`
`},h.tablerow=function(l){return` `+l+` -`},h.tablecell=function(l,u){var v=u.header?"th":"td",d=u.align?"<"+v+' align="'+u.align+'">':"<"+v+">";return d+l+(" -`)},h.strong=function(l){return""+l+""},h.em=function(l){return""+l+""},h.codespan=function(l){return""+l+""},h.br=function(){return this.options.xhtml?"
":"
"},h.del=function(l){return""+l+""},h.link=function(l,u,v){if(l=tu(this.options.sanitize,this.options.baseUrl,l),l===null)return v;var d='",d},h.image=function(l,u,v){if(l=tu(this.options.sanitize,this.options.baseUrl,l),l===null)return v;var d=''+v+'":">",d},h.text=function(l){return l},a}(),$o=function(){function a(){}var h=a.prototype;return h.strong=function(l){return l},h.em=function(l){return l},h.codespan=function(l){return l},h.del=function(l){return l},h.html=function(l){return l},h.text=function(l){return l},h.link=function(l,u,v){return""+v},h.image=function(l,u,v){return""+v},h.br=function(){return""},a}(),Vo=function(){function a(){this.seen={}}var h=a.prototype;return h.serialize=function(l){return l.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},h.getNextSafeSlug=function(l,u){var v=l,d=0;if(this.seen.hasOwnProperty(v)){d=this.seen[l];do d++,v=l+"-"+d;while(this.seen.hasOwnProperty(v))}return u||(this.seen[l]=d,this.seen[v]=0),v},h.slug=function(l,u){u===void 0&&(u={});var v=this.serialize(l);return this.getNextSafeSlug(v,u.dryrun)},a}(),Rr=function(){function a(c){this.options=c||Se.defaults,this.options.renderer=this.options.renderer||new fn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new $o,this.slugger=new Vo}a.parse=function(l,u){var v=new a(u);return v.parse(l)},a.parseInline=function(l,u){var v=new a(u);return v.parseInline(l)};var h=a.prototype;return h.parse=function(l,u){u===void 0&&(u=!0);var v="",d,g,y,w,C,M,B,N,H,O,k,L,T,I,z,_,X,K,ge,G=l.length;for(d=0;d0&&z.tokens[0].type==="paragraph"?(z.tokens[0].text=K+" "+z.tokens[0].text,z.tokens[0].tokens&&z.tokens[0].tokens.length>0&&z.tokens[0].tokens[0].type==="text"&&(z.tokens[0].tokens[0].text=K+" "+z.tokens[0].tokens[0].text)):z.tokens.unshift({type:"text",text:K}):I+=K),I+=this.parse(z.tokens,T),H+=this.renderer.listitem(I,X,_);v+=this.renderer.list(H,k,L);continue}case"html":{v+=this.renderer.html(O.text);continue}case"paragraph":{v+=this.renderer.paragraph(this.parseInline(O.tokens));continue}case"text":{for(H=O.tokens?this.parseInline(O.tokens):O.text;d+1";if(h)return Promise.resolve(u);if(c){c(null,u);return}return u}if(h)return Promise.reject(l);if(c){c(l);return}throw l}}function uu(a,h){return function(c,l,u){typeof l=="function"&&(u=l,l=null);var v=gt({},l);l=gt({},le.defaults,v);var d=id(l.silent,l.async,u);if(typeof c>"u"||c===null)return d(new Error("marked(): input parameter is undefined or null"));if(typeof c!="string")return d(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(c)+", string expected"));if(ed(l),l.hooks&&(l.hooks.options=l),u){var g=l.highlight,y;try{l.hooks&&(c=l.hooks.preprocess(c)),y=a(c,l)}catch(N){return d(N)}var w=function(H){var O;if(!H)try{l.walkTokens&&le.walkTokens(y,l.walkTokens),O=h(y,l),l.hooks&&(O=l.hooks.postprocess(O))}catch(k){H=k}return l.highlight=g,H?d(H):u(null,O)};if(!g||g.length<3||(delete l.highlight,!y.length))return w();var C=0;le.walkTokens(y,function(N){N.type==="code"&&(C++,setTimeout(function(){g(N.text,N.lang,function(H,O){if(H)return w(H);O!=null&&O!==N.text&&(N.text=O,N.escaped=!0),C--,C===0&&w()})},0))}),C===0&&w();return}if(l.async)return Promise.resolve(l.hooks?l.hooks.preprocess(c):c).then(function(N){return a(N,l)}).then(function(N){return l.walkTokens?Promise.all(le.walkTokens(N,l.walkTokens)).then(function(){return N}):N}).then(function(N){return h(N,l)}).then(function(N){return l.hooks?l.hooks.postprocess(N):N}).catch(d);try{l.hooks&&(c=l.hooks.preprocess(c));var M=a(c,l);l.walkTokens&&le.walkTokens(M,l.walkTokens);var B=h(M,l);return l.hooks&&(B=l.hooks.postprocess(B)),B}catch(N){return d(N)}}}function le(a,h,c){return uu(zr.lex,Rr.parse)(a,h,c)}le.options=le.setOptions=function(a){return le.defaults=gt({},le.defaults,a),Wc(le.defaults),le};le.getDefaults=Jo;le.defaults=Se.defaults;le.use=function(){for(var a=le.defaults.extensions||{renderers:{},childTokens:{}},h=arguments.length,c=new Array(h),l=0;l{"use strict";var Pr=ct();ms();ys();Cs();Xo();Yo();Is();zs();_s();Us();Ks();Ko();var dd=Js(),ea=fu().marked,hu=/Mac/.test(navigator.platform),hd=new RegExp(/()+?/g),Di={toggleBold:hn,toggleItalic:pn,drawLink:Fn,toggleHeadingSmaller:Ci,toggleHeadingBigger:bn,drawImage:An,toggleBlockquote:mn,toggleOrderedList:wn,toggleUnorderedList:Cn,toggleCheckList:kn,toggleCodeBlock:vn,togglePreview:Bn,toggleStrikethrough:gn,toggleHeading1:yn,toggleHeading2:xn,toggleHeading3:Dn,toggleHeading4:ra,toggleHeading5:ia,toggleHeading6:na,cleanBlock:Sn,drawTable:En,drawHorizontalRule:Ln,undo:Tn,redo:Mn,toggleSideBySide:_r,toggleFullScreen:dr},pd={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",toggleHeading1:"Ctrl+Alt+1",toggleHeading2:"Ctrl+Alt+2",toggleHeading3:"Ctrl+Alt+3",toggleHeading4:"Ctrl+Alt+4",toggleHeading5:"Ctrl+Alt+5",toggleHeading6:"Ctrl+Alt+6",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCheckList:"Shift-Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},gd=function(a){for(var h in Di)if(Di[h]===a)return h;return null},ta=function(){var a=!1;return function(h){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(h)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(h.substr(0,4)))&&(a=!0)}(navigator.userAgent||navigator.vendor||window.opera),a};function vd(a){for(var h;(h=hd.exec(a))!==null;){var c=h[0];if(c.indexOf("target=")===-1){var l=c.replace(/>$/,' target="_blank">');a=a.replace(c,l)}}return a}function md(a){for(var h=new DOMParser,c=h.parseFromString(a,"text/html"),l=c.getElementsByTagName("li"),u=0;u0){for(var N=document.createElement("i"),H=0;H':"<"+v+">";return f+l+(" +`)},h.strong=function(l){return""+l+""},h.em=function(l){return""+l+""},h.codespan=function(l){return""+l+""},h.br=function(){return this.options.xhtml?"
":"
"},h.del=function(l){return""+l+""},h.link=function(l,u,v){if(l=iu(this.options.sanitize,this.options.baseUrl,l),l===null)return v;var f='
",f},h.image=function(l,u,v){if(l=iu(this.options.sanitize,this.options.baseUrl,l),l===null)return v;var f=''+v+'":">",f},h.text=function(l){return l},a}(),ea=function(){function a(){}var h=a.prototype;return h.strong=function(l){return l},h.em=function(l){return l},h.codespan=function(l){return l},h.del=function(l){return l},h.html=function(l){return l},h.text=function(l){return l},h.link=function(l,u,v){return""+v},h.image=function(l,u,v){return""+v},h.br=function(){return""},a}(),ta=function(){function a(){this.seen={}}var h=a.prototype;return h.serialize=function(l){return l.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},h.getNextSafeSlug=function(l,u){var v=l,f=0;if(this.seen.hasOwnProperty(v)){f=this.seen[l];do f++,v=l+"-"+f;while(this.seen.hasOwnProperty(v))}return u||(this.seen[l]=f,this.seen[v]=0),v},h.slug=function(l,u){u===void 0&&(u={});var v=this.serialize(l);return this.getNextSafeSlug(v,u.dryrun)},a}(),_r=function(){function a(c){this.options=c||Se.defaults,this.options.renderer=this.options.renderer||new dn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ea,this.slugger=new ta}a.parse=function(l,u){var v=new a(u);return v.parse(l)},a.parseInline=function(l,u){var v=new a(u);return v.parseInline(l)};var h=a.prototype;return h.parse=function(l,u){u===void 0&&(u=!0);var v="",f,p,y,w,D,T,M,N,O,z,k,L,B,I,H,_,X,K,ge,G=l.length;for(f=0;f0&&H.tokens[0].type==="paragraph"?(H.tokens[0].text=K+" "+H.tokens[0].text,H.tokens[0].tokens&&H.tokens[0].tokens.length>0&&H.tokens[0].tokens[0].type==="text"&&(H.tokens[0].tokens[0].text=K+" "+H.tokens[0].tokens[0].text)):H.tokens.unshift({type:"text",text:K}):I+=K),I+=this.parse(H.tokens,B),O+=this.renderer.listitem(I,X,_);v+=this.renderer.list(O,k,L);continue}case"html":{v+=this.renderer.html(z.text);continue}case"paragraph":{v+=this.renderer.paragraph(this.parseInline(z.tokens));continue}case"text":{for(O=z.tokens?this.parseInline(z.tokens):z.text;f+1";if(h)return Promise.resolve(u);if(c){c(null,u);return}return u}if(h)return Promise.reject(l);if(c){c(l);return}throw l}}function cu(a,h){return function(c,l,u){typeof l=="function"&&(u=l,l=null);var v=gt({},l);l=gt({},le.defaults,v);var f=od(l.silent,l.async,u);if(typeof c>"u"||c===null)return f(new Error("marked(): input parameter is undefined or null"));if(typeof c!="string")return f(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(c)+", string expected"));if(rd(l),l.hooks&&(l.hooks.options=l),u){var p=l.highlight,y;try{l.hooks&&(c=l.hooks.preprocess(c)),y=a(c,l)}catch(N){return f(N)}var w=function(O){var z;if(!O)try{l.walkTokens&&le.walkTokens(y,l.walkTokens),z=h(y,l),l.hooks&&(z=l.hooks.postprocess(z))}catch(k){O=k}return l.highlight=p,O?f(O):u(null,z)};if(!p||p.length<3||(delete l.highlight,!y.length))return w();var D=0;le.walkTokens(y,function(N){N.type==="code"&&(D++,setTimeout(function(){p(N.text,N.lang,function(O,z){if(O)return w(O);z!=null&&z!==N.text&&(N.text=z,N.escaped=!0),D--,D===0&&w()})},0))}),D===0&&w();return}if(l.async)return Promise.resolve(l.hooks?l.hooks.preprocess(c):c).then(function(N){return a(N,l)}).then(function(N){return l.walkTokens?Promise.all(le.walkTokens(N,l.walkTokens)).then(function(){return N}):N}).then(function(N){return h(N,l)}).then(function(N){return l.hooks?l.hooks.postprocess(N):N}).catch(f);try{l.hooks&&(c=l.hooks.preprocess(c));var T=a(c,l);l.walkTokens&&le.walkTokens(T,l.walkTokens);var M=h(T,l);return l.hooks&&(M=l.hooks.postprocess(M)),M}catch(N){return f(N)}}}function le(a,h,c){return cu(Pr.lex,_r.parse)(a,h,c)}le.options=le.setOptions=function(a){return le.defaults=gt({},le.defaults,a),Uc(le.defaults),le};le.getDefaults=Vo;le.defaults=Se.defaults;le.use=function(){for(var a=le.defaults.extensions||{renderers:{},childTokens:{}},h=arguments.length,c=new Array(h),l=0;l{"use strict";var Wr=ct();ys();Ds();ks();Zo();Qo();Os();Ps();qs();Gs();Ys();Yo();var pd=Vs(),ra=du().marked,gu=/Mac/.test(navigator.platform),gd=new RegExp(/()+?/g),wi={toggleBold:gn,toggleItalic:vn,drawLink:An,toggleHeadingSmaller:ki,toggleHeadingBigger:xn,drawImage:Ln,toggleBlockquote:yn,toggleOrderedList:Sn,toggleUnorderedList:kn,toggleCheckList:Fn,toggleCodeBlock:bn,togglePreview:In,toggleStrikethrough:mn,toggleHeading1:Dn,toggleHeading2:Cn,toggleHeading3:wn,toggleHeading4:na,toggleHeading5:oa,toggleHeading6:aa,cleanBlock:En,drawTable:Tn,drawHorizontalRule:Mn,undo:Bn,redo:Nn,toggleSideBySide:qr,toggleFullScreen:hr},vd={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",toggleHeading1:"Ctrl+Alt+1",toggleHeading2:"Ctrl+Alt+2",toggleHeading3:"Ctrl+Alt+3",toggleHeading4:"Ctrl+Alt+4",toggleHeading5:"Ctrl+Alt+5",toggleHeading6:"Ctrl+Alt+6",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCheckList:"Shift-Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},md=function(a){for(var h in wi)if(wi[h]===a)return h;return null},ia=function(){var a=!1;return function(h){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(h)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(h.substr(0,4)))&&(a=!0)}(navigator.userAgent||navigator.vendor||window.opera),a};function bd(a){for(var h;(h=gd.exec(a))!==null;){var c=h[0];if(c.indexOf("target=")===-1){var l=c.replace(/>$/,' target="_blank">');a=a.replace(c,l)}}return a}function yd(a){for(var h=new DOMParser,c=h.parseFromString(a,"text/html"),l=c.getElementsByTagName("li"),u=0;u0){for(var N=document.createElement("i"),O=0;O=0&&(C=d.getLineHandle(B),!c(C));B--);var L=d.getTokenAt({line:B,ch:1}),T=l(L).fencedChars,I,z,_,X;c(d.getLineHandle(g.line))?(I="",z=g.line):c(d.getLineHandle(g.line-1))?(I="",z=g.line-1):(I=T+` -`,z=g.line),c(d.getLineHandle(y.line))?(_="",X=y.line,y.ch===0&&(X+=1)):y.ch!==0&&c(d.getLineHandle(y.line+1))?(_="",X=y.line+1):(_=T+` -`,X=y.line+1),y.ch===0&&(X-=1),d.operation(function(){d.replaceRange(_,{line:X,ch:0},{line:X+(_?0:1),ch:0}),d.replaceRange(I,{line:z,ch:0},{line:z+(I?0:1),ch:0})}),d.setSelection({line:z+(I?1:0),ch:0},{line:X+(I?1:-1),ch:0}),d.focus()}else{var K=g.line;if(c(d.getLineHandle(g.line))&&(u(d,g.line+1)==="fenced"?(B=g.line,K=g.line+1):(N=g.line,K=g.line-1)),B===void 0)for(B=K;B>=0&&(C=d.getLineHandle(B),!c(C));B--);if(N===void 0)for(H=d.lineCount(),N=K;N=0;B--)if(C=d.getLineHandle(B),!C.text.match(/^\s*$/)&&u(d,B,C)!=="indented"){B+=1;break}for(H=d.lineCount(),N=g.line;N\s+/,"unordered-list":l,"ordered-list":l,"check-list":/^(\s*)(- \[[ xX]])(\s+)/},w=function(L,T){var I={quote:">","unordered-list":c,"ordered-list":"%%i.","check-list":"- [ ]"};return I[L].replace("%%i",T)},C=function(L,T){var I={quote:">","unordered-list":"\\"+c,"ordered-list":"\\d+.","check-list":"- \\[[ xX]]"},z=new RegExp(I[L]);return T&&z.test(T)},M=function(L,T,I){var z=l.exec(T),_=w(L,B);return z!==null?(C(L,z[2])&&(_=""),T=z[1]+_+z[3]+T.replace(u,"").replace(y[L],"$1")):I==!1&&(T=_+" "+T),T},B=1,N=["unordered-list","ordered-list","check-list"],H=Object.keys(v)[0];if(!N.includes(H)){var O=a.getLine(d.line);/^\s*- \[[ xX]]\s/.test(O)?H="check-list":/^\s*\d+\.\s/.test(O)?H="ordered-list":/^\s*[*\-+]\s/.test(O)&&(H="unordered-list")}for(var k=d.line;k<=g.line;k++)(function(L){var T=a.getLine(L);v[h]?T=T.replace(y[h],"$1"):N.includes(H)&&N.includes(h)?(T=T.replace(y[H],"$1"),T=M(h,T,!1),B+=1):(T=M(h,T,!1),B+=1),a.replaceRange(T,{line:L,ch:0},{line:L,ch:99999999999999})})(k);a.focus()}}function mu(a,h,c,l){if(!(!a.codemirror||a.isPreviewActive())){var u=a.codemirror,v=Qt(u),d=v[h];if(!d){hr(u,d,c,l);return}var g=u.getCursor("start"),y=u.getCursor("end"),w=u.getLine(g.line),C=w.slice(0,g.ch),M=w.slice(g.ch);h=="link"?C=C.replace(/(.*)[^!]\[/,"$1"):h=="image"&&(C=C.replace(/(.*)!\[$/,"$1")),M=M.replace(/]\(.*?\)/,""),u.replaceRange(C+M,{line:g.line,ch:0},{line:g.line,ch:99999999999999}),g.ch-=c[0].length,g!==y&&(y.ch-=c[0].length),u.setSelection(g,y),u.focus()}}function aa(a,h,c,l){if(!(!a.codemirror||a.isPreviewActive())){l=typeof l>"u"?c:l;var u=a.codemirror,v=Qt(u),d,g=c,y=l,w=u.getCursor("start"),C=u.getCursor("end");v[h]?(d=u.getLine(w.line),g=d.slice(0,w.ch),y=d.slice(w.ch),h=="bold"?(g=g.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),y=y.replace(/(\*\*|__)/,"")):h=="italic"?(g=g.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),y=y.replace(/(\*|_)/,"")):h=="strikethrough"&&(g=g.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),y=y.replace(/(\*\*|~~)/,"")),u.replaceRange(g+y,{line:w.line,ch:0},{line:w.line,ch:99999999999999}),h=="bold"||h=="strikethrough"?(w.ch-=2,w!==C&&(C.ch-=2)):h=="italic"&&(w.ch-=1,w!==C&&(C.ch-=1))):(d=u.getSelection(),h=="bold"?(d=d.split("**").join(""),d=d.split("__").join("")):h=="italic"?(d=d.split("*").join(""),d=d.split("_").join("")):h=="strikethrough"&&(d=d.split("~~").join("")),u.replaceSelection(g+d+y),w.ch+=c.length,C.ch=w.ch+d.length),u.setSelection(w,C),u.focus()}}function Dd(a){if(!a.getWrapperElement().lastChild.classList.contains("editor-preview-active"))for(var h=a.getCursor("start"),c=a.getCursor("end"),l,u=h.line;u<=c.line;u++)l=a.getLine(u),l=l.replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/,""),a.replaceRange(l,{line:u,ch:0},{line:u,ch:99999999999999})}function dn(a,h){if(Math.abs(a)<1024)return""+a+h[0];var c=0;do a/=1024,++c;while(Math.abs(a)>=1024&&c=19968?l+=c[u].length:l+=1;return l}var ke={bold:"fa fa-bold",italic:"fa fa-italic",strikethrough:"fa fa-strikethrough",heading:"fa fa-header fa-heading","heading-smaller":"fa fa-header fa-heading header-smaller","heading-bigger":"fa fa-header fa-heading header-bigger","heading-1":"fa fa-header fa-heading header-1","heading-2":"fa fa-header fa-heading header-2","heading-3":"fa fa-header fa-heading header-3",code:"fa fa-code",quote:"fa fa-quote-left","ordered-list":"fa fa-list-ol","unordered-list":"fa fa-list-ul","check-list":"fa fa-check-square-o","clean-block":"fa fa-eraser",link:"fa fa-link",image:"fa fa-image","upload-image":"fa fa-image",table:"fa fa-table","horizontal-rule":"fa fa-minus",preview:"fa fa-eye","side-by-side":"fa fa-columns",fullscreen:"fa fa-arrows-alt",guide:"fa fa-question-circle",undo:"fa fa-undo",redo:"fa fa-repeat fa-redo"},cr={bold:{name:"bold",action:hn,className:ke.bold,title:"Bold",default:!0},italic:{name:"italic",action:pn,className:ke.italic,title:"Italic",default:!0},strikethrough:{name:"strikethrough",action:gn,className:ke.strikethrough,title:"Strikethrough"},heading:{name:"heading",action:Ci,className:ke.heading,title:"Heading",default:!0},"heading-smaller":{name:"heading-smaller",action:Ci,className:ke["heading-smaller"],title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:bn,className:ke["heading-bigger"],title:"Bigger Heading"},"heading-1":{name:"heading-1",action:yn,className:ke["heading-1"],title:"Big Heading"},"heading-2":{name:"heading-2",action:xn,className:ke["heading-2"],title:"Medium Heading"},"heading-3":{name:"heading-3",action:Dn,className:ke["heading-3"],title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:vn,className:ke.code,title:"Code"},quote:{name:"quote",action:mn,className:ke.quote,title:"Quote",default:!0},"unordered-list":{name:"unordered-list",action:Cn,className:ke["unordered-list"],title:"Generic List",default:!0},"ordered-list":{name:"ordered-list",action:wn,className:ke["ordered-list"],title:"Numbered List",default:!0},"check-list":{name:"check-list",action:kn,className:ke["check-list"],title:"Check List",default:!0},"clean-block":{name:"clean-block",action:Sn,className:ke["clean-block"],title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:Fn,className:ke.link,title:"Create Link",default:!0},image:{name:"image",action:An,className:ke.image,title:"Insert Image",default:!0},"upload-image":{name:"upload-image",action:oa,className:ke["upload-image"],title:"Import an image"},table:{name:"table",action:En,className:ke.table,title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:Ln,className:ke["horizontal-rule"],title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:Bn,className:ke.preview,noDisable:!0,title:"Toggle Preview",default:!0},"side-by-side":{name:"side-by-side",action:_r,className:ke["side-by-side"],noDisable:!0,noMobile:!0,title:"Toggle Side by Side",default:!0},fullscreen:{name:"fullscreen",action:dr,className:ke.fullscreen,noDisable:!0,noMobile:!0,title:"Toggle Fullscreen",default:!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://www.markdownguide.org/basic-syntax/",className:ke.guide,noDisable:!0,title:"Markdown Guide",default:!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:Tn,className:ke.undo,noDisable:!0,title:"Undo"},redo:{name:"redo",action:Mn,className:ke.redo,noDisable:!0,title:"Redo"}},Cd={link:["[","](#url#)"],image:["![","](#url#)"],uploadedImage:["![](#url#)",""],table:["",` +`,vt--),pr(U,!1,[b,ee]),U.setSelection({line:Te,ch:0},{line:vt,ch:0})}var f=a.codemirror,p=f.getCursor("start"),y=f.getCursor("end"),w=f.getTokenAt({line:p.line,ch:p.ch||1}),D=f.getLineHandle(p.line),T=u(f,p.line,D,w),M,N,O;if(T==="single"){var z=D.text.slice(0,p.ch).replace("`",""),k=D.text.slice(p.ch).replace("`","");f.replaceRange(z+k,{line:p.line,ch:0},{line:p.line,ch:99999999999999}),p.ch--,p!==y&&y.ch--,f.setSelection(p,y),f.focus()}else if(T==="fenced")if(p.line!==y.line||p.ch!==y.ch){for(M=p.line;M>=0&&(D=f.getLineHandle(M),!c(D));M--);var L=f.getTokenAt({line:M,ch:1}),B=l(L).fencedChars,I,H,_,X;c(f.getLineHandle(p.line))?(I="",H=p.line):c(f.getLineHandle(p.line-1))?(I="",H=p.line-1):(I=B+` +`,H=p.line),c(f.getLineHandle(y.line))?(_="",X=y.line,y.ch===0&&(X+=1)):y.ch!==0&&c(f.getLineHandle(y.line+1))?(_="",X=y.line+1):(_=B+` +`,X=y.line+1),y.ch===0&&(X-=1),f.operation(function(){f.replaceRange(_,{line:X,ch:0},{line:X+(_?0:1),ch:0}),f.replaceRange(I,{line:H,ch:0},{line:H+(I?0:1),ch:0})}),f.setSelection({line:H+(I?1:0),ch:0},{line:X+(I?1:-1),ch:0}),f.focus()}else{var K=p.line;if(c(f.getLineHandle(p.line))&&(u(f,p.line+1)==="fenced"?(M=p.line,K=p.line+1):(N=p.line,K=p.line-1)),M===void 0)for(M=K;M>=0&&(D=f.getLineHandle(M),!c(D));M--);if(N===void 0)for(O=f.lineCount(),N=K;N=0;M--)if(D=f.getLineHandle(M),!D.text.match(/^\s*$/)&&u(f,M,D)!=="indented"){M+=1;break}for(O=f.lineCount(),N=p.line;N\s+/,"unordered-list":l,"ordered-list":l,"check-list":/^(\s*)(- \[[ xX]])(\s+)/},w=function(L,B){var I={quote:">","unordered-list":c,"ordered-list":"%%i.","check-list":"- [ ]"};return I[L].replace("%%i",B)},D=function(L,B){var I={quote:">","unordered-list":"\\"+c,"ordered-list":"\\d+.","check-list":"- \\[[ xX]]"},H=new RegExp(I[L]);return B&&H.test(B)},T=function(L,B,I){var H=l.exec(B),_=w(L,M);return H!==null?(D(L,H[2])&&(_=""),B=H[1]+_+H[3]+B.replace(u,"").replace(y[L],"$1")):I==!1&&(B=_+" "+B),B},M=1,N=["unordered-list","ordered-list","check-list"],O=Object.keys(v)[0];if(!N.includes(O)){var z=a.getLine(f.line);/^\s*- \[[ xX]]\s/.test(z)?O="check-list":/^\s*\d+\.\s/.test(z)?O="ordered-list":/^\s*[*\-+]\s/.test(z)&&(O="unordered-list")}for(var k=f.line;k<=p.line;k++)(function(L){var B=a.getLine(L);v[h]?B=B.replace(y[h],"$1"):N.includes(O)&&N.includes(h)?(B=B.replace(y[O],"$1"),B=T(h,B,!1),M+=1):(B=T(h,B,!1),M+=1),a.replaceRange(B,{line:L,ch:0},{line:L,ch:99999999999999})})(k);a.focus()}}function yu(a,h,c,l){if(!(!a.codemirror||a.isPreviewActive())){var u=a.codemirror,v=Qt(u),f=v[h];if(!f){pr(u,f,c,l);return}var p=u.getCursor("start"),y=u.getCursor("end"),w=u.getLine(p.line),D=w.slice(0,p.ch),T=w.slice(p.ch);h=="link"?D=D.replace(/(.*)[^!]\[/,"$1"):h=="image"&&(D=D.replace(/(.*)!\[$/,"$1")),T=T.replace(/]\(.*?\)/,""),u.replaceRange(D+T,{line:p.line,ch:0},{line:p.line,ch:99999999999999}),p.ch-=c[0].length,p!==y&&(y.ch-=c[0].length),u.setSelection(p,y),u.focus()}}function sa(a,h,c,l){if(!(!a.codemirror||a.isPreviewActive())){l=typeof l>"u"?c:l;var u=a.codemirror,v=Qt(u),f,p=c,y=l,w=u.getCursor("start"),D=u.getCursor("end");v[h]?(f=u.getLine(w.line),p=f.slice(0,w.ch),y=f.slice(w.ch),h=="bold"?(p=p.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),y=y.replace(/(\*\*|__)/,"")):h=="italic"?(p=p.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),y=y.replace(/(\*|_)/,"")):h=="strikethrough"&&(p=p.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),y=y.replace(/(\*\*|~~)/,"")),u.replaceRange(p+y,{line:w.line,ch:0},{line:w.line,ch:99999999999999}),h=="bold"||h=="strikethrough"?(w.ch-=2,w!==D&&(D.ch-=2)):h=="italic"&&(w.ch-=1,w!==D&&(D.ch-=1))):(f=u.getSelection(),h=="bold"?(f=f.split("**").join(""),f=f.split("__").join("")):h=="italic"?(f=f.split("*").join(""),f=f.split("_").join("")):h=="strikethrough"&&(f=f.split("~~").join("")),u.replaceSelection(p+f+y),w.ch+=c.length,D.ch=w.ch+f.length),u.setSelection(w,D),u.focus()}}function wd(a){if(!a.getWrapperElement().lastChild.classList.contains("editor-preview-active"))for(var h=a.getCursor("start"),c=a.getCursor("end"),l,u=h.line;u<=c.line;u++)l=a.getLine(u),l=l.replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/,""),a.replaceRange(l,{line:u,ch:0},{line:u,ch:99999999999999})}function pn(a,h){if(Math.abs(a)<1024)return""+a+h[0];var c=0;do a/=1024,++c;while(Math.abs(a)>=1024&&c=19968?l+=c[u].length:l+=1;return l}var ke={bold:"fa fa-bold",italic:"fa fa-italic",strikethrough:"fa fa-strikethrough",heading:"fa fa-header fa-heading","heading-smaller":"fa fa-header fa-heading header-smaller","heading-bigger":"fa fa-header fa-heading header-bigger","heading-1":"fa fa-header fa-heading header-1","heading-2":"fa fa-header fa-heading header-2","heading-3":"fa fa-header fa-heading header-3",code:"fa fa-code",quote:"fa fa-quote-left","ordered-list":"fa fa-list-ol","unordered-list":"fa fa-list-ul","check-list":"fa fa-check-square-o","clean-block":"fa fa-eraser",link:"fa fa-link",image:"fa fa-image","upload-image":"fa fa-image",table:"fa fa-table","horizontal-rule":"fa fa-minus",preview:"fa fa-eye","side-by-side":"fa fa-columns",fullscreen:"fa fa-arrows-alt",guide:"fa fa-question-circle",undo:"fa fa-undo",redo:"fa fa-repeat fa-redo"},dr={bold:{name:"bold",action:gn,className:ke.bold,title:"Bold",default:!0},italic:{name:"italic",action:vn,className:ke.italic,title:"Italic",default:!0},strikethrough:{name:"strikethrough",action:mn,className:ke.strikethrough,title:"Strikethrough"},heading:{name:"heading",action:ki,className:ke.heading,title:"Heading",default:!0},"heading-smaller":{name:"heading-smaller",action:ki,className:ke["heading-smaller"],title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:xn,className:ke["heading-bigger"],title:"Bigger Heading"},"heading-1":{name:"heading-1",action:Dn,className:ke["heading-1"],title:"Big Heading"},"heading-2":{name:"heading-2",action:Cn,className:ke["heading-2"],title:"Medium Heading"},"heading-3":{name:"heading-3",action:wn,className:ke["heading-3"],title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:bn,className:ke.code,title:"Code"},quote:{name:"quote",action:yn,className:ke.quote,title:"Quote",default:!0},"unordered-list":{name:"unordered-list",action:kn,className:ke["unordered-list"],title:"Generic List",default:!0},"ordered-list":{name:"ordered-list",action:Sn,className:ke["ordered-list"],title:"Numbered List",default:!0},"check-list":{name:"check-list",action:Fn,className:ke["check-list"],title:"Check List",default:!0},"clean-block":{name:"clean-block",action:En,className:ke["clean-block"],title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:An,className:ke.link,title:"Create Link",default:!0},image:{name:"image",action:Ln,className:ke.image,title:"Insert Image",default:!0},"upload-image":{name:"upload-image",action:la,className:ke["upload-image"],title:"Import an image"},table:{name:"table",action:Tn,className:ke.table,title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:Mn,className:ke["horizontal-rule"],title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:In,className:ke.preview,noDisable:!0,title:"Toggle Preview",default:!0},"side-by-side":{name:"side-by-side",action:qr,className:ke["side-by-side"],noDisable:!0,noMobile:!0,title:"Toggle Side by Side",default:!0},fullscreen:{name:"fullscreen",action:hr,className:ke.fullscreen,noDisable:!0,noMobile:!0,title:"Toggle Fullscreen",default:!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://www.markdownguide.org/basic-syntax/",className:ke.guide,noDisable:!0,title:"Markdown Guide",default:!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:Bn,className:ke.undo,noDisable:!0,title:"Undo"},redo:{name:"redo",action:Nn,className:ke.redo,noDisable:!0,title:"Redo"}},kd={link:["[","](#url#)"],image:["![","](#url#)"],uploadedImage:["![](#url#)",""],table:["",` | Column 1 | Column 2 | Column 3 | | -------- | -------- | -------- | @@ -91,5 +91,5 @@ Please report this to https://github.com/markedjs/marked.`,a){var u="

An error ----- -`]},wd={link:"URL for the link:",image:"URL of the image:"},kd={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},Sd={bold:"**",code:"```",italic:"*"},Fd={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},Ad={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:`Image #image_name# is too big (#image_size#). -Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function J(a){a=a||{},a.parent=this;var h=!0;if(a.autoDownloadFontAwesome===!1&&(h=!1),a.autoDownloadFontAwesome!==!0)for(var c=document.styleSheets,l=0;l-1&&(h=!1);if(h){var u=document.createElement("link");u.rel="stylesheet",u.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(u)}if(a.element)this.element=a.element;else if(a.element===null){console.log("EasyMDE: Error. No element was found.");return}if(a.toolbar===void 0){a.toolbar=[];for(var v in cr)Object.prototype.hasOwnProperty.call(cr,v)&&(v.indexOf("separator-")!=-1&&a.toolbar.push("|"),(cr[v].default===!0||a.showIcons&&a.showIcons.constructor===Array&&a.showIcons.indexOf(v)!=-1)&&a.toolbar.push(v))}if(Object.prototype.hasOwnProperty.call(a,"previewClass")||(a.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(a,"status")||(a.status=["autosave","lines","words","cursor"],a.uploadImage&&a.status.unshift("upload-image")),a.previewRender||(a.previewRender=function(g){return this.parent.markdown(g)}),a.parsingConfig=Rt({highlightFormatting:!0},a.parsingConfig||{}),a.insertTexts=Rt({},Cd,a.insertTexts||{}),a.promptTexts=Rt({},wd,a.promptTexts||{}),a.blockStyles=Rt({},Sd,a.blockStyles||{}),a.autosave!=null&&(a.autosave.timeFormat=Rt({},kd,a.autosave.timeFormat||{})),a.iconClassMap=Rt({},ke,a.iconClassMap||{}),a.shortcuts=Rt({},pd,a.shortcuts||{}),a.maxHeight=a.maxHeight||void 0,a.direction=a.direction||"ltr",typeof a.maxHeight<"u"?a.minHeight=a.maxHeight:a.minHeight=a.minHeight||"300px",a.errorCallback=a.errorCallback||function(g){alert(g)},a.uploadImage=a.uploadImage||!1,a.imageMaxSize=a.imageMaxSize||2097152,a.imageAccept=a.imageAccept||"image/png, image/jpeg, image/gif, image/avif",a.imageTexts=Rt({},Fd,a.imageTexts||{}),a.errorMessages=Rt({},Ad,a.errorMessages||{}),a.imagePathAbsolute=a.imagePathAbsolute||!1,a.imageCSRFName=a.imageCSRFName||"csrfmiddlewaretoken",a.imageCSRFHeader=a.imageCSRFHeader||!1,a.imageInputName=a.imageInputName||"image",a.autosave!=null&&a.autosave.unique_id!=null&&a.autosave.unique_id!=""&&(a.autosave.uniqueId=a.autosave.unique_id),a.overlayMode&&a.overlayMode.combine===void 0&&(a.overlayMode.combine=!0),this.options=a,this.render(),a.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(a.initialValue),a.uploadImage){var d=this;this.codemirror.on("dragenter",function(g,y){d.updateStatusBar("upload-image",d.options.imageTexts.sbOnDragEnter),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragend",function(g,y){d.updateStatusBar("upload-image",d.options.imageTexts.sbInit),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragleave",function(g,y){d.updateStatusBar("upload-image",d.options.imageTexts.sbInit),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragover",function(g,y){d.updateStatusBar("upload-image",d.options.imageTexts.sbOnDragEnter),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("drop",function(g,y){y.stopPropagation(),y.preventDefault(),a.imageUploadFunction?d.uploadImagesUsingCustomFunction(a.imageUploadFunction,y.dataTransfer.files):d.uploadImages(y.dataTransfer.files)}),this.codemirror.on("paste",function(g,y){a.imageUploadFunction?d.uploadImagesUsingCustomFunction(a.imageUploadFunction,y.clipboardData.files):d.uploadImages(y.clipboardData.files)})}}J.prototype.uploadImages=function(a,h,c){if(a.length!==0){for(var l=[],u=0;u=2){var I=T[1];if(h.imagesPreviewHandler){var z=h.imagesPreviewHandler(T[1]);typeof z=="string"&&(I=z)}if(window.EMDEimagesCache[I])N(L,window.EMDEimagesCache[I]);else{window.EMDEimagesCache[I]={};var _=document.createElement("img");_.onload=function(){window.EMDEimagesCache[I]={naturalWidth:_.naturalWidth,naturalHeight:_.naturalHeight,url:I},N(L,window.EMDEimagesCache[I])},_.src=I}}}})}this.codemirror.on("update",function(){H()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(h.autofocus===!0||a.autofocus)&&this.codemirror.focus();var O=this.codemirror;setTimeout(function(){O.refresh()}.bind(O),0)};J.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function yu(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}J.prototype.autosave=function(){if(yu()){var a=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(a.element.form!=null&&a.element.form!=null&&a.element.form.addEventListener("submit",function(){clearTimeout(a.autosaveTimeoutId),a.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+a.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var h=a.value();h!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,h):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var c=document.getElementById("autosaved");if(c!=null&&c!=null&&c!=""){var l=new Date,u=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(l),v=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;c.innerHTML=v+u}}else console.log("EasyMDE: localStorage not available, cannot autosave")};J.prototype.clearAutosavedValue=function(){if(yu()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};J.prototype.openBrowseFileWindow=function(a,h){var c=this,l=this.gui.toolbar.getElementsByClassName("imageInput")[0];l.click();function u(v){c.options.imageUploadFunction?c.uploadImagesUsingCustomFunction(c.options.imageUploadFunction,v.target.files):c.uploadImages(v.target.files,a,h),l.removeEventListener("change",u)}l.addEventListener("change",u)};J.prototype.uploadImage=function(a,h,c){var l=this;h=h||function(w){vu(l,w)};function u(y){l.updateStatusBar("upload-image",y),setTimeout(function(){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit)},1e4),c&&typeof c=="function"&&c(y),l.options.errorCallback(y)}function v(y){var w=l.options.imageTexts.sizeUnits.split(",");return y.replace("#image_name#",a.name).replace("#image_size#",dn(a.size,w)).replace("#image_max_size#",dn(l.options.imageMaxSize,w))}if(a.size>this.options.imageMaxSize){u(v(this.options.errorMessages.fileTooLarge));return}var d=new FormData;d.append("image",a),l.options.imageCSRFToken&&!l.options.imageCSRFHeader&&d.append(l.options.imageCSRFName,l.options.imageCSRFToken);var g=new XMLHttpRequest;g.upload.onprogress=function(y){if(y.lengthComputable){var w=""+Math.round(y.loaded*100/y.total);l.updateStatusBar("upload-image",l.options.imageTexts.sbProgress.replace("#file_name#",a.name).replace("#progress#",w))}},g.open("POST",this.options.imageUploadEndpoint),l.options.imageCSRFToken&&l.options.imageCSRFHeader&&g.setRequestHeader(l.options.imageCSRFName,l.options.imageCSRFToken),g.onload=function(){try{var y=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),u(v(l.options.errorMessages.importError));return}this.status===200&&y&&!y.error&&y.data&&y.data.filePath?h((l.options.imagePathAbsolute?"":window.location.origin+"/")+y.data.filePath):y.error&&y.error in l.options.errorMessages?u(v(l.options.errorMessages[y.error])):y.error?u(v(y.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),u(v(l.options.errorMessages.importError)))},g.onerror=function(y){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+y.target.status+" ("+y.target.statusText+")"),u(l.options.errorMessages.importError)},g.send(d)};J.prototype.uploadImageUsingCustomFunction=function(a,h){var c=this;function l(d){vu(c,d)}function u(d){var g=v(d);c.updateStatusBar("upload-image",g),setTimeout(function(){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit)},1e4),c.options.errorCallback(g)}function v(d){var g=c.options.imageTexts.sizeUnits.split(",");return d.replace("#image_name#",h.name).replace("#image_size#",dn(h.size,g)).replace("#image_max_size#",dn(c.options.imageMaxSize,g))}a.apply(this,[h,l,u])};J.prototype.setPreviewMaxHeight=function(){var a=this.codemirror,h=a.getWrapperElement(),c=h.nextSibling,l=parseInt(window.getComputedStyle(h).paddingTop),u=parseInt(window.getComputedStyle(h).borderTopWidth),v=parseInt(this.options.maxHeight),d=v+l*2+u*2,g=d.toString()+"px";c.style.height=g};J.prototype.createSideBySide=function(){var a=this.codemirror,h=a.getWrapperElement(),c=h.nextSibling;if(!c||!c.classList.contains("editor-preview-side")){if(c=document.createElement("div"),c.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var l=0;l0),a.classList.toggle("is-busy",w>0)}function N(k){var L=document.createElement("li");L.className="photo-card is-converting";var T=document.createElement("img");T.className="photo-card__thumb",T.alt=k.name||"photo";var I=document.createElement("span");return I.className="photo-card__state",I.textContent="converting\u2026",L.appendChild(T),L.appendChild(I),c&&c.appendChild(L),{li:L,img:T,state:I}}function H(k,L){var T=new FormData;return T.append("__form-name__",C("__form-name__")),T.append("__unique_form_id__",C("__unique_form_id__")),T.append("__form-file-uploader__","1"),T.append("form-nonce",C("form-nonce")),T.append("name",v),T.append("data["+v+"][]",k,L),fetch(d,{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:T,credentials:"same-origin"}).then(function(I){return I.json()}).then(function(I){if(!I||I.status==="error")throw new Error(I&&I.message||"Upload failed");return I})}function O(k){if(y>=g){M("You can attach up to "+g+" photos.","err");return}y++,w++,B();var L=N(k);Td(k).then(function(T){return T?import("./heic-to-CN7JBE7H.js").then(function(I){var z=I.heicTo||I.default&&I.default.heicTo;return z({blob:k,type:"image/jpeg",quality:.85})}):k}).then(function(T){var I=T===k,z=I&&/\.(jpe?g|png)$/i.test(k.name)?k.name:Md(k.name);try{L.img.src=URL.createObjectURL(T)}catch{}return L.state.textContent="uploading\u2026",H(T,z)}).then(function(){L.li.classList.remove("is-converting"),L.li.classList.add("is-done"),L.state.textContent="\u2713"}).catch(function(){y--,L.li.classList.remove("is-converting"),L.li.classList.add("is-error"),L.state.textContent="\u2717 skipped",M("A photo could not be processed and was skipped \u2014 the others are fine.","err")}).then(function(){w--,B()})}h.addEventListener("change",function(){M(""),Array.prototype.slice.call(h.files||[]).forEach(O),h.value=""}),u.addEventListener("submit",function(k){w>0&&(k.preventDefault(),M("Hang on \u2014 photos are still uploading.","err"))},!0)}function Cu(){window.postFormEditor=Ed(),Bd()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Cu):Cu(); +`]},Sd={link:"URL for the link:",image:"URL of the image:"},Fd={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},Ed={bold:"**",code:"```",italic:"*"},Ad={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},Ld={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:`Image #image_name# is too big (#image_size#). +Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function J(a){a=a||{},a.parent=this;var h=!0;if(a.autoDownloadFontAwesome===!1&&(h=!1),a.autoDownloadFontAwesome!==!0)for(var c=document.styleSheets,l=0;l-1&&(h=!1);if(h){var u=document.createElement("link");u.rel="stylesheet",u.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(u)}if(a.element)this.element=a.element;else if(a.element===null){console.log("EasyMDE: Error. No element was found.");return}if(a.toolbar===void 0){a.toolbar=[];for(var v in dr)Object.prototype.hasOwnProperty.call(dr,v)&&(v.indexOf("separator-")!=-1&&a.toolbar.push("|"),(dr[v].default===!0||a.showIcons&&a.showIcons.constructor===Array&&a.showIcons.indexOf(v)!=-1)&&a.toolbar.push(v))}if(Object.prototype.hasOwnProperty.call(a,"previewClass")||(a.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(a,"status")||(a.status=["autosave","lines","words","cursor"],a.uploadImage&&a.status.unshift("upload-image")),a.previewRender||(a.previewRender=function(p){return this.parent.markdown(p)}),a.parsingConfig=Rt({highlightFormatting:!0},a.parsingConfig||{}),a.insertTexts=Rt({},kd,a.insertTexts||{}),a.promptTexts=Rt({},Sd,a.promptTexts||{}),a.blockStyles=Rt({},Ed,a.blockStyles||{}),a.autosave!=null&&(a.autosave.timeFormat=Rt({},Fd,a.autosave.timeFormat||{})),a.iconClassMap=Rt({},ke,a.iconClassMap||{}),a.shortcuts=Rt({},vd,a.shortcuts||{}),a.maxHeight=a.maxHeight||void 0,a.direction=a.direction||"ltr",typeof a.maxHeight<"u"?a.minHeight=a.maxHeight:a.minHeight=a.minHeight||"300px",a.errorCallback=a.errorCallback||function(p){alert(p)},a.uploadImage=a.uploadImage||!1,a.imageMaxSize=a.imageMaxSize||2097152,a.imageAccept=a.imageAccept||"image/png, image/jpeg, image/gif, image/avif",a.imageTexts=Rt({},Ad,a.imageTexts||{}),a.errorMessages=Rt({},Ld,a.errorMessages||{}),a.imagePathAbsolute=a.imagePathAbsolute||!1,a.imageCSRFName=a.imageCSRFName||"csrfmiddlewaretoken",a.imageCSRFHeader=a.imageCSRFHeader||!1,a.imageInputName=a.imageInputName||"image",a.autosave!=null&&a.autosave.unique_id!=null&&a.autosave.unique_id!=""&&(a.autosave.uniqueId=a.autosave.unique_id),a.overlayMode&&a.overlayMode.combine===void 0&&(a.overlayMode.combine=!0),this.options=a,this.render(),a.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(a.initialValue),a.uploadImage){var f=this;this.codemirror.on("dragenter",function(p,y){f.updateStatusBar("upload-image",f.options.imageTexts.sbOnDragEnter),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragend",function(p,y){f.updateStatusBar("upload-image",f.options.imageTexts.sbInit),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragleave",function(p,y){f.updateStatusBar("upload-image",f.options.imageTexts.sbInit),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("dragover",function(p,y){f.updateStatusBar("upload-image",f.options.imageTexts.sbOnDragEnter),y.stopPropagation(),y.preventDefault()}),this.codemirror.on("drop",function(p,y){y.stopPropagation(),y.preventDefault(),a.imageUploadFunction?f.uploadImagesUsingCustomFunction(a.imageUploadFunction,y.dataTransfer.files):f.uploadImages(y.dataTransfer.files)}),this.codemirror.on("paste",function(p,y){a.imageUploadFunction?f.uploadImagesUsingCustomFunction(a.imageUploadFunction,y.clipboardData.files):f.uploadImages(y.clipboardData.files)})}}J.prototype.uploadImages=function(a,h,c){if(a.length!==0){for(var l=[],u=0;u=2){var I=B[1];if(h.imagesPreviewHandler){var H=h.imagesPreviewHandler(B[1]);typeof H=="string"&&(I=H)}if(window.EMDEimagesCache[I])N(L,window.EMDEimagesCache[I]);else{window.EMDEimagesCache[I]={};var _=document.createElement("img");_.onload=function(){window.EMDEimagesCache[I]={naturalWidth:_.naturalWidth,naturalHeight:_.naturalHeight,url:I},N(L,window.EMDEimagesCache[I])},_.src=I}}}})}this.codemirror.on("update",function(){O()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(h.autofocus===!0||a.autofocus)&&this.codemirror.focus();var z=this.codemirror;setTimeout(function(){z.refresh()}.bind(z),0)};J.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function Du(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}J.prototype.autosave=function(){if(Du()){var a=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(a.element.form!=null&&a.element.form!=null&&a.element.form.addEventListener("submit",function(){clearTimeout(a.autosaveTimeoutId),a.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+a.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var h=a.value();h!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,h):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var c=document.getElementById("autosaved");if(c!=null&&c!=null&&c!=""){var l=new Date,u=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(l),v=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;c.innerHTML=v+u}}else console.log("EasyMDE: localStorage not available, cannot autosave")};J.prototype.clearAutosavedValue=function(){if(Du()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};J.prototype.openBrowseFileWindow=function(a,h){var c=this,l=this.gui.toolbar.getElementsByClassName("imageInput")[0];l.click();function u(v){c.options.imageUploadFunction?c.uploadImagesUsingCustomFunction(c.options.imageUploadFunction,v.target.files):c.uploadImages(v.target.files,a,h),l.removeEventListener("change",u)}l.addEventListener("change",u)};J.prototype.uploadImage=function(a,h,c){var l=this;h=h||function(w){bu(l,w)};function u(y){l.updateStatusBar("upload-image",y),setTimeout(function(){l.updateStatusBar("upload-image",l.options.imageTexts.sbInit)},1e4),c&&typeof c=="function"&&c(y),l.options.errorCallback(y)}function v(y){var w=l.options.imageTexts.sizeUnits.split(",");return y.replace("#image_name#",a.name).replace("#image_size#",pn(a.size,w)).replace("#image_max_size#",pn(l.options.imageMaxSize,w))}if(a.size>this.options.imageMaxSize){u(v(this.options.errorMessages.fileTooLarge));return}var f=new FormData;f.append("image",a),l.options.imageCSRFToken&&!l.options.imageCSRFHeader&&f.append(l.options.imageCSRFName,l.options.imageCSRFToken);var p=new XMLHttpRequest;p.upload.onprogress=function(y){if(y.lengthComputable){var w=""+Math.round(y.loaded*100/y.total);l.updateStatusBar("upload-image",l.options.imageTexts.sbProgress.replace("#file_name#",a.name).replace("#progress#",w))}},p.open("POST",this.options.imageUploadEndpoint),l.options.imageCSRFToken&&l.options.imageCSRFHeader&&p.setRequestHeader(l.options.imageCSRFName,l.options.imageCSRFToken),p.onload=function(){try{var y=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),u(v(l.options.errorMessages.importError));return}this.status===200&&y&&!y.error&&y.data&&y.data.filePath?h((l.options.imagePathAbsolute?"":window.location.origin+"/")+y.data.filePath):y.error&&y.error in l.options.errorMessages?u(v(l.options.errorMessages[y.error])):y.error?u(v(y.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),u(v(l.options.errorMessages.importError)))},p.onerror=function(y){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+y.target.status+" ("+y.target.statusText+")"),u(l.options.errorMessages.importError)},p.send(f)};J.prototype.uploadImageUsingCustomFunction=function(a,h){var c=this;function l(f){bu(c,f)}function u(f){var p=v(f);c.updateStatusBar("upload-image",p),setTimeout(function(){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit)},1e4),c.options.errorCallback(p)}function v(f){var p=c.options.imageTexts.sizeUnits.split(",");return f.replace("#image_name#",h.name).replace("#image_size#",pn(h.size,p)).replace("#image_max_size#",pn(c.options.imageMaxSize,p))}a.apply(this,[h,l,u])};J.prototype.setPreviewMaxHeight=function(){var a=this.codemirror,h=a.getWrapperElement(),c=h.nextSibling,l=parseInt(window.getComputedStyle(h).paddingTop),u=parseInt(window.getComputedStyle(h).borderTopWidth),v=parseInt(this.options.maxHeight),f=v+l*2+u*2,p=f.toString()+"px";c.style.height=p};J.prototype.createSideBySide=function(){var a=this.codemirror,h=a.getWrapperElement(),c=h.nextSibling;if(!c||!c.classList.contains("editor-preview-side")){if(c=document.createElement("div"),c.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var l=0;l0),a.classList.toggle("is-busy",w>0)}function N(k){var L=document.createElement("li");L.className="photo-card is-converting";var B=document.createElement("img");B.className="photo-card__thumb",B.alt=k.name||"photo";var I=document.createElement("span");return I.className="photo-card__state",I.textContent="converting\u2026",L.appendChild(B),L.appendChild(I),c&&c.appendChild(L),{li:L,img:B,state:I}}function O(k,L){var B=new FormData;return B.append("__form-name__",D("__form-name__")),B.append("__unique_form_id__",D("__unique_form_id__")),B.append("__form-file-uploader__","1"),B.append("form-nonce",D("form-nonce")),B.append("name",v),B.append("data["+v+"][]",k,L),fetch(f,{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:B,credentials:"same-origin"}).then(function(I){return I.json()}).then(function(I){if(!I||I.status==="error")throw new Error(I&&I.message||"Upload failed");return I})}function z(k){if(y>=p){T("You can attach up to "+p+" photos.","err");return}y++,w++,M();var L=N(k);Bd(k).then(function(B){return B?import("./heic-to-CN7JBE7H.js").then(function(I){var H=I.heicTo||I.default&&I.default.heicTo;return H({blob:k,type:"image/jpeg",quality:.85})}):k}).then(function(B){var I=B===k,H=I&&/\.(jpe?g|png)$/i.test(k.name)?k.name:Nd(k.name);try{L.img.src=URL.createObjectURL(B)}catch{}return L.state.textContent="uploading\u2026",O(B,H)}).then(function(){L.li.classList.remove("is-converting"),L.li.classList.add("is-done"),L.state.textContent="\u2713"}).catch(function(){y--,L.li.classList.remove("is-converting"),L.li.classList.add("is-error"),L.state.textContent="\u2717 skipped",T("A photo could not be processed and was skipped \u2014 the others are fine.","err")}).then(function(){w--,M()})}h.addEventListener("change",function(){T(""),Array.prototype.slice.call(h.files||[]).forEach(z),h.value=""}),u.addEventListener("submit",function(k){w>0&&(k.preventDefault(),T("Hang on \u2014 photos are still uploading.","err"))},!0)}function vr(a){return document.querySelector('[name="data['+a+']"]')}function zd(){var a=Array.prototype.slice.call(document.querySelectorAll(".advanced-field"));if(a.length){var h=[];if(a.forEach(function(v){var f=v.closest(".form-field");f&&h.indexOf(f)===-1&&h.push(f)}),!!h.length){var c=document.createElement("details");c.className="more-options";var l=document.createElement("summary");l.className="more-options__summary",l.textContent="More options",c.appendChild(l),h[0].parentNode.insertBefore(c,h[0]),h.forEach(function(v){c.appendChild(v)});var u=h.some(function(v){var f=v.querySelector('input[type="text"]');if(f&&f.value.trim())return!0;var p=v.querySelector('input[type="radio"]:checked');return!!(p&&p.value&&p.value!=="0")});u&&(c.open=!0)}}}var Od={0:"Sunny",1:"Partly cloudy",2:"Partly cloudy",3:"Cloudy",45:"Foggy",48:"Foggy",51:"Drizzle",53:"Drizzle",55:"Drizzle",56:"Drizzle",57:"Drizzle",61:"Rain",63:"Rain",65:"Rain",66:"Rain",67:"Rain",80:"Rain",81:"Rain",82:"Rain",71:"Snow",73:"Snow",75:"Snow",77:"Snow",85:"Snow",86:"Snow",95:"Thunderstorm",96:"Thunderstorm",99:"Thunderstorm"};function $t(a,h,c){a&&(a.className="form-status"+(c?" form-status--"+c:""),a.textContent=h||"")}function Hd(){var a=document.getElementById("get-location"),h=document.getElementById("get-weather");if(!a&&!h)return;var c=document.getElementById("location-status"),l=document.getElementById("weather-status");function u(){var f=vr("lat"),p=vr("lng"),y=f?f.value.trim():"",w=p?p.value.trim():"";return y&&w?{lat:y,lng:w}:null}function v(){if(h){var f=!!u();h.disabled=!f,h.title=f?"":"Get location first"}}v(),a&&a.addEventListener("click",function(){if(!navigator.geolocation){$t(c,"Geolocation is not supported on this device.","err");return}a.classList.add("is-loading"),a.disabled=!0,$t(c,"Getting location\u2026"),navigator.geolocation.getCurrentPosition(function(f){var p=f.coords.latitude.toFixed(6),y=f.coords.longitude.toFixed(6),w=vr("lat"),D=vr("lng");w&&(w.value=p),D&&(D.value=y),a.classList.remove("is-loading"),a.disabled=!1,$t(c,"\u2713 Location captured \xB7 "+p+", "+y,"ok"),v()},function(f){a.classList.remove("is-loading"),a.disabled=!1,$t(c,"\u2717 "+(f&&f.message?f.message:"Could not get location")+" \u2014 enter coordinates manually if needed.","err")},{enableHighAccuracy:!0,timeout:15e3})}),h&&h.addEventListener("click",function(){var f=u();if(!f){$t(l,"Get location first, then fetch weather.","err");return}h.classList.add("is-loading"),h.disabled=!0,$t(l,"Fetching weather\u2026");var p="https://api.open-meteo.com/v1/forecast?latitude="+f.lat+"&longitude="+f.lng+"¤t=temperature_2m,weather_code&temperature_unit=celsius";fetch(p).then(function(y){return y.json()}).then(function(y){var w=Math.round(y.current.temperature_2m),D=Od[y.current.weather_code]||"Cloudy",T=vr("weather_temp_c"),M=vr("weather_desc");T&&(T.value=w),M&&(M.value=D),h.classList.remove("is-loading"),v(),$t(l,"\u2713 Weather set \xB7 "+D+" \xB7 "+w+"\xB0C (edit above if needed)","ok")}).catch(function(){h.classList.remove("is-loading"),v(),$t(l,"\u2717 Could not fetch weather \u2014 set it manually above.","err")})})}function Rd(){var a={title:"Title",content:"Content"},h=document.querySelector('form[name="new-entry"]');if(!h)return;function c(){h.querySelectorAll(".field-error").forEach(function(u){u.remove()}),h.querySelectorAll(".field-invalid").forEach(function(u){u.classList.remove("field-invalid")})}function l(u,v){u.classList.add("field-invalid");var f=document.createElement("span");f.className="field-error",f.textContent=v,u.parentNode.insertBefore(f,u.nextSibling)}h.addEventListener("submit",function(u){c();var v=null;Object.keys(a).forEach(function(f){var p=vr(f);p&&!String(p.value).trim()&&(l(p,a[f]+" is required."),v||(v=p))}),v&&(u.preventDefault(),v.focus(),v.scrollIntoView({behavior:"smooth",block:"center"}))})}function ku(){window.postFormEditor=Td(),Id(),zd(),Hd(),Rd()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ku):ku(); diff --git a/themes/intotheeast/js/src/post-form.css b/themes/intotheeast/js/src/post-form.css index 21a620a..fc59f1c 100644 --- a/themes/intotheeast/js/src/post-form.css +++ b/themes/intotheeast/js/src/post-form.css @@ -65,3 +65,176 @@ } .photo-card.is-error .photo-card__state { background: rgba(176, 0, 32, 0.85); } .photo-card.is-converting .photo-card__thumb { opacity: 0.4; } + +/* Photo picker add button + hint (U5 polish) */ +.photo-picker__add { + display: inline-flex; + align-items: center; + gap: var(--space-2); + cursor: pointer; +} +.photo-picker.is-busy .photo-picker__add { + opacity: 0.6; + pointer-events: none; +} +.photo-picker__hint:empty { display: none; } +.photo-picker__reauth-hint { + display: none; + font-size: var(--text-sm); + color: var(--color-ink-muted); + margin-top: var(--space-2); +} +.photo-picker__reauth-hint.is-shown { display: block; } + +/* ── Field Notes styling for the new controls (U5, R11/R12) ── */ + +/* Select fields (weather condition, transport mode) match the text inputs. */ +.post-form-wrap select { + width: 100%; + font-family: var(--font-ui); + font-size: var(--text-base); + padding: 0.875rem 1rem; + min-height: 44px; + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-canvas); + color: var(--color-ink); + -webkit-appearance: none; + appearance: none; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2390887E' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-position: right 1rem center; + padding-right: 2.5rem; +} +.post-form-wrap select:focus { + outline: 2px solid var(--color-accent); + outline-offset: 1px; + border-color: var(--color-accent); +} +.post-form-wrap input[type="number"] { + width: 100%; + font-family: var(--font-ui); + font-size: var(--text-base); + padding: 0.875rem 1rem; + min-height: 44px; + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-canvas); + color: var(--color-ink); + -webkit-appearance: none; + appearance: none; +} +.post-form-wrap input[type="number"]:focus { + outline: 2px solid var(--color-accent); + outline-offset: 1px; + border-color: var(--color-accent); +} + +/* "More options" disclosure */ +.more-options { + margin-bottom: var(--space-5); + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-canvas); +} +.more-options__summary { + cursor: pointer; + padding: 0.875rem 1rem; + min-height: 44px; + display: flex; + align-items: center; + font-family: var(--font-ui); + font-size: var(--text-sm); + font-weight: 600; + color: var(--color-ink); + list-style: none; + user-select: none; +} +.more-options__summary::-webkit-details-marker { display: none; } +.more-options__summary::before { + content: '▸'; + margin-right: var(--space-2); + color: var(--color-ink-muted); + transition: transform 0.15s; +} +.more-options[open] .more-options__summary::before { transform: rotate(90deg); } +.more-options[open] .more-options__summary { border-bottom: 1px solid var(--color-border); } +.more-options > .form-field { padding: 0 1rem; } +.more-options > .form-field:first-of-type { padding-top: var(--space-4); } +.more-options > .form-field:last-child { padding-bottom: var(--space-4); margin-bottom: 0; } + +/* Button loading spinner (Get Location / Get Weather) */ +.btn-action.is-loading { position: relative; color: transparent; pointer-events: none; } +.btn-action.is-loading::after { + content: ''; + position: absolute; + top: 50%; + left: 50%; + width: 16px; + height: 16px; + margin: -8px 0 0 -8px; + border: 2px solid var(--color-ink-muted); + border-top-color: var(--color-accent); + border-radius: 50%; + animation: post-spin 0.7s linear infinite; +} +.btn-action[disabled] { opacity: 0.5; cursor: not-allowed; } +@keyframes post-spin { to { transform: rotate(360deg); } } + +/* Grav form save/validation messages (success + error from the server) */ +.post-form-wrap .form-messages { margin-bottom: var(--space-5); } +.post-form-wrap .form-message { + padding: 0.875rem 1rem; + border-radius: var(--radius-md); + font-size: var(--text-sm); + margin-bottom: var(--space-2); +} +.post-form-wrap .form-message.notice, +.post-form-wrap .form-message.error { + background: var(--color-accent-light); + color: var(--color-ink); + border: 1px solid var(--color-error); +} +.post-form-wrap .form-message.success { + background: var(--color-accent-light); + color: var(--color-ink); + border: 1px solid var(--color-accent); +} + +/* ── EasyMDE — Field Notes dark theme (U5) ─────────────────── */ +.EasyMDEContainer .CodeMirror { + background: var(--color-canvas); + color: var(--color-ink); + border: 1px solid var(--color-border); + border-radius: 0 0 var(--radius-md) var(--radius-md); + font-family: var(--font-ui); + font-size: var(--text-base); + line-height: var(--leading-normal); + padding: var(--space-1); +} +.EasyMDEContainer .CodeMirror-cursor { border-color: var(--color-ink); } +.EasyMDEContainer .CodeMirror-selected { background: var(--color-accent-light) !important; } +.EasyMDEContainer .editor-toolbar { + background: var(--color-surface-raised); + border: 1px solid var(--color-border); + border-bottom: none; + border-radius: var(--radius-md) var(--radius-md) 0 0; + opacity: 1; +} +.EasyMDEContainer .editor-toolbar button { + color: var(--color-ink) !important; + min-width: 34px; + height: 34px; +} +.EasyMDEContainer .editor-toolbar button:hover, +.EasyMDEContainer .editor-toolbar button.active { + background: var(--color-accent-light); + border-color: var(--color-border); +} +.EasyMDEContainer .editor-toolbar i.separator { border-color: var(--color-border); } +.EasyMDEContainer .editor-preview, +.EasyMDEContainer .editor-preview-side { + background: var(--color-canvas); + color: var(--color-ink); +} +.EasyMDEContainer .editor-preview a { color: var(--color-accent); } diff --git a/themes/intotheeast/js/src/post-form.js b/themes/intotheeast/js/src/post-form.js index cdc2dbd..f2ef61a 100644 --- a/themes/intotheeast/js/src/post-form.js +++ b/themes/intotheeast/js/src/post-form.js @@ -212,12 +212,204 @@ function initPhotoPicker() { }, true); } +/* ── Field helper ────────────────────────────────────────── */ +// Attribute selector matches input, select AND textarea — unlike the old +// input[...] lookup, which broke once weather_desc became a + * weather_desc field and expose idle/loading/success/error states. + */ +var WMO_MAP = { + 0: 'Sunny', 1: 'Partly cloudy', 2: 'Partly cloudy', 3: 'Cloudy', + 45: 'Foggy', 48: 'Foggy', + 51: 'Drizzle', 53: 'Drizzle', 55: 'Drizzle', 56: 'Drizzle', 57: 'Drizzle', + 61: 'Rain', 63: 'Rain', 65: 'Rain', 66: 'Rain', 67: 'Rain', 80: 'Rain', 81: 'Rain', 82: 'Rain', + 71: 'Snow', 73: 'Snow', 75: 'Snow', 77: 'Snow', 85: 'Snow', 86: 'Snow', + 95: 'Thunderstorm', 96: 'Thunderstorm', 99: 'Thunderstorm' +}; + +function setStatus(el, msg, kind) { + if (!el) return; + el.className = 'form-status' + (kind ? ' form-status--' + kind : ''); + el.textContent = msg || ''; +} + +function initGeo() { + var locBtn = document.getElementById('get-location'); + var wxBtn = document.getElementById('get-weather'); + if (!locBtn && !wxBtn) return; + + var locStatus = document.getElementById('location-status'); + var wxStatus = document.getElementById('weather-status'); + + function coords() { + var latEl = field('lat'); + var lngEl = field('lng'); + var lat = latEl ? latEl.value.trim() : ''; + var lng = lngEl ? lngEl.value.trim() : ''; + return (lat && lng) ? { lat: lat, lng: lng } : null; + } + + // Get Weather is meaningless without coordinates — gate it (R18). + function syncWeatherEnabled() { + if (!wxBtn) return; + var ok = !!coords(); + wxBtn.disabled = !ok; + wxBtn.title = ok ? '' : 'Get location first'; + } + syncWeatherEnabled(); + + if (locBtn) { + locBtn.addEventListener('click', function () { + if (!navigator.geolocation) { + setStatus(locStatus, 'Geolocation is not supported on this device.', 'err'); + return; + } + locBtn.classList.add('is-loading'); + locBtn.disabled = true; + setStatus(locStatus, 'Getting location…'); + navigator.geolocation.getCurrentPosition(function (pos) { + var lat = pos.coords.latitude.toFixed(6); + var lng = pos.coords.longitude.toFixed(6); + var latEl = field('lat'); + var lngEl = field('lng'); + if (latEl) latEl.value = lat; + if (lngEl) lngEl.value = lng; + locBtn.classList.remove('is-loading'); + locBtn.disabled = false; + setStatus(locStatus, '✓ Location captured · ' + lat + ', ' + lng, 'ok'); + syncWeatherEnabled(); + }, function (err) { + locBtn.classList.remove('is-loading'); + locBtn.disabled = false; + setStatus(locStatus, '✗ ' + (err && err.message ? err.message : 'Could not get location') + ' — enter coordinates manually if needed.', 'err'); + }, { enableHighAccuracy: true, timeout: 15000 }); + }); + } + + if (wxBtn) { + wxBtn.addEventListener('click', function () { + var c = coords(); + if (!c) { + setStatus(wxStatus, 'Get location first, then fetch weather.', 'err'); + return; + } + wxBtn.classList.add('is-loading'); + wxBtn.disabled = true; + setStatus(wxStatus, 'Fetching weather…'); + var url = 'https://api.open-meteo.com/v1/forecast?latitude=' + c.lat + + '&longitude=' + c.lng + '¤t=temperature_2m,weather_code&temperature_unit=celsius'; + fetch(url).then(function (r) { return r.json(); }).then(function (data) { + var temp = Math.round(data.current.temperature_2m); + var desc = WMO_MAP[data.current.weather_code] || 'Cloudy'; + var tempEl = field('weather_temp_c'); + var descEl = field('weather_desc'); + if (tempEl) tempEl.value = temp; + if (descEl) descEl.value = desc; // works for