@streamline-pulse/formkrafter-wc 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/components/fk-brick-render.js +1 -1
  2. package/dist/components/fk-code-editor.js +1 -1
  3. package/dist/components/fk-data-grid.js +1 -1
  4. package/dist/components/fk-file-input.js +1 -1
  5. package/dist/components/fk-form-builder.js +1 -1
  6. package/dist/components/fk-form-render.js +1 -1
  7. package/dist/components/fk-property-panel.js +1 -1
  8. package/dist/components/fk-rules-editor.js +1 -1
  9. package/dist/components/fk-select-input.js +1 -1
  10. package/dist/components/fk-stepper.js +1 -1
  11. package/dist/components/fk-tabs.js +1 -1
  12. package/dist/components/index.js +1 -1
  13. package/dist/components/p-2Yg5YU28.js +1 -0
  14. package/dist/components/{p-BYhtwUM4.js → p-38x7HHH5.js} +4 -4
  15. package/dist/components/{p-CKAZ15-B.js → p-8ZeGXEsz.js} +1 -1
  16. package/dist/components/{p-DQKpUpzo.js → p-B7Wn62C3.js} +1 -1
  17. package/dist/components/{p-dFTWRHWl.js → p-B87l6fG8.js} +1 -1
  18. package/dist/components/{p-BQIUKz-H.js → p-CBWGephQ.js} +1 -1
  19. package/dist/{formkrafter-wc/p-_JpQ28sq.js → components/p-CtXlkz3R.js} +1 -1
  20. package/dist/components/{p-BJ7u_t3N.js → p-CzZHZjz2.js} +1 -1
  21. package/dist/components/{p-COkZvRcY.js → p-DRCnedSc.js} +1 -1
  22. package/dist/components/p-DX8WH8Dt.js +1 -0
  23. package/dist/{formkrafter-wc/p-DOTbu58d.js → components/p-DZTNUdkF.js} +1 -1
  24. package/dist/components/{p-C3SjLyf4.js → p-Dh3ei8wT.js} +1 -1
  25. package/dist/components/{p-CAilSzZp.js → p-Do6vaAvb.js} +1 -1
  26. package/dist/components/{p-DtO4LFLi.js → p-YFczER4B.js} +1 -1
  27. package/dist/components/p-jUqF8CGO.js +1 -0
  28. package/dist/components/p-p20GeeQY.js +1 -0
  29. package/dist/components/{p-DyI9tTC9.js → p-x9Ll7hS1.js} +1 -1
  30. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
  31. package/dist/formkrafter-wc/index.esm.js +1 -1
  32. package/dist/formkrafter-wc/{p-DvzB4zo1.js → p-C7yLpAp-.js} +2 -2
  33. package/dist/{components/p-_JpQ28sq.js → formkrafter-wc/p-CtXlkz3R.js} +1 -1
  34. package/dist/formkrafter-wc/{p-BJ7u_t3N.js → p-CzZHZjz2.js} +1 -1
  35. package/dist/{components/p-DOTbu58d.js → formkrafter-wc/p-DZTNUdkF.js} +1 -1
  36. package/dist/formkrafter-wc/{p-CAilSzZp.js → p-Do6vaAvb.js} +1 -1
  37. package/dist/formkrafter-wc/{p-BjBiz89q.js → p-NJy5rYft.js} +1 -1
  38. package/dist/formkrafter-wc/p-c48f97e1.entry.js +1 -0
  39. package/dist/formkrafter-wc/p-jUqF8CGO.js +1 -0
  40. package/package.json +2 -2
  41. package/dist/components/p-BKT368_B.js +0 -1
  42. package/dist/components/p-CV2J_nG8.js +0 -1
  43. package/dist/components/p-CfLRuUU4.js +0 -1
  44. package/dist/components/p-Cg-VvkW4.js +0 -1
  45. package/dist/formkrafter-wc/p-954e842c.entry.js +0 -1
  46. package/dist/formkrafter-wc/p-CfLRuUU4.js +0 -1
