(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[15036],{15036:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>ed});var a=n(67841),s=n(79477),r=n(64833),l=n(82059),o=n(53725),i=n(25967),c=n(91952);let d=(0,r.z)("div")({name:"InlineOuterWrapper",class:"il1gxx9",propsAsIs:!1}),u=(0,r.z)(i.Z)({name:"InlineWrapper",class:"i1j6zvew",propsAsIs:!0}),p=(0,r.z)(i.Z)({name:"FullscreenWrapper",class:"f1xbttis",propsAsIs:!0}),h=function(e){let{stacked:t,size:n,className:r,children:i,isFullscreened:h}=e,m=s.useRef(null),[f,g]=s.useState(h),[y,v]=s.useState(0);return(s.useEffect(()=>{g(h),m.current&&(h?v(m.current.getBoundingClientRect().height):v(0))},[h]),f)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d,{children:(0,a.jsx)(u,{style:{...l.Ro,height:y}})}),(0,a.jsx)(o.Z,{children:(0,a.jsx)(p,{style:l.Ro,children:i})})]}):(0,a.jsx)(d,{"data-stacked":String(!!t),as:"wide"===n?c.Z:"div",children:(0,a.jsx)(u,{style:l.Ro,className:r,ref:m,children:i})})};n(62544);var m=n(73060),f=n(60637);let g=(0,r.z)("header")({name:"Wrapper",class:"w14j10eb",propsAsIs:!1}),y=(0,r.z)("p")({name:"Title",class:"tkoi9ui",propsAsIs:!1}),v=(0,r.z)("div")({name:"Actions",class:"au0cxa1",propsAsIs:!1}),x=function(e){let{title:t,isFullscreened:n,handleToggleFullscreen:s,handleReset:r,handleFormat:l}=e;return(0,a.jsxs)(g,{children:[(0,a.jsx)(y,{children:t||"Code Playground"}),(0,a.jsxs)(v,{children:[(0,a.jsx)(f.Z,{handleFormat:l}),(0,a.jsx)(m.Z,{handleReset:r})]})]})};n(41739);var w=n(66596),b=n(34308);let j=(0,r.z)("button")({name:"ActionButton",class:"ah084m5",propsAsIs:!1});n(9520);let k=(0,r.z)(j)({name:"Wrapper",class:"w11udlg3",propsAsIs:!0}),z=e=>{let{handleRefresh:t}=e,[n,r]=s.useState(0),[l,o]=s.useState(!1);return(0,a.jsx)("abbr",{title:"Refresh pane",children:(0,a.jsxs)(k,{onClick:()=>{t(),r(e=>e+180)},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{transform:"rotate(".concat(n,"deg)"),opacity:l?1:.7},children:[(0,a.jsx)(w.Z,{size:16}),(0,a.jsx)(b.Z,{children:"Refresh results pane"})]})})};n(22587);var E=n(74631);let S=function(e){let{rulerRef:t,containerRef:n,dividerRef:a,dividerWidth:r,defaultRatio:l}=e,[o,i]=(0,s.useState)(782*l),[c,d]=(0,s.useState)(null),u=s.useRef(c);u.current=c,(0,s.useEffect)(()=>{let e=t.current,n=()=>{if(e){let t=e.clientWidth;d(e.getBoundingClientRect()),i(t*l-r)}};n();let a=(0,E.P2)(n,100);return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[l,r,t]);let p=(0,s.useCallback)(e=>{let t=u.current,{clientX:n}=e;t&&i(n-t.left)},[]),h=(0,s.useCallback)(()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h),n.current&&(n.current.style.pointerEvents="")},[p,n]),m=(0,s.useCallback)(()=>{document.addEventListener("mousemove",p),document.addEventListener("mouseup",h),n.current&&(n.current.style.pointerEvents="none")},[p,h,n]);(0,s.useEffect)(()=>{let e=a.current,t=u.current;function n(){t&&i(t.width*l-r)}function s(e){"ArrowLeft"===e.key?i(e=>e-20):"ArrowRight"===e.key&&i(e=>e+20)}return e&&(e.addEventListener("mousedown",m),e.addEventListener("dblclick",n),e.addEventListener("keydown",s)),()=>{e&&(e.removeEventListener("mousedown",m),e.removeEventListener("dblclick",n),e.removeEventListener("keydown",s))}},[m,l,a,r]);let f=c?c.width-r:782,g=Math.min(o,f);return{leftWidth:g,rightWidth:f-g}},A=(0,r.z)("div")({name:"Wrapper",class:"w198elmk",propsAsIs:!1}),R=(0,r.z)("div")({name:"Container",class:"c1jztmaw",propsAsIs:!1}),I=(0,r.z)("div")({name:"FirstPane",class:"f15xiyga",propsAsIs:!1}),C=(0,r.z)("div")({name:"SecondPane",class:"s1c0ceq0",propsAsIs:!1}),F=(0,r.z)("button")({name:"Divider",class:"dijulrw",propsAsIs:!1}),L=function(e){let{className:t="",splitRatio:n,isFullscreened:r,leftTitle:l,leftChild:o,rightTitle:i,rightChild:c}=e,d=s.useRef(null),u=s.useRef(null),p=s.useRef(null),{leftWidth:h,rightWidth:m,reset:f}=S({defaultRatio:n,rulerRef:d,containerRef:u,dividerRef:p,dividerWidth:16});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{ref:d}),(0,a.jsx)(A,{style:{flex:r?1:void 0},children:(0,a.jsxs)(R,{className:t,ref:u,children:[(0,a.jsx)(I,{style:{flex:h},children:o}),(0,a.jsx)(F,{ref:p,children:(0,a.jsx)(b.Z,{children:"Resize editor. Use left/right arrows."})}),(0,a.jsx)(C,{style:{flex:m},children:c})]})})]})};n(13024);let U=(0,r.z)("div")({name:"Wrapper",class:"whrzwqb",propsAsIs:!1}),W=(0,r.z)("div")({name:"Header",class:"h1nlnw7n",propsAsIs:!1}),q=(0,r.z)("p")({name:"Title",class:"tbdao9h",propsAsIs:!1}),N=function(e){let{title:t,children:n,actions:s,...r}=e;return(0,a.jsxs)(U,{...r,children:[(0,a.jsxs)(W,{children:[(0,a.jsx)(q,{children:t}),s]}),n]})};n(46391);var D=n(29273),T=n(521),P=n.n(T),M=n(45052);let H={plain:{color:"var(--syntax-txt)",backgroundColor:"transparent",padding:0,fontFamily:"var(--font-family-mono)"},styles:[{types:["prolog","comment","doctype","cdata"],style:{color:"var(--syntax-comment)"}},{types:["property","tag","deleted","constant","symbol"],style:{color:"var(--syntax-prop)"}},{types:["boolean","number"],style:{color:"var(--syntax-bool)"}},{types:["attr-name","tag"],style:{fontWeight:"var(--font-weight-medium)"}},{types:["string","attr-value"],style:{color:"var(--syntax-val)"}},{types:["operator","entity","url","string","variable","language-css","keyword"],style:{color:"var(--syntax-str)"}},{types:["selector","attr-name","char","builtin","insert","script-punctuation"],style:{color:"var(--syntax-name)"}},{types:["deleted"],style:{color:"var(--syntax-del)"}},{types:["italic"],style:{fontStyle:"italic"}},{types:["important","bold"],style:{fontWeight:"var(--font-weight-bold)"}},{types:["regex","important"],style:{color:"var(--syntax-regex)"}},{types:["atrule","function"],style:{color:"var(--syntax-fn)"}},{types:["symbol"],style:{opacity:"0.7"}},{types:["string"],style:{fontWeight:"var(--font-weight-medium)"}}]},O=(0,r.z)("div")({name:"Wrapper",class:"w1bgwmtf",propsAsIs:!1}),Z=(0,r.z)("button")({name:"FocusTrapper",class:"f9ibg9h",propsAsIs:!1}),B=(0,r.z)(P())({name:"CodeEditor",class:"c18okpq0",propsAsIs:!0}),_=function(e){let{code:t,language:n,maxHeight:r,handleUpdate:l,handleFormat:o}=e,i=s.useRef(null),c=s.useRef(null),[d,u]=s.useState(!1),[p,h]=s.useState(!1);return(0,a.jsxs)(O,{in:String(d),style:{"--max-height":r},children:[(0,a.jsx)(Z,{ref:c,onFocus:()=>h(!0),onBlur:()=>h(!1),onKeyDown:e=>{"Enter"===e.key&&(e.stopPropagation(),e.preventDefault(),(0,D.flushSync)(()=>{h(!1)}),i.current._input.focus())},children:(0,a.jsx)(b.Z,{children:"Focus the editor. This will trap focus until you press Escape."})}),(0,a.jsxs)("label",{inert:p,children:[(0,a.jsx)(b.Z,{children:"Code editor:"}),(0,a.jsx)(B,{ref:i,value:t,onValueChange:l,onKeyDown:function(e){if(e.metaKey&&"s"===e.key){let t=i.current._input,n=t.selectionStart;e.preventDefault(),o(),window.requestAnimationFrame(()=>{(0,E.tO)(t,n)})}"Escape"===e.key&&(c.current.focus(),u(!0)),e.shiftKey&&"Tab"===e.key&&0===i.current._input.selectionStart&&(e.preventDefault(),c.current.focus())},translate:"no",highlight:e=>(0,a.jsx)(M.y$,{theme:H,code:e,language:n,children:e=>{let{className:t,style:n,tokens:s,getLineProps:r,getTokenProps:l}=e;return(0,a.jsx)(a.Fragment,{children:s.map((e,t)=>(0,a.jsx)("div",{...r({line:e}),children:e.map((e,t)=>(0,a.jsx)("span",{...l({token:e})},t))},t))})}})})]})]})};n(8652);let K=(0,r.z)("div")({name:"Wrapper",class:"w16o0eiw",propsAsIs:!1}),J=(0,r.z)("div")({name:"Triggers",class:"tt2ystl",propsAsIs:!1}),V=(0,r.z)("button")({name:"TabTrigger",class:"ts2dciv",propsAsIs:!1}),$=function(e){let{paneData:t,splitRatio:n,maxHeight:r,handleFormat:l,...o}=e,[i,c]=t,[d,u]=s.useState(i.language),p=d===i.language?i:c;return(0,a.jsxs)(K,{...o,children:[(0,a.jsx)(J,{children:t.map((e,t)=>(0,a.jsx)(V,{style:{"--weight":e===p?"var(--font-weight-bold)":"var(--font-weight-normal)","--color":e===p?"var(--color-text)":"var(--color-gray-500)"},onClick:()=>u(e.language),children:e.label},e.language))}),(0,a.jsx)(_,{code:p.code,language:p.language,handleUpdate:p.handleUpdate,handleFormat:l,maxHeight:r})]})};n(58103);let G=function(e,t){let[n,a]=s.useState(t),r=s.useRef(t);return r.current=t,s.useEffect(()=>{let t=window.setTimeout(()=>{a(r.current)},e);return()=>{window.clearTimeout(t)}},[e,...Object.values(t)]),n};var X=n(38339);let Y={},Q={"":"https://cdn.skypack.dev/"},ee=function(e){var t;let{id:n,codeMap:a,mode:s,boxSizing:r,centered:l}=e,o={...a};return"react"===s?o=function(e,t){let n=e.javascript,a=RegExp("render\\((.*)\\)","s");Object.keys(Q).forEach(e=>{n=n.replace(e,Q[e])});try{let[,s]=n.match(a),r=n.replace(a,""),l="\n import React, { createElement } from 'https://cdn.skypack.dev/react@17.0.2';\n import ReactDOM from 'https://cdn.skypack.dev/react-dom@17.0.2';\n\n import styled, { createGlobalStyle } from 'https://cdn.skypack.dev/styled-components@5.3.5';\n\n ".concat(r,"\n\n // Wait a frame so that 'window' reads as the correct width,\n // inside the React app\n window.setTimeout(() => {\n ReactDOM.render(").concat(s,", document.querySelector('#app'));\n }, 0)\n ").trim(),o="";return t&&(o="\n display: grid;\n place-content: center;\n height: calc(100vh - 16px);\n "),{...e,javascript:l,markup:'
')}}catch(t){return e}}(o,l):l&&(o=function(e){let{markup:t}=e;return{...e,markup:'