import{j as e}from"./jsx-runtime-CLpGMVip.js";import{r as o}from"./index-B-SYruCi.js";import{c as _,a as D,S as f,b as a,m as O,d as z,P as A}from"./config-DN7VXKqt.js";const C="python-editor-frame",h={editor:{display:"flex",flexDirection:"column"},iframe:{width:"100%",flexGrow:1,border:"none"}},j=o.forwardRef(function(t,r){const{lang:n,version:i="3",controller:c=1,controllerId:l,style:d,queryParams:p,initialProjects:v,onWorkspaceLoaded:x,onWorkspaceSave:w,onWorkspaceSync:E}=t,N=_(i,n,c,p),M=o.useMemo(()=>({initialProjects:v,controllerId:l,onWorkspaceLoaded:x,onWorkspaceSave:w,onWorkspaceSync:E}),[l,v,x,w,E]);return e.jsx("div",{style:{...h.editor,...d},children:e.jsx(H,{options:M,ref:r,"data-testid":C,title:"Python editor",src:N,style:h.iframe,allow:"usb; clipboard-read; clipboard-write"})})}),H=o.forwardRef(function(t,r){const{options:n,style:i,...c}=t,l=o.useRef(null),d=o.useRef(new D(n,()=>l.current??void 0));return o.useEffect(()=>{const p=d.current;return p.initialize(),()=>{p.dispose()}},[]),o.useEffect(()=>{d.current.setOptions(n)},[n]),o.useImperativeHandle(r,()=>d.current,[]),e.jsx("iframe",{ref:l,title:"PythonEditor",style:{...h.iframe,...i},allow:"usb; autoplay; camera; microphone;",...c})});j.__docgenInfo={description:"",methods:[],displayName:"PythonEditorFrame",props:{version:{required:!1,tsType:{name:"string"},description:""},lang:{required:!1,tsType:{name:"string"},description:""},controller:{required:!1,tsType:{name:"union",raw:"1 | 2",elements:[{name:"literal",value:"1"},{name:"literal",value:"2"}]},description:""},queryParams:{required:!1,tsType:{name:"Record",elements:[{name:"string"},{name:"string"}],raw:"Record<string, string>"},description:""},initialProjects:{required:!0,tsType:{name:"signature",type:"function",raw:"() => Promise<PythonProject[]>",signature:{arguments:[],return:{name:"Promise",elements:[{name:"Array",elements:[{name:"union",raw:"PythonProjectV2 | PythonProjectV3",elements:[{name:"string"},{name:"signature",type:"object",raw:`{
  files: { [key: string]: string };
  projectName?: string;
}`,signature:{properties:[{key:"files",value:{name:"signature",type:"object",raw:"{ [key: string]: string }",signature:{properties:[{key:{name:"string"},value:{name:"string",required:!0}}]},required:!0}},{key:"projectName",value:{name:"string",required:!1}}]}}]}],raw:"PythonProject[]"}],raw:"Promise<PythonProject[]>"}}},description:""},controllerId:{required:!1,tsType:{name:"string"},description:""}}};const K={component:j,argTypes:{version:{options:["2.0.0","2.2.2","3","beta"],defaultValue:"2.0.0",name:"version",control:{type:"radio"}}}},P=({startingProject:s,...t})=>{const r=o.useRef(new Map),n=o.useRef(null),i=o.useCallback(async()=>[s??z],[s]);return e.jsxs(e.Fragment,{children:[e.jsx(A,{driver:n}),e.jsx(j,{ref:n,controllerId:a,initialProjects:i,onWorkspaceSave:c=>{r.current.set(a,c.project),console.log(r)},...t})]})},m={name:"Python Editor versions",args:{version:"3"},render:s=>{const{version:t}=s;return e.jsx(f,{children:e.jsx(P,{controllerId:a,style:{flexGrow:1},version:t,onWorkspaceLoaded:r=>console.log("workspaceLoaded",r),onWorkspaceSync:r=>console.log("workspaceSync",r),onWorkspaceSave:r=>{console.log("onWorkspaceSave",r)}})})}},y={name:"Python Editor multi-file project",render:()=>e.jsx(f,{children:e.jsx(P,{controllerId:a,style:{flexGrow:1},startingProject:O,version:"3"})})},u={name:"Python Editor V3 lang via query string",render:()=>e.jsx(f,{children:e.jsx(P,{controllerId:a,style:{flexGrow:1},version:"3",lang:"fr"})})},g={name:"Python Editor V3 noLang flag",render:()=>e.jsx(f,{children:e.jsx(P,{controllerId:a,style:{flexGrow:1},version:"3",queryParams:{flag:"noLang"}})})};var S,k,W;m.parameters={...m.parameters,docs:{...(S=m.parameters)==null?void 0:S.docs,source:{originalSource:`{
  name: 'Python Editor versions',
  args: {
    version: '3'
  },
  render: args => {
    const {
      version
    } = args;
    return <StoryWrapper>
        <PythonEditor controllerId={controllerId} style={{
        flexGrow: 1
      }} version={version} onWorkspaceLoaded={e => console.log('workspaceLoaded', e)} onWorkspaceSync={e => console.log('workspaceSync', e)} onWorkspaceSave={e => {
        console.log('onWorkspaceSave', e);
      }} />
      </StoryWrapper>;
  }
}`,...(W=(k=m.parameters)==null?void 0:k.docs)==null?void 0:W.source}}};var q,I,F;y.parameters={...y.parameters,docs:{...(q=y.parameters)==null?void 0:q.docs,source:{originalSource:`{
  name: 'Python Editor multi-file project',
  render: () => <StoryWrapper>
      <PythonEditor controllerId={controllerId} style={{
      flexGrow: 1
    }} startingProject={multiFilePythonProject} version="3" />
    </StoryWrapper>
}`,...(F=(I=y.parameters)==null?void 0:I.docs)==null?void 0:F.source}}};var L,R,b;u.parameters={...u.parameters,docs:{...(L=u.parameters)==null?void 0:L.docs,source:{originalSource:`{
  name: 'Python Editor V3 lang via query string',
  render: () => <StoryWrapper>
      <PythonEditor controllerId={controllerId} style={{
      flexGrow: 1
    }} version="3" lang="fr" />
    </StoryWrapper>
}`,...(b=(R=u.parameters)==null?void 0:R.docs)==null?void 0:b.source}}};var V,G,T;g.parameters={...g.parameters,docs:{...(V=g.parameters)==null?void 0:V.docs,source:{originalSource:`{
  name: 'Python Editor V3 noLang flag',
  render: () => <StoryWrapper>
      <PythonEditor controllerId={controllerId} style={{
      flexGrow: 1
    }} version="3" queryParams={{
      flag: 'noLang'
    }} />
    </StoryWrapper>
}`,...(T=(G=g.parameters)==null?void 0:G.docs)==null?void 0:T.source}}};const Q=["PythonEditorStory","MultiFileProject","V3French","V3NoLangFlag"];export{y as MultiFileProject,m as PythonEditorStory,u as V3French,g as V3NoLangFlag,Q as __namedExportsOrder,K as default};