@@ -1 +1 @@
1
- import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-CfLRuUU4.js";import{s as O,b as $}from"./p-_JpQ28sq.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function L(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function S(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class C{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function j(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const B=t.define();function F(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class U{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const H=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:q,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>_(t(i),e(i)),optionClass:(t,e)=>i=>_(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function _(t,e){return t?e?t+" "+e:t:e}function q(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const K=o.define();function Q(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class J{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(H);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=Q(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:K.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(H).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=Q(o.length,r,t.state.facet(H).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Q(e.options.length,e.selected,this.view.state.facet(H).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(H).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function N(t,e){return i=>new J(i,t,e)}function X(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class G{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new G(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(H);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new C(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new U(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new C(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):X(t.completion)>X(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(H).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new G(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new G(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new G(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(H),n=(i.override||e.languageDataAt("autocomplete",j(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=G.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(K)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(B);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(j(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=j(t.state);if(s>r||!n||2&e&&(j(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:j(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...F(t.state,i,n.from,n.to),annotations:B.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=N(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(H).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:K.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(H).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(H);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=j(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(H),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=j(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(H).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[B.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function Lt(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const St=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),Ct=Lt(1),jt=Lt(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Bt(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Ft=[{key:"Tab",run:Ct,shift:jt},{key:"Escape",run:St}],Rt=e.define({combine:t=>t.length?t[0]:Ft}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ut=Object.create(null);function Ht(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function _t(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of _t(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ht(s,i,l,c,o-r);r+=s.length+1}}else Ht(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const qt=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=_t(t.state.doc,function(t){return Ut[t]||(Ut[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},Kt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Qt=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Jt=new class extends d{};Jt.startSide=1,Jt.endSide=-1;const Nt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(Qt)&&(t=t.update({add:[Jt.range(i.value,i.value+1)]}));return t}});function Xt(){return[ee,Nt]}const Gt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Gt.charCodeAt(e)==t)return Gt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||Kt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||Kt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||Kt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||Kt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Nt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:Qt.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:Qt.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||Kt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:Qt.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,H.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([H],(t=>t.facet(H).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return K.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,St as clearSnippet,Xt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,qt as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Bt as hasPrevSnippetField,L as ifIn,S as ifNotIn,oe as insertBracket,F as insertCompletionText,ht as moveCompletionSelection,Ct as nextSnippetField,B as pickedCompletion,jt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}
1
+ import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-jUqF8CGO.js";import{s as O,b as $}from"./p-CtXlkz3R.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function C(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function S(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class j{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function L(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const F=t.define();function B(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class U{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const H=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:K,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>q(t(i),e(i)),optionClass:(t,e)=>i=>q(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function q(t,e){return t?e?t+" "+e:t:e}function K(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const X=o.define();function _(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class G{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(H);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=_(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:X.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(H).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=_(o.length,r,t.state.facet(H).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=_(e.options.length,e.selected,this.view.state.facet(H).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(H).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function N(t,e){return i=>new G(i,t,e)}function Q(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class J{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new J(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(H);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new j(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new U(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new j(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):Q(t.completion)>Q(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(H).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new J(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new J(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new J(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(H),n=(i.override||e.languageDataAt("autocomplete",L(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=J.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(X)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(F);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(L(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=L(t.state);if(s>r||!n||2&e&&(L(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:L(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...B(t.state,i,n.from,n.to),annotations:F.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=N(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(H).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:X.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(H).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(H);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=L(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(H),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=L(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(H).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[F.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function Ct(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const St=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),jt=Ct(1),Lt=Ct(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Ft(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Bt=[{key:"Tab",run:jt,shift:Lt},{key:"Escape",run:St}],Rt=e.define({combine:t=>t.length?t[0]:Bt}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ut=Object.create(null);function Ht(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function qt(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of qt(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ht(s,i,l,c,o-r);r+=s.length+1}}else Ht(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const Kt=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=qt(t.state.doc,function(t){return Ut[t]||(Ut[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},Xt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_t=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Gt=new class extends d{};Gt.startSide=1,Gt.endSide=-1;const Nt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(_t)&&(t=t.update({add:[Gt.range(i.value,i.value+1)]}));return t}});function Qt(){return[ee,Nt]}const Jt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Jt.charCodeAt(e)==t)return Jt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||Xt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||Xt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||Xt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||Xt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Nt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:_t.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:_t.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||Xt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:_t.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:_t.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,H.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([H],(t=>t.facet(H).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return X.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,St as clearSnippet,Qt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,Kt as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Ft as hasPrevSnippetField,C as ifIn,S as ifNotIn,oe as insertBracket,B as insertCompletionText,ht as moveCompletionSelection,jt as nextSnippetField,F as pickedCompletion,Lt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}
@@ -1 +1 @@
1
- import{t as e,p as t,H as s,c as o,h as r}from"./p-BB4Llg42.js";import{a}from"./p-BYhtwUM4.js";import{a as l,f as i}from"./p-bZPtT8wr.js";import{d as p}from"./p-CKAZ15-B.js";import{d as n}from"./p-CV2J_nG8.js";const c=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickConfigsChange=o(this,"brickConfigsChange"),this.brickValidationsChange=o(this,"brickValidationsChange"),this.brickStylesChange=o(this,"brickStylesChange"),this.fields=[],this.locales=[],this.activeTab="config",this.newStyleKey=""}onBrickChange(){this.availableTabs().some((e=>e.id===this.activeTab))||(this.activeTab="config")}availableTabs(){const e=[{id:"config",label:l("panel.tab.config")}];return"input"===this.brick.type&&e.push({id:"validation",label:l("panel.tab.validation")}),e.push({id:"styles",label:l("panel.tab.styles")},{id:"rules",label:l("panel.tab.rules")}),e}localized(e,t){var s;if(this.locales.length<=1)return t||void 0;const o=a(e)?Object.assign({},e):{};return"string"==typeof e&&e&&!a(e)&&(o[this.locales[0]]=e),o[null!==(s=this.editLocale)&&void 0!==s?s:this.locales[0]]=t,o}readLocalized(e){var t,s,o;return a(e)?null!==(s=e[null!==(t=this.editLocale)&&void 0!==t?t:this.locales[0]])&&void 0!==s?s:"":null!==(o=e)&&void 0!==o?o:""}writeTextConfig(e,t){var s;this.emitConfigs({[e]:this.localized(null===(s=this.brick.configs)||void 0===s?void 0:s[e],t)})}emitConfigs(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickConfigsChange.emit({configs:e,uid:s})}emitValidations(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickValidationsChange.emit({validations:e,uid:s})}emitStyles(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickStylesChange.emit({styles:e,uid:s})}validationOf(e){var t;return null===(t=this.brick.validations)||void 0===t?void 0:t.find((t=>t.validator===e))}setValidation(e,t,s={}){var o;const r=this.validationOf(e),a=(null!==(o=this.brick.validations)&&void 0!==o?o:[]).filter((t=>t.validator!==e));this.emitValidations(t?[...a,Object.assign(Object.assign(Object.assign({},r),{validator:e}),s)]:a)}addStyle(e){const t=this.newStyleKey.trim();t&&(this.emitStyles({[t]:e}),this.newStyleKey="")}textField(e,t,s){var o;return r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},e),r("input",{class:"fk-props__input",type:"text",value:null!==(o=t)&&void 0!==o?o:"",onChange:e=>s(e.target.value)}))}optionsFields(){var e,t,s;const o=this.brick.configs;if(!o||!("options"in o)&&!("optionsSource"in o))return[];const a="optionsSource"in o,i=a&&null!==(e=o.optionsSource)&&void 0!==e?e:"static",p=a?[r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.optionsSource")),r("select",{class:"fk-props__input",onChange:e=>this.emitConfigs({optionsSource:e.target.value})},["static","dataMap","remote","js","catalog"].map((e=>r("option",{value:e,selected:e===i},e)))))]:[];return"static"===i&&p.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.options")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("options",e.target.value)},this.readLocalized(o.options)))),"dataMap"===i&&p.push(this.textField(l("panel.dataKey"),o.optionsPath,(e=>this.emitConfigs({optionsPath:e})))),"remote"===i&&p.push(this.textField(l("panel.url"),o.optionsUrl,(e=>this.emitConfigs({optionsUrl:e}))),r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.headers")),r("textarea",{class:"fk-props__input fk-props__input--textarea",placeholder:"Authorization: Bearer {token}",onChange:e=>this.emitConfigs({optionsHeaders:e.target.value||void 0})},null!==(t=o.optionsHeaders)&&void 0!==t?t:"")),this.textField(l("panel.searchParam"),o.searchParam,(e=>this.emitConfigs({searchParam:e||void 0})))),"js"===i&&p.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},"Code"),r("fk-code-editor",{completions:this.fields,value:null!==(s=o.optionsCode)&&void 0!==s?s:"",placeholder:"return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];",onCodeChange:e=>this.emitConfigs({optionsCode:e.detail})}))),"catalog"===i&&p.push(this.textField(l("panel.optionsRef"),o.optionsRef,(e=>this.emitConfigs({optionsRef:e})))),"remote"!==i&&"js"!==i&&"catalog"!==i||p.push(this.textField(l("panel.labelKey"),o.labelKey,(e=>this.emitConfigs({labelKey:e}))),this.textField(l("panel.valueKey"),o.valueKey,(e=>this.emitConfigs({valueKey:e})))),p}renderConfigTab(){const e=this.brick.configs,t="input"===this.brick.type;return r("section",{class:"fk-props__section"},this.textField(l("panel.key"),null==e?void 0:e.key,(e=>this.emitConfigs({key:e}))),this.textField(l("panel.label"),this.readLocalized(null==e?void 0:e.label),(e=>this.writeTextConfig("label",e))),t?[this.textField(l("panel.placeholder"),this.readLocalized(null==e?void 0:e.placeholder),(e=>this.writeTextConfig("placeholder",e))),this.textField(l("panel.prefix"),null==e?void 0:e.prefix,(e=>this.emitConfigs({prefix:e||void 0}))),this.textField(l("panel.suffix"),null==e?void 0:e.suffix,(e=>this.emitConfigs({suffix:e||void 0})))]:null,e&&"specRef"in e?this.textField(i("panel.specRef","Referenced form (specRef)"),e.specRef,(e=>this.emitConfigs({specRef:e}))):null,e&&"mask"in e?this.textField(i("panel.mask","Input mask (9=digit, a=letter, *=any)"),e.mask,(e=>this.emitConfigs({mask:e}))):null,e&&"accept"in e?this.textField(i("panel.accept","Accepted file types"),e.accept,(e=>this.emitConfigs({accept:e}))):null,e&&"uploadUrl"in e?this.textField(i("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e}))):null,this.optionsFields(),Object.entries(null!=e?e:{}).filter((([,e])=>"boolean"==typeof e)).map((([e,t])=>r("label",{class:"fk-props__field fk-props__field--inline",key:e},r("input",{type:"checkbox",checked:!0===t,onChange:t=>this.emitConfigs({[e]:t.target.checked})}),r("span",{class:"fk-props__label"},i(`panel.cfg.${e}`,e))))),e&&"content"in e?r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.content")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("content",e.target.value)},this.readLocalized(e.content))):null)}validationRow(e,t,s){const o=this.validationOf(e);return r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!o,onChange:t=>this.setValidation(e,t.target.checked)}),r("span",{class:"fk-props__label"},t)),o&&s?r("input",{class:"fk-props__input",type:s,placeholder:"number"===s?"value":"regex",value:null==o.value?"":String(o.value),onChange:t=>{const o=t.target.value;this.setValidation(e,!0,{value:"number"===s?""===o?void 0:Number(o):o||void 0})}}):null,o?this.textField(l("panel.errorMessage"),this.readLocalized(o.message),(t=>this.setValidation(e,!0,{message:this.localized(o.message,t)}))):null)}renderValidationTab(){var e;const t=this.brick.dataType,s=this.validationOf("custom");return r("section",{class:"fk-props__section"},this.validationRow("required",l("panel.required")),"string"===t?[this.validationRow("minLength",l("panel.minLength"),"number"),this.validationRow("maxLength",l("panel.maxLength"),"number"),this.validationRow("pattern",l("panel.pattern"),"text"),this.validationRow("email",l("panel.emailFormat")),this.validationRow("url",l("panel.urlFormat"))]:null,"number"===t?[this.validationRow("min",l("panel.min"),"number"),this.validationRow("max",l("panel.max"),"number")]:null,"array"===t?[this.validationRow("minItems",l("panel.minItems"),"number"),this.validationRow("maxItems",l("panel.maxItems"),"number")]:null,r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!s,onChange:e=>{var t;return this.setValidation("custom",e.target.checked,{customValidator:null!==(t=null==s?void 0:s.customValidator)&&void 0!==t?t:"return true;"})}}),r("span",{class:"fk-props__label"},l("panel.custom"))),s?r("fk-code-editor",{completions:this.fields,value:null!==(e=s.customValidator)&&void 0!==e?e:"",placeholder:'return value?.startsWith("BJ-") ? true : "Must start with BJ-";',onCodeChange:e=>this.setValidation("custom",!0,{customValidator:e.detail})}):null,s?this.textField(l("panel.fallbackMessage"),this.readLocalized(s.message),(e=>this.setValidation("custom",!0,{message:this.localized(s.message,e)}))):null))}renderStylesTab(){var e;return r("section",{class:"fk-props__section"},Object.entries(null!==(e=this.brick.styles)&&void 0!==e?e:{}).map((([e,t])=>r("div",{class:"fk-props__style-row",key:e},r("span",{class:"fk-props__style-key"},e),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",value:String(null!=t?t:""),onChange:t=>this.emitStyles({[e]:t.target.value})}),r("button",{type:"button",class:"fk-props__remove",title:"Remove style",onClick:()=>this.emitStyles({[e]:void 0})},"✕")))),r("div",{class:"fk-props__style-row"},r("input",{class:"fk-props__input",type:"text",placeholder:l("panel.styleProperty"),value:this.newStyleKey,onInput:e=>this.newStyleKey=e.target.value}),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",placeholder:l("panel.styleValue"),onChange:e=>{const t=e.target;this.addStyle(t.value),t.value=""}})))}render(){return r("div",{key:"7903cc72f8462cc4fb33c04a886265157d10244e",class:"fk-props"},r("header",{key:"7918774557a0a4f8a835e25148833d24d669beac",class:"fk-props__header"},r("span",{key:"46f227ec676661ef7e70313a0c76a1f0c047e462",class:"fk-props__type"},this.brick.type),r("h4",{key:"9b96042938efa4d6e7193eb91f1776d1272d5bc7",class:"fk-props__title"},i(`brick.${this.brick.id}.name`,this.brick.name))),r("div",{key:"809d87d577a7127c86f23ff2e37d621a2340ca6b",class:"fk-props__tabs"},this.availableTabs().map((e=>r("button",{key:e.id,type:"button",class:{"fk-props__tab":!0,"fk-props__tab--active":this.activeTab===e.id},onClick:()=>this.activeTab=e.id},e.label)))),"config"===this.activeTab?this.renderConfigTab():null,"validation"===this.activeTab?this.renderValidationTab():null,"styles"===this.activeTab?this.renderStylesTab():null,"rules"===this.activeTab?r("section",{class:"fk-props__section"},r("fk-rules-editor",{brick:this.brick,fields:this.fields})):null)}static get watchers(){return{brick:[{onBrickChange:0}]}}static get style(){return".sc-fk-property-panel-h{display:block}.fk-props.sc-fk-property-panel{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) * 1.5)}.fk-props__header.sc-fk-property-panel{display:flex;flex-direction:column;gap:2px}.fk-props__type.sc-fk-property-panel{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-primary)}.fk-props__title.sc-fk-property-panel{margin:0;font-size:0.95rem;color:var(--fk-color-text)}.fk-props__section.sc-fk-property-panel{display:flex;flex-direction:column;gap:var(--fk-spacing);padding-top:var(--fk-spacing)}.fk-props__tabs.sc-fk-property-panel{display:flex;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-props__tab.sc-fk-property-panel{font:inherit;font-size:0.72rem;font-weight:600;padding:5px 9px;border:none;border-bottom:2px solid transparent;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-props__tab.sc-fk-property-panel:hover{color:var(--fk-color-text)}.fk-props__tab--active.sc-fk-property-panel{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary)}.fk-props__section-title.sc-fk-property-panel{margin:0;font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-props__field.sc-fk-property-panel{display:flex;flex-direction:column;gap:4px}.fk-props__field--inline.sc-fk-property-panel{flex-direction:row;align-items:center;gap:8px}.fk-props__label.sc-fk-property-panel{font-size:0.75rem;font-weight:600;color:var(--fk-color-muted)}.fk-props__input.sc-fk-property-panel{font:inherit;font-size:0.85rem;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-props__input.sc-fk-property-panel:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-props__input--textarea.sc-fk-property-panel{min-height:72px;resize:vertical}.fk-props__vrule.sc-fk-property-panel{display:flex;flex-direction:column;gap:6px;padding:calc(var(--fk-spacing) / 1.5);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5)}.fk-props__style-row.sc-fk-property-panel{display:flex;align-items:center;gap:6px}.fk-props__style-key.sc-fk-property-panel{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;color:var(--fk-color-text);min-width:72px}.fk-props__input--grow.sc-fk-property-panel{flex:1;min-width:0}.fk-props__remove.sc-fk-property-panel{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-props__remove.sc-fk-property-panel:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}"}},[2,"fk-property-panel",{brick:[16],fields:[16],locales:[16],editLocale:[1,"edit-locale"],activeTab:[32],newStyleKey:[32]},void 0,{brick:[{onBrickChange:0}]}]);function f(){"undefined"!=typeof customElements&&["fk-property-panel","fk-code-editor","fk-rules-editor"].forEach((t=>{switch(t){case"fk-property-panel":customElements.get(e(t))||customElements.define(e(t),c);break;case"fk-code-editor":customElements.get(e(t))||p();break;case"fk-rules-editor":customElements.get(e(t))||n()}}))}f();export{c as F,f as d}
1
+ import{t as e,p as t,H as s,c as o,h as r}from"./p-BB4Llg42.js";import{a}from"./p-38x7HHH5.js";import{a as l,f as i}from"./p-bZPtT8wr.js";import{d as p}from"./p-8ZeGXEsz.js";import{d as n}from"./p-DX8WH8Dt.js";const c=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickConfigsChange=o(this,"brickConfigsChange"),this.brickValidationsChange=o(this,"brickValidationsChange"),this.brickStylesChange=o(this,"brickStylesChange"),this.fields=[],this.locales=[],this.activeTab="config",this.newStyleKey=""}onBrickChange(){this.availableTabs().some((e=>e.id===this.activeTab))||(this.activeTab="config")}availableTabs(){const e=[{id:"config",label:l("panel.tab.config")}];return"input"===this.brick.type&&e.push({id:"validation",label:l("panel.tab.validation")}),e.push({id:"styles",label:l("panel.tab.styles")},{id:"rules",label:l("panel.tab.rules")}),e}localized(e,t){var s;if(this.locales.length<=1)return t||void 0;const o=a(e)?Object.assign({},e):{};return"string"==typeof e&&e&&!a(e)&&(o[this.locales[0]]=e),o[null!==(s=this.editLocale)&&void 0!==s?s:this.locales[0]]=t,o}readLocalized(e){var t,s,o;return a(e)?null!==(s=e[null!==(t=this.editLocale)&&void 0!==t?t:this.locales[0]])&&void 0!==s?s:"":null!==(o=e)&&void 0!==o?o:""}writeTextConfig(e,t){var s;this.emitConfigs({[e]:this.localized(null===(s=this.brick.configs)||void 0===s?void 0:s[e],t)})}emitConfigs(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickConfigsChange.emit({configs:e,uid:s})}emitValidations(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickValidationsChange.emit({validations:e,uid:s})}emitStyles(e){var t;const s=null===(t=this.brick.configs)||void 0===t?void 0:t.uid;s&&this.brickStylesChange.emit({styles:e,uid:s})}validationOf(e){var t;return null===(t=this.brick.validations)||void 0===t?void 0:t.find((t=>t.validator===e))}setValidation(e,t,s={}){var o;const r=this.validationOf(e),a=(null!==(o=this.brick.validations)&&void 0!==o?o:[]).filter((t=>t.validator!==e));this.emitValidations(t?[...a,Object.assign(Object.assign(Object.assign({},r),{validator:e}),s)]:a)}addStyle(e){const t=this.newStyleKey.trim();t&&(this.emitStyles({[t]:e}),this.newStyleKey="")}textField(e,t,s){var o;return r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},e),r("input",{class:"fk-props__input",type:"text",value:null!==(o=t)&&void 0!==o?o:"",onChange:e=>s(e.target.value)}))}optionsFields(){var e,t,s;const o=this.brick.configs;if(!o||!("options"in o)&&!("optionsSource"in o))return[];const a="optionsSource"in o,i=a&&null!==(e=o.optionsSource)&&void 0!==e?e:"static",p=a?[r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.optionsSource")),r("select",{class:"fk-props__input",onChange:e=>this.emitConfigs({optionsSource:e.target.value})},["static","dataMap","remote","js","catalog"].map((e=>r("option",{value:e,selected:e===i},e)))))]:[];return"static"===i&&p.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.options")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("options",e.target.value)},this.readLocalized(o.options)))),"dataMap"===i&&p.push(this.textField(l("panel.dataKey"),o.optionsPath,(e=>this.emitConfigs({optionsPath:e})))),"remote"===i&&p.push(this.textField(l("panel.url"),o.optionsUrl,(e=>this.emitConfigs({optionsUrl:e}))),r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.headers")),r("textarea",{class:"fk-props__input fk-props__input--textarea",placeholder:"Authorization: Bearer {token}",onChange:e=>this.emitConfigs({optionsHeaders:e.target.value||void 0})},null!==(t=o.optionsHeaders)&&void 0!==t?t:"")),this.textField(l("panel.searchParam"),o.searchParam,(e=>this.emitConfigs({searchParam:e||void 0})))),"js"===i&&p.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},"Code"),r("fk-code-editor",{completions:this.fields,value:null!==(s=o.optionsCode)&&void 0!==s?s:"",placeholder:"return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];",onCodeChange:e=>this.emitConfigs({optionsCode:e.detail})}))),"catalog"===i&&p.push(this.textField(l("panel.optionsRef"),o.optionsRef,(e=>this.emitConfigs({optionsRef:e})))),"remote"!==i&&"js"!==i&&"catalog"!==i||p.push(this.textField(l("panel.labelKey"),o.labelKey,(e=>this.emitConfigs({labelKey:e}))),this.textField(l("panel.valueKey"),o.valueKey,(e=>this.emitConfigs({valueKey:e})))),p}renderConfigTab(){const e=this.brick.configs,t="input"===this.brick.type;return r("section",{class:"fk-props__section"},this.textField(l("panel.key"),null==e?void 0:e.key,(e=>this.emitConfigs({key:e}))),this.textField(l("panel.label"),this.readLocalized(null==e?void 0:e.label),(e=>this.writeTextConfig("label",e))),t?[this.textField(l("panel.placeholder"),this.readLocalized(null==e?void 0:e.placeholder),(e=>this.writeTextConfig("placeholder",e))),this.textField(l("panel.prefix"),null==e?void 0:e.prefix,(e=>this.emitConfigs({prefix:e||void 0}))),this.textField(l("panel.suffix"),null==e?void 0:e.suffix,(e=>this.emitConfigs({suffix:e||void 0})))]:null,e&&"specRef"in e?this.textField(i("panel.specRef","Referenced form (specRef)"),e.specRef,(e=>this.emitConfigs({specRef:e}))):null,e&&"mask"in e?this.textField(i("panel.mask","Input mask (9=digit, a=letter, *=any)"),e.mask,(e=>this.emitConfigs({mask:e}))):null,e&&"accept"in e?this.textField(i("panel.accept","Accepted file types"),e.accept,(e=>this.emitConfigs({accept:e}))):null,e&&"uploadUrl"in e?this.textField(i("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e}))):null,this.optionsFields(),Object.entries(null!=e?e:{}).filter((([,e])=>"boolean"==typeof e)).map((([e,t])=>r("label",{class:"fk-props__field fk-props__field--inline",key:e},r("input",{type:"checkbox",checked:!0===t,onChange:t=>this.emitConfigs({[e]:t.target.checked})}),r("span",{class:"fk-props__label"},i(`panel.cfg.${e}`,e))))),e&&"content"in e?r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},l("panel.content")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("content",e.target.value)},this.readLocalized(e.content))):null)}validationRow(e,t,s){const o=this.validationOf(e);return r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!o,onChange:t=>this.setValidation(e,t.target.checked)}),r("span",{class:"fk-props__label"},t)),o&&s?r("input",{class:"fk-props__input",type:s,placeholder:"number"===s?"value":"regex",value:null==o.value?"":String(o.value),onChange:t=>{const o=t.target.value;this.setValidation(e,!0,{value:"number"===s?""===o?void 0:Number(o):o||void 0})}}):null,o?this.textField(l("panel.errorMessage"),this.readLocalized(o.message),(t=>this.setValidation(e,!0,{message:this.localized(o.message,t)}))):null)}renderValidationTab(){var e;const t=this.brick.dataType,s=this.validationOf("custom");return r("section",{class:"fk-props__section"},this.validationRow("required",l("panel.required")),"string"===t?[this.validationRow("minLength",l("panel.minLength"),"number"),this.validationRow("maxLength",l("panel.maxLength"),"number"),this.validationRow("pattern",l("panel.pattern"),"text"),this.validationRow("email",l("panel.emailFormat")),this.validationRow("url",l("panel.urlFormat"))]:null,"number"===t?[this.validationRow("min",l("panel.min"),"number"),this.validationRow("max",l("panel.max"),"number")]:null,"array"===t?[this.validationRow("minItems",l("panel.minItems"),"number"),this.validationRow("maxItems",l("panel.maxItems"),"number")]:null,r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!s,onChange:e=>{var t;return this.setValidation("custom",e.target.checked,{customValidator:null!==(t=null==s?void 0:s.customValidator)&&void 0!==t?t:"return true;"})}}),r("span",{class:"fk-props__label"},l("panel.custom"))),s?r("fk-code-editor",{completions:this.fields,value:null!==(e=s.customValidator)&&void 0!==e?e:"",placeholder:'return value?.startsWith("BJ-") ? true : "Must start with BJ-";',onCodeChange:e=>this.setValidation("custom",!0,{customValidator:e.detail})}):null,s?this.textField(l("panel.fallbackMessage"),this.readLocalized(s.message),(e=>this.setValidation("custom",!0,{message:this.localized(s.message,e)}))):null))}renderStylesTab(){var e;return r("section",{class:"fk-props__section"},Object.entries(null!==(e=this.brick.styles)&&void 0!==e?e:{}).map((([e,t])=>r("div",{class:"fk-props__style-row",key:e},r("span",{class:"fk-props__style-key"},e),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",value:String(null!=t?t:""),onChange:t=>this.emitStyles({[e]:t.target.value})}),r("button",{type:"button",class:"fk-props__remove",title:"Remove style",onClick:()=>this.emitStyles({[e]:void 0})},"✕")))),r("div",{class:"fk-props__style-row"},r("input",{class:"fk-props__input",type:"text",placeholder:l("panel.styleProperty"),value:this.newStyleKey,onInput:e=>this.newStyleKey=e.target.value}),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",placeholder:l("panel.styleValue"),onChange:e=>{const t=e.target;this.addStyle(t.value),t.value=""}})))}render(){return r("div",{key:"7903cc72f8462cc4fb33c04a886265157d10244e",class:"fk-props"},r("header",{key:"7918774557a0a4f8a835e25148833d24d669beac",class:"fk-props__header"},r("span",{key:"46f227ec676661ef7e70313a0c76a1f0c047e462",class:"fk-props__type"},this.brick.type),r("h4",{key:"9b96042938efa4d6e7193eb91f1776d1272d5bc7",class:"fk-props__title"},i(`brick.${this.brick.id}.name`,this.brick.name))),r("div",{key:"809d87d577a7127c86f23ff2e37d621a2340ca6b",class:"fk-props__tabs"},this.availableTabs().map((e=>r("button",{key:e.id,type:"button",class:{"fk-props__tab":!0,"fk-props__tab--active":this.activeTab===e.id},onClick:()=>this.activeTab=e.id},e.label)))),"config"===this.activeTab?this.renderConfigTab():null,"validation"===this.activeTab?this.renderValidationTab():null,"styles"===this.activeTab?this.renderStylesTab():null,"rules"===this.activeTab?r("section",{class:"fk-props__section"},r("fk-rules-editor",{brick:this.brick,fields:this.fields})):null)}static get watchers(){return{brick:[{onBrickChange:0}]}}static get style(){return".sc-fk-property-panel-h{display:block}.fk-props.sc-fk-property-panel{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) * 1.5)}.fk-props__header.sc-fk-property-panel{display:flex;flex-direction:column;gap:2px}.fk-props__type.sc-fk-property-panel{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-primary)}.fk-props__title.sc-fk-property-panel{margin:0;font-size:0.95rem;color:var(--fk-color-text)}.fk-props__section.sc-fk-property-panel{display:flex;flex-direction:column;gap:var(--fk-spacing);padding-top:var(--fk-spacing)}.fk-props__tabs.sc-fk-property-panel{display:flex;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-props__tab.sc-fk-property-panel{font:inherit;font-size:0.72rem;font-weight:600;padding:5px 9px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-props__tab.sc-fk-property-panel:hover{color:var(--fk-color-text)}.fk-props__tab--active.sc-fk-property-panel{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary)}.fk-props__section-title.sc-fk-property-panel{margin:0;font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-props__field.sc-fk-property-panel{display:flex;flex-direction:column;gap:4px}.fk-props__field--inline.sc-fk-property-panel{flex-direction:row;align-items:center;gap:8px}.fk-props__label.sc-fk-property-panel{font-size:0.75rem;font-weight:600;color:var(--fk-color-muted)}.fk-props__input.sc-fk-property-panel{font:inherit;font-size:0.85rem;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-props__input.sc-fk-property-panel:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-props__input--textarea.sc-fk-property-panel{min-height:72px;resize:vertical}.fk-props__vrule.sc-fk-property-panel{display:flex;flex-direction:column;gap:6px;padding:calc(var(--fk-spacing) / 1.5);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5)}.fk-props__style-row.sc-fk-property-panel{display:flex;align-items:center;gap:6px}.fk-props__style-key.sc-fk-property-panel{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;color:var(--fk-color-text);min-width:72px}.fk-props__input--grow.sc-fk-property-panel{flex:1;min-width:0}.fk-props__remove.sc-fk-property-panel{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-props__remove.sc-fk-property-panel:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}"}},[2,"fk-property-panel",{brick:[16],fields:[16],locales:[16],editLocale:[1,"edit-locale"],activeTab:[32],newStyleKey:[32]},void 0,{brick:[{onBrickChange:0}]}]);function f(){"undefined"!=typeof customElements&&["fk-property-panel","fk-code-editor","fk-rules-editor"].forEach((t=>{switch(t){case"fk-property-panel":customElements.get(e(t))||customElements.define(e(t),c);break;case"fk-code-editor":customElements.get(e(t))||p();break;case"fk-rules-editor":customElements.get(e(t))||n()}}))}f();export{c as F,f as d}
@@ -0,0 +1 @@
1
+ import{t as e,p as r,H as t,c as o,h as s}from"./p-BB4Llg42.js";import{s as l}from"./p-38x7HHH5.js";import{a as i}from"./p-bZPtT8wr.js";import{d as a}from"./p-8ZeGXEsz.js";const n=[{id:"equals",label:"equals"},{id:"notEquals",label:"does not equal"},{id:"greaterThan",label:"is greater than"},{id:"lessThan",label:"is less than"},{id:"isEmpty",label:"is empty"},{id:"isNotEmpty",label:"is not empty"}];function c(e){const r={var:e.field};switch(e.operator){case"equals":return{"==":[r,e.value]};case"notEquals":return{"!=":[r,e.value]};case"greaterThan":return{">":[r,e.value]};case"lessThan":return{"<":[r,e.value]};case"isEmpty":return{"!":r};case"isNotEmpty":return{"!!":r}}}const d=e=>null!==e&&"object"==typeof e&&"string"==typeof e.var?e.var:void 0,u={"==":"equals","!=":"notEquals",">":"greaterThan","<":"lessThan"};function f(e){if(!e||"object"!=typeof e)return;const r=Object.entries(e);if(1!==r.length)return;const[t,o]=r[0];if("!"===t||"!!"===t){const e=d(Array.isArray(o)?o[0]:o);if(!e)return;return{field:e,operator:"!"===t?"isEmpty":"isNotEmpty"}}const s=u[t];if(!s||!Array.isArray(o)||2!==o.length)return;const l=d(o[0]);return l?{field:l,operator:s,value:o[1]}:void 0}function p(e){if(""===e)return"";try{return JSON.parse(e)}catch(r){return e}}const k=["hidden","disabled","required","value"],v=r(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickRulesChange=o(this,"brickRulesChange"),this.fields=[],this.forcedModes={},this.jsonErrors={},this.codeErrors={},this.addRule=()=>{var e;this.commit([...this.rules(),{name:`Rule ${this.rules().length+1}`,type:"jsonLogic",logic:c({field:null!==(e=this.fields[0])&&void 0!==e?e:"",operator:"equals",value:""}),effects:[{property:{target:"hidden",type:"boolean"},boolean:!0}]}])}}rules(){var e;return null!==(e=this.brick.rules)&&void 0!==e?e:[]}commit(e){var r;const t=null===(r=this.brick.configs)||void 0===r?void 0:r.uid;t&&this.brickRulesChange.emit({rules:e,uid:t})}updateRule(e,r){this.commit(this.rules().map(((t,o)=>o===e?Object.assign(Object.assign({},t),r):t)))}removeRule(e){this.commit(this.rules().filter(((r,t)=>t!==e))),this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:void 0})}modeOf(e,r){return"javaScript"===r.type?"javaScript":this.forcedModes[e]?this.forcedModes[e]:f(r.logic)?"simple":"json"}setMode(e,r,t){var o,s,l;this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:t}),this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:""}),"javaScript"!==t||"javaScript"===r.type?"javaScript"!==t&&"jsonLogic"!==r.type&&this.updateRule(e,{type:"jsonLogic",logic:null!==(s=r.logic)&&void 0!==s?s:c({field:null!==(l=this.fields[0])&&void 0!==l?l:"",operator:"equals",value:""})}):this.updateRule(e,{type:"javaScript",code:null!==(o=r.code)&&void 0!==o?o:"return true;"})}updateCondition(e,r,t){var o,s;const l=null!==(o=f(r.logic))&&void 0!==o?o:{field:null!==(s=this.fields[0])&&void 0!==s?s:"",operator:"equals",value:""};this.updateRule(e,{logic:c(Object.assign(Object.assign({},l),t))})}commitJson(e,r){try{const t=JSON.parse(r);this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.updateRule(e,{logic:t})}catch(r){this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:r instanceof Error?r.message:String(r)})}}commitCode(e,r){var t,o;const s=l.jsRunnerService.validateJs(`(() => {${r}})();`);this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:s.valid?"":null!==(o=null===(t=s.error)||void 0===t?void 0:t.message)&&void 0!==o?o:"Invalid code"}),this.updateRule(e,{code:r})}updateEffect(e,r,t){var o;const s=(null!==(o=this.rules()[e].effects)&&void 0!==o?o:[]).map(((e,o)=>o===r?t:e));this.updateRule(e,{effects:s})}addEffect(e){var r;const t=this.rules()[e];this.updateRule(e,{effects:[...null!==(r=t.effects)&&void 0!==r?r:[],{property:{target:"hidden",type:"boolean"},boolean:!0}]})}removeEffect(e,r){var t;const o=this.rules()[e];this.updateRule(e,{effects:(null!==(t=o.effects)&&void 0!==t?t:[]).filter(((e,t)=>t!==r))})}renderCondition(e,r){var t,o;const l=null!==(t=f(r.logic))&&void 0!==t?t:{field:null!==(o=this.fields[0])&&void 0!==o?o:"",operator:"equals",value:""},a="isEmpty"!==l.operator&&"isNotEmpty"!==l.operator;return s("div",{class:"fk-rule__condition"},s("span",{class:"fk-rule__keyword"},i("rules.when")),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{field:t.target.value})},this.fields.map((e=>s("option",{value:e,selected:e===l.field},e)))),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{operator:t.target.value})},n.map((e=>s("option",{value:e.id,selected:e.id===l.operator},e.label)))),a?s("input",{class:"fk-rule__control",type:"text",value:(c=l.value,void 0===c?"":"string"==typeof c?c:JSON.stringify(c)),onChange:t=>this.updateCondition(e,r,{value:p(t.target.value)})}):null);var c}renderEffect(e,r,t){var o,l,a,n,c;const d=null!==(l=null===(o=r.property)||void 0===o?void 0:o.target)&&void 0!==l?l:"hidden",u=null!==(n=null===(a=r.property)||void 0===a?void 0:a.type)&&void 0!==n?n:"boolean";return s("div",{class:"fk-rule__effect"},s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{property:{target:o.target.value,type:u}}))},k.map((e=>s("option",{value:e,selected:e===d},e)))),s("select",{class:"fk-rule__control",onChange:r=>{const o=r.target.value;this.updateEffect(e,t,Object.assign({property:{target:d,type:o}},"boolean"===o?{boolean:!0}:{string:""}))}},s("option",{value:"boolean",selected:"boolean"===u},"boolean"),s("option",{value:"string",selected:"string"===u},"string")),"boolean"===u?s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{boolean:"true"===o.target.value}))},s("option",{value:"true",selected:!1!==r.boolean},"true"),s("option",{value:"false",selected:!1===r.boolean},"false")):s("input",{class:"fk-rule__control",type:"text",value:null!==(c=r.string)&&void 0!==c?c:"",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{string:o.target.value}))}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeEffect"),onClick:()=>this.removeEffect(e,t)},"✕"))}render(){return s("div",{key:"f31daa5219d35d255bc9cf2361df03d41e671155",class:"fk-rules"},this.rules().map(((e,r)=>{var t,o,l;const a=this.modeOf(r,e);return s("article",{class:"fk-rule"},s("header",{class:"fk-rule__header"},s("input",{class:"fk-rule__name",type:"text",value:e.name,onChange:e=>this.updateRule(r,{name:e.target.value})}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeRule"),onClick:()=>this.removeRule(r)},"✕")),s("div",{class:"fk-rule__modes"},["simple","json","javaScript"].map((t=>s("button",{type:"button",class:{"fk-rule__mode":!0,"fk-rule__mode--active":a===t},onClick:()=>this.setMode(r,e,t)},i(`rules.mode.${"javaScript"===t?"js":t}`))))),"simple"===a?this.renderCondition(r,e):null,"json"===a?s("div",{class:"fk-rule__advanced"},s("textarea",{class:"fk-rule__code",onChange:e=>this.commitJson(r,e.target.value)},JSON.stringify(null!==(t=e.logic)&&void 0!==t?t:null,null,2)),this.jsonErrors[r]?s("p",{class:"fk-rule__error"},this.jsonErrors[r]):null):null,"javaScript"===a?s("div",{class:"fk-rule__advanced"},s("fk-code-editor",{completions:this.fields,value:null!==(o=e.code)&&void 0!==o?o:"",placeholder:"return dataMap.country === 'BJ';",onCodeChange:e=>this.commitCode(r,e.detail)}),this.codeErrors[r]?s("p",{class:"fk-rule__error"},this.codeErrors[r]):null):null,s("div",{class:"fk-rule__effects"},s("span",{class:"fk-rule__keyword"},i("rules.then")),(null!==(l=e.effects)&&void 0!==l?l:[]).map(((e,t)=>this.renderEffect(r,e,t))),s("button",{type:"button",class:"fk-rule__add",onClick:()=>this.addEffect(r)},i("rules.addEffect"))))})),s("button",{key:"e481d50c0d949f1ef470d55e9d2ee88a25f614e9",type:"button",class:"fk-rule__add",onClick:this.addRule},i("rules.addRule")))}static get style(){return".sc-fk-rules-editor-h{display:block}.fk-rules.sc-fk-rules-editor{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-rule.sc-fk-rules-editor{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 1.5);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-rule__header.sc-fk-rules-editor{display:flex;align-items:center;gap:6px}.fk-rule__name.sc-fk-rules-editor{flex:1;min-width:0;font:inherit;font-size:0.8rem;font-weight:600;padding:4px 6px;border:1px solid transparent;border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-text)}.fk-rule__name.sc-fk-rules-editor:hover,.fk-rule__name.sc-fk-rules-editor:focus{border-color:var(--fk-color-border);background:var(--fk-color-surface);outline:none}.fk-rule__modes.sc-fk-rules-editor{display:flex;gap:4px}.fk-rule__mode.sc-fk-rules-editor{font:inherit;font-size:0.65rem;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:3px 8px;border:1px solid var(--fk-color-border);border-radius:999px;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__mode--active.sc-fk-rules-editor{border-color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent);color:var(--fk-color-primary)}.fk-rule__condition.sc-fk-rules-editor,.fk-rule__effect.sc-fk-rules-editor{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.fk-rule__keyword.sc-fk-rules-editor{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-rule__control.sc-fk-rules-editor{font:inherit;font-size:0.78rem;padding:4px 6px;max-width:100%;min-width:0;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-rule__control.sc-fk-rules-editor:focus{outline:none;border-color:var(--fk-color-primary)}.fk-rule__advanced.sc-fk-rules-editor{display:flex;flex-direction:column;gap:4px}.fk-rule__code.sc-fk-rules-editor{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;min-height:72px;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);resize:vertical}.fk-rule__error.sc-fk-rules-editor{margin:0;font-size:0.72rem;color:var(--fk-color-danger)}.fk-rule__effects.sc-fk-rules-editor{display:flex;flex-direction:column;gap:6px}.fk-rule__remove.sc-fk-rules-editor{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-rule__remove.sc-fk-rules-editor:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-rule__add.sc-fk-rules-editor{align-self:flex-start;font:inherit;font-size:0.75rem;font-weight:600;padding:4px 10px;border:1px dashed var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__add.sc-fk-rules-editor:hover{border-color:var(--fk-color-primary);color:var(--fk-color-primary)}"}},[2,"fk-rules-editor",{brick:[16],fields:[16],forcedModes:[32],jsonErrors:[32],codeErrors:[32]}]);function h(){"undefined"!=typeof customElements&&["fk-rules-editor","fk-code-editor"].forEach((r=>{switch(r){case"fk-rules-editor":customElements.get(e(r))||customElements.define(e(r),v);break;case"fk-code-editor":customElements.get(e(r))||a()}}))}h();export{v as F,h as d}