1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8438],{6501:function(t,e,a){"use strict";a.d(e,{sj:function(){return I},Tm:function(){return T},Bv:function(){return F}});var r=a(72338),n=a(2284),o=a.n(n),s=a(30764),i=a(1188),l=a(50260),u=a(57362),d=a(26104),c=a(33169),m=a(3402),p=a(97253),h=a(13793),f=a(36651),g=a(3543),y=a(90775),x=a(1313),v=a.n(x);let b=t=>v()(t)(),j=(t,e)=>{let a=v()(e),r=Math.floor(a()*t.length);return t[r]};var w=a(50775),k=a(28667);let C=["gridLayout","table","gallery"],N=["imagesText","pyramid","funnel","staircase","stats","circleStats","barStats"],I=async(t,e)=>{var a,n;let{cardIndex:o,imageOptions:s,docFormatKey:i,theme:l,loadImages:c}=e,p=await (0,k.T)(t,{imageOptions:s,removeImagesFromLayouts:!0,loadImages:!1}),h=(0,r.J1)((0,u.e)()),{content:g,dom:y}=(0,m.T)(p,h),x=null===(a=y.firstElementChild)||void 0===a?void 0:a.getAttribute("layout"),v=x&&d.IT.includes(x)?x:void 0,b=g.toJSON(),j=1===b.length&&"card"===b[0].type?(null===(n=b[0])||void 0===n?void 0:n.content)||[]:b,w=E(j,{cardIndex:o,docFormatKey:i,theme:l,cardLayout:v});return s&&"aiGenerated"===s.provider&&O(w,h),c&&await P(w,h,{docId:"unknown",workspaceId:(0,f.n_)(),...e.context}),T(w),w},O=(t,e)=>{(0,y.N)(t,t=>{if("text"===t.type)return;let a=s.NB.fromJSON(e,{type:t.type,attrs:t.attrs}),r=(0,p.XU)(a);if(!r||!r.loadImageParams)return;let n=S(t),o={height:i.sl[n].height,width:i.sl[n].width},l={...r.loadImageParams,options:{...r.loadImageParams.options,...o}};t.attrs=(0,p.j6)(a,{loadImageParams:l})})},S=t=>{let e=t.parent;if(!(null==e?void 0:e.attrs))return"square";if("smartLayoutCell"===t.type&&"imagesText"===e.attrs.variantKey)return"landscape";if("cardAccentLayoutItem"===t.type){let t=e.attrs.layout;if("left"===t||"right"===t)return"portrait";if("top"===t)return"landscape"}return"square"},P=async(t,e,a)=>{let r=[];(0,y.N)(t,async t=>{if("text"===t.type)return;let n=e.nodeFromJSON({type:t.type,attrs:t.attrs}),o=(0,p.XU)(n);if(!o)return;let{loadImageStatus:s,loadImageId:i,loadImageParams:l}=o;if("queued"!==s||!l||!i)return;let u=(0,w.B)({loadImageId:i,loadImageParams:l,context:a}).then(e=>{t.attrs=(0,p.j6)(n,e)});r.push(u)}),await Promise.all(r)},T=t=>{var e,a,r,n;let o=t.content.find(t=>"cardAccentLayoutItem"===t.type);if(!o)return;let s=o.attrs.background;if(!s)return;let i=null==s?void 0:null===(a=s.image)||void 0===a?void 0:null===(e=a.meta)||void 0===e?void 0:e.average_color,l=i&&(0,g.DP)(i);"behind"===t.attrs.layout&&(l||.5>b(t.attrs.id))&&(null!==(n=(r=t.attrs).container)&&void 0!==n||(r.container={}),t.attrs.container.background={type:h.E.COLOR,color:{hex:"#000000"}})},E=(t,e)=>{let a;let{cardIndex:r,docFormatKey:n,theme:s,cardLayout:i}=e,l=c.C2.generate(),u=t.filter(t=>{var e,a;return"image"===t.type&&((null===(e=t.attrs)||void 0===e?void 0:e.src)||(null===(a=t.attrs)||void 0===a?void 0:a.loadImageStatus)==="queued")})||[],d=t.some(e=>{var a;return C.includes(e.type)||"smartLayout"===e.type&&(null===(a=e.attrs)||void 0===a?void 0:a.variantKey)&&N.includes(e.attrs.variantKey)||"smartLayout"===e.type&&e.content&&e.content.length>3||t.length>5});u.length>0?(a={type:h.E.IMAGE,image:u[0].attrs,source:u[0].attrs.source},o()(t,...u)):s&&(a=F(s,l)),0===r&&"webpage"!==n&&t.push({type:"contributors"}),t.forEach(t=>K(t,l));let m={};"deck"===n?m=D({cardIndex:r,cardId:l,preventCardLayouts:d,cardLayout:i}):"document"===n?m=z({cardIndex:r,cardId:l,preventCardLayouts:d,cardLayout:i}):"webpage"===n&&(m=L({cardIndex:r,cardId:l,accentBackground:a,preventCardLayouts:d,cardLayout:i,theme:s}));let p={container:{},layout:i||"blank",id:l,...m};if("left"===p.layout||"right"===p.layout){let e=!1;t.forEach(t=>{if("smartLayout"===t.type&&t.attrs){let a=t.attrs;e=!0,a.options.orientation="vertical",a.options.twoSided=!1,a.options.cellSize="lg"}}),e&&(p.layoutTemplateColumns="left"===p.layout?"25% 75%":"75% 25%")}let f={type:"cardLayoutItem",attrs:{itemId:"body"},content:t},g="blank"===p.layout?null:{type:"cardAccentLayoutItem",attrs:{itemId:"accent",background:a}};return{type:"card",attrs:p,content:g?[g,f]:[f]}},L=t=>
1{let{cardIndex:e,cardId:a,accentBackground:r,preventCardLayouts:n,theme:o,cardLayout:s}=t,i={},u=o?(0,l.Wz)(o):[];return s?i.layout=s:0===e?i.layout=j(["behind","right"],a):.8>b(a)?(i.layout=n?"blank":j(["left","right","behind","blank","blank"],a),n&&"blank"===i.layout&&u.length&&.25>b(a)&&(i.container={background:{type:h.E.COLOR,color:{hex:j(u,a)}}})):(i.cardSize="contained",i.background=j([r,{type:h.E.COLOR,color:{hex:j(u,a)}}],a),i.layout="blank"),i},D=t=>{let{cardIndex:e,cardId:a,preventCardLayouts:r,cardLayout:n}=t,o={};return n?o.layout=n:0!==e||r?r?o.layout="blank":o.layout=j(["left","left","right","right","behind","top","blank"],a):o.layout=j(["left","right"],a),o},z=t=>{let{cardIndex:e,preventCardLayouts:a,cardId:r,cardLayout:n}=t,o={};return n?o.layout=n:0===e?(o.cardSize="full",o.layout="behind"):a?o.layout="blank":o.layout=j(["blank","blank","blank","blank","right","left"],r),o},F=(t,e)=>j(t.config.accentBackgrounds||[],e),K=(t,e)=>{if("smartLayout"!==t.type||!t.attrs)return;let a=t.attrs.variantKey;if("numbers"===a){var r;let a=null===(r=t.content)||void 0===r?void 0:r.map(t=>{var e;return null===(e=t.attrs)||void 0===e?void 0:e.label});(null==a?void 0:a.every(t=>t.endsWith("%")))&&(t.attrs.variantKey=j(["barStats","circleStats"],e))}}},21041:function(t,e,a){"use strict";a.d(e,{U:function(){return u}});var r=a(87254),n=a(21156),o=a(38290);let s={key:"presentation",label:()=>
1r.ag._({id:"nQbhA4"}),docFormat:"deck",prompt:new n.V({params:{temperature:1,model:"gpt-3.5-turbo"},variables:["input","numCards","language"],systemPromptOperation:o.Run.GeneratePresentationSystem,userPromptOperation:o.Run.GeneratePresentationUser})},i={key:"document",label:()=>r.ag._({id:"XH30C4"}),docFormat:"document",prompt:new n.V({params:{temperature:1,model:"gpt-3.5-turbo"},variables:["input","numCards","language"],systemPromptOperation:o.Run.GenerateDocumentSystem,userPromptOperation:o.Run.GenerateDocumentUser})},l={key:"webpage",label:()=>r.ag._({id:"1NdXQ6"}),docFormat:"webpage",prompt:new n.V({params:{temperature:1,model:"gpt-3.5-turbo"},variables:["input","numCards","language"],systemPromptOperation:o.Run.GenerateWebpageSystem,userPromptOperation:o.Run.GenerateWebpageUser})},u={presentation:s,document:i,webpage:l}},93206:function(t,e,a){"use strict";a.d(e,{N:function(){return r}});let r=8},18469:function(t,e,a){"use strict";a.d(e,{p:function(){return c}});var r=a(43019),n=a(54073),o=a.n(n),s=a(2784),i=a(42111),l=a(91994),u=a(91073),d=a(66625);let c=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,a=(0,l.TL)(),n=(0,i.ye)("cardTextComputedEnabled");(0,s.useEffect)(()=>{if(!e||!n)return;let t=o()(()=>{let t={};e.state.doc.descendants((a,n)=>{if((0,u.KH)(a)&&a.attrs.id){let o=a.toJSON(),s=(0,r.getCardTitle)(o),i=e.state.doc.resolve(n),l=0===i.parentOffset&&1===i.depth;t[a.attrs.id]={title:s,text:(0,r.getCardText)(e.schema,o,s),isFirstCard:l}}return!0}),a((0,d.uD)({localCardTextMap:t}))},1e3,{leading:!0,trailing:!0,maxWait:1e3});return t(),e.on("update",t),()=>{e.off("update",t)}},[e,a,n]),(0,s.useEffect)(()=>{t&&a((0,d.eJ)({cards:t}))},[a,t]),(0,s.useEffect)(()=>()=>{a((0,d.mc)())},[])}},32186:function(t,e,a){"use strict";a.d(e,{m:function(){return g},n:function(){return x}});var r=a(52322),n=a(53738),o=a(2784),s=a(43997),i=a(18469),l=a(52332),u=a(30870),d=a(65878),c=a(47968),m=a(95027),p=a(90507),h=a(85069),f=a(57362);let g=t=>{let{reduxData:e,...a}=t,n=(0,h.c)(e);return(0,r.jsx)(s.zt,{store:n,children:(0,r.jsx)(y,{...a})})},y=t=>{let{onCreate:e=()=>{},initialContent:a,content:h,theme:g,isThumbnail:y,portalComponent:x}=t,[v,b]=(0,o.useState)(!1),j=(0,o.useMemo)(()=>(0,f.e)(),[]),w=(0,s.I0)();(0,o.useEffect)(()=>{w((0,c.Dc)({theme:g||null})),w((0,c.iS)({isAllowedToEdit:!1})),w((0,c.Nr)({animationsEnabled:!1}))},[g,w]);let k=(0,p.jE)({async onCreate(t){var a;let{editor:r}=t;console.debug("[EditorPreview][onCreate] TipTap editor is now ready"),null===(a=u.Z8.getState(r.state))||void 0===a||a.compute(r.state).processChanges(w),r.commands.command(()=>((0,l.E0)(r.state.doc,w),!0)),b(!0),null==e||e({editor:r})},extensions:j,content:a,editable:!1});return(k.isThumbnail=y,(0,o.useEffect)(()=>{var t;h&&k&&(k.commands.setContent(h),k.commands.command(()=>((0,l.E0)(k.state.doc,w),!0)),null===(t=d.S.getState(k.state))||void 0===t||t.compute(k.state.doc).processChanges(w))},[h,k,w]),(0,i.p)([],k),v)?(0,r.jsx)(n.xu,{className:"editor-preview-root","data-variation-preview":!0,"data-testid":"editor-preview-root",width:"100%",position:"relative",sx:m.I,children:(0,r.jsx)(p.kg,{editor:k,portalComponent:x,style:{width:"100%",height:"100%"},className:"highlight-mask"})}):(0,r.jsx)(r.Fragment,{})},x={"[data-thumbnail-hidden]":{display:"none !important"},"*":{backdropFilter:"none !important",webkitBackdropFilter:"none !important","-webkit-transition":"none !important","-moz-transition":"none !important","-o-transition":"none !important","-ms-transition":"none !important",transition:"none !important"},contain:"paint",".editor-core-root, .editor-preview-root":{height:"100% !important",width:"auto !important"},".doc-content-wrapper":{pb:"0 !important",minH:"auto !important"},"[data-doc-background-element], [data-doc-background-element-present-mode]":{display:"none !important"},".card2-background":{mt:0}}},4515:function(t,e,a){"use strict";a.r(e),a.d(e,{PromptStudio:function(){return tr}});var r=a(52322),n=a(11919),o=a(63413),s=a(2784),i=a(61697),l=a(83049);let u=(0,l.ZF)({apiKey:"AIzaSyBSeAlKxWOjtGDuLwfMV-cjgUdRPtX6pKM",authDomain:"prompt-studio-18f19.firebaseapp.com",projectId:"prompt-studio-18f19",storageBucket:"prompt-studio-18f19.appspot.com",messagingSenderId:"484278304471",appId:"1:484278304471:web:e7b571b23548551606fa92"}),d=(0,o.ad)(u),c=(0,o.hJ)(d,"/examples"),m=(0,o.hJ)(d,"/html-outputs"),p=(0,o.hJ)(d,"/prompts");var h=a(53738),f=a(94659),g=a(50390),y=a(2046),x=a(70287),v=a(25793),b=a(8022);let j=t=>{let{promptDoc:e}=t,{systemPrompt:a,userPrompt:n,maxTokens:s,temperature:i}=e.data(),l=(t,a)=>{(0,o.r7)(e.ref,{[t]:a})};return(0,r.jsx)(h.xu,{flex:"1",p:4,overflowY:"auto",maxH:"100%",children:(0,r.jsxs)(f.g,{align:"start",spacing:4,children:[(0,r.jsx)(g.X,{size:"md",children:"Prompt definition"}),(0,r.jsxs)(y.NI,{children:[(0,r.jsx)(x.l,{children:"System Prompt"}),(0,r.jsx)(w,{defaultValue:a,onChange:t=>l("systemPrompt",t.target.value)})]}),(0,r.jsxs)(y.NI,{children:[(0,r.jsx)(x.l,{children:"User Prompt"}),(0,r.jsx)(v.g,{fontFamily:"monospace",bg:"white",rows:20,defaultValue:n,onChange:t=>l("userPrompt",t.target.value)})]}),(0,r.jsxs)(y.NI,{children:[(0,r.jsx)(x.l,{children:"Max tokens"}),(0,r.jsx)(b.Y2,{defaultValue:s,onChange:(t,e)=>l("maxTokens",e),bg:"white",children:(0,r.jsx)(b.zu,{})})]}),(0,r.jsxs)(y.NI,{children:[(0,r.jsx)(x.l,{children:"Temperature"}),(0,r.jsx)(b.Y2,{bg:"white",defaultValue:i,onChange:(t,e)=>l("temperature",e),children:(0,r.jsx)(b.zu,{})})]})]})})},w=t=>{let{...e}=t;return(0,r.jsx)(v.g,{fontFamily:"monospace",bg:"white",rows:20,...e})};var k=a(8283),C=a(45650),N=a(42946),I=a(49929),O=a(29318),S=a(75832),P=a(54691),T=a(6997),E=a(31490),L=a(21041),D=a(93206),z=a(43019),F=a(6501),K=a(52906),U=a(61870),J=a(65396);let M=async(t,e,a)=>{(0,K.Uu)();let r=new DOMParser().parseFromString(t,"text/html"),n=(0,J.F)(r,"section").map(async(t,r)=>(0,F.sj)(t.outerHTML,{cardIndex:r,loadImages:!0,docFormatKey:a,theme:e})),o=await Promise.all(n),s=(0,z.getCardTitle)(o[0]);return{doc:(0,U.vL)({docFlags:{cardLayoutsEnabled:!0},format:a},o),title:s}},G=async(t,e,a,r,n)=>{let s={input:e,numCards:D.N},i=new T.u({variables:["input","numCards"],systemPrompt:r.systemPrompt,userPrompt:r.userPrompt,params:{maxTokens:r.maxTokens,temperature:r.temperature}}),l="prompt-studio-"+(0,E.nZ)(),u=i.prepare({variables:s}),d=u.messages.reduce((t,e)=>{var a;return t+((null===(a=e.content)||void 0===a?void 0:a.length)||0)},0),c=performance.now(),p=await (0,o.ET)(m,{promptKey:a,input:e,inputId:t,startTime:o.EK.fromDate(new Date),userPrompt:i.getUserChatMessage(s).c
1ontent,systemPrompt:i.getSystemChatMessage(s).content,inputChars:d}),h=await (0,P.I)(u,l,{timeout:12e4});if(!h)return;let f=performance.now()-c;if(!h)return;await (0,o.r7)(p,{outputHtml:h,outputChars:h.length,endTime:o.EK.fromDate(new Date),latency:f});let g=r.format?Object.values(L.U).find(t=>t.key===r.format):L.U.presentation,{doc:y}=await M(h,n,g.docFormat);await (0,o.r7)(p,{outputJSON:JSON.stringify(y)})};var H=a(76648),A=a(93319),_=a(67887),R=a(81927),X=a(89190),V=a(73848),B=a(24798),W=a(91012),Y=a(84520),q=a(95085),Z=a(28918),Q=a(32186);let $=t=>{let{example:e,promptKey:a,promptDef:l}=t,{input:u}=e.data(),[d,c,p]=(0,i.Kx)((0,o.IO)(m,(0,o.ar)("inputId","==",e.id),(0,o.Xo)("startTime","desc"),(0,o.b9)(1)));p&&console.error(p);let f=null==d?void 0:d.docs[0],g=(0,s.useCallback)(async t=>{await (0,o.r7)(e.ref,{input:t.target.value})},[e.ref]),y=(0,s.useCallback)(async()=>{await (0,o.oe)(e.ref)},[e.ref]),x=(0,O.c2)("prism"),b=(0,s.useCallback)(async()=>{G(e.id,u,a,l,x)},[e.id,u,l,a,x]);return(0,r.jsxs)(k.U,{spacing:2,w:"100%",h:"48em",align:"stretch",children:[(0,r.jsxs)(h.xu,{flex:"1",position:"relative",children:[(0,r.jsx)(v.g,{bg:"white",fontFamily:"monospace",defaultValue:u,onChange:g,h:"100%",w:"100%"}),(0,r.jsxs)(H.h,{size:"sm",position:"absolute",bottom:2,left:2,right:2,zIndex:2,children:[(0,r.jsx)(C.z,{onClick:b,children:"Generate HTML"}),(0,r.jsx)(A.L,{}),(0,r.jsx)(_.h,{"aria-label":"delete",icon:(0,r.jsx)(I.G,{icon:N.XAH}),onClick:y})]})]}),(0,r.jsx)(n.k,{flex:"3",direction:"column",children:f&&(0,r.jsx)(tt,{outputDoc:f,promptDef:l})})]})},tt=t=>{let{outputDoc:e,promptDef:a}=t,n=e.data(),{outputHtml:i,outputJSON:l,endTime:u,latency:d,outputChars:c}=n,m=c?(0,Z.J1)(i):void 0,p=(0,s.useMemo)(()=>l?JSON.parse(l):void 0,[l]),f=(0,O.c2)("prism"),g=(0,s.useCallback)(async()=>{if(!i)return;let t=a.format?Object.values(L.U).find(t=>t.key===a.format):L.U.presentation;(0,K.Uu)();let{doc:r}=await M(i,f,t.docFormat);await (0,o.r7)(e.ref,{outputJSON:JSON.stringify(r)})},[e.ref,i,f,a.format]);return(0,r.jsx)(R.O,{isLoaded:!!u,h:"100%",children:(0,r.jsxs)(X.m,{h:"100%",display:"flex",flexDirection:"column",children:[(0,r.jsxs)(k.U,{children:[(0,r.jsxs)(V.t,{children:[(0,r.jsx)(B.O,{children:"Editor"}),(0,r.jsx)(B.O,{children:"HTML"})]}),(0,r.jsx)(C.z,{size:"sm",onClick:g,children:"Generate doc"}),(0,r.jsx)(A.L,{}),m&&(0,r.jsxs)(W.x,{children:[m," tokens"]}),d&&(0,r.jsxs)(W.x,{children:[Math.round(d/1e3),"s"]})]}),(0,r.jsxs)(Y.n,{flex:"1",display:"flex",alignItems:"stretch",justifyContent:"stretch",flexDirection:"column",sx:{'[role="tabpanel"]':{flex:1}},h:"100%",children:[(0,r.jsx)(q.x,{position:"relative",children:(0,r.jsx)(h.xu,{position:"absolute",inset:"0",overflow:"auto",children:(0,r.jsx)(h.xu,{style:{zoom:.75},children:(0,r.jsx)(Q.m,{content:p,theme:f})})})}),(0,r.jsx)(q.x,{children:(0,r.jsx)(v.g,{bg:"white",fontFamily:"monospace",readOnly:!0,value:i,h:"100%",w:"100%"})})]})]})})},te=t=>{let{promptKey:e,promptDef:a}=t,[n,l,u]=(0,i.Kx)((0,o.IO)(c,(0,o.ar)("promptKey","==",e),(0,o.Xo)("createdTime","asc")));u&&console.error(u);let d=(0,O.c2)("prism"),m=(0,s.useCallback)(async()=>{Promise.all(((null==n?void 0:n.docs)||[]).map(async t=>{let{input:r}=t.data();G(t.id,r,e,a,d)}))},[null==n?void 0:n.docs,e,a,d]),p=(0,s.useCallback)(async()=>{await (0,o.ET)(c,{promptKey:e,input:"",createdTime:o.EK.fromDate(new Date)})},[e]);return(0,r.jsx)(h.xu,{flex:"3",p:4,pr:8,maxH:"100%",overflowY:"auto",children:(0,r.jsxs)(f.g,{spacing:4,align:"start",children:[(0,r.jsxs)(k.U,{children:[(0,r.jsx)(g.X,{size:"md",mr:6,children:"Prompt outputs"}),(0,r.jsx)(C.z,{variant:"solid",size:"sm",onClick:m,children:"Generate HTML"})]}),(0,r.jsx)(S.Y,{}),null==n?void 0:n.docs.map(t=>(0,r.jsx)($,{example:t,promptKey:e,promptDef:a},t.id)),(0,r.jsx)(C.z,{variant:"solid",leftIcon:(0,r.jsx)(I.G,{icon:N.r8p}),onClick:p,children:"Add example"})]})})},ta={systemPrompt:"You are a ...",userPrompt:"Now, ...",temperature:.7,maxTokens:2e3},tr=t=>{let{promptKey:e}=t,[a,l,u]=(0,i.Kx)((0,o.IO)(p,(0,o.ar)("key","==",e)));u&&console.error(u);let d=null==a?void 0:a.docs[0],c=null==d?void 0:d.data();return((0,s.useEffect)(()=>{l||u||!a||a.docs.length>0||!e||(console.log("No prompt found, creating one"),(0,o.ET)(p,{...ta,key:e}))},[a,l,u,e]),d&&c)?(0,r.jsxs)(n.k,{direction:"row",w:"100%",flex:1,maxH:"100vh",children:[(0,r.jsx)(j,{promptDoc:d}),(0,r.jsx)(te,{promptKey:e,promptDef:c})]}):null}},90775:function(t,e,a){"use strict";a.d(e,{N:function(){return r}});let r=(t,e)=>o(new n(t,null),e);class n{get type(){return this.jsonNode.type}get text(){return this.jsonNode.text}get content(){return this.jsonNode.content?this.jsonNode.content.map(t=>new n(t,this)):this.jsonNode.content}get attrs(){return this.jsonNode.attrs}set attrs(t){this.jsonNode.attrs=t}constructor(t,e){this.jsonNode=t,this.parent=e,this.__type="JSONContentNode"}}let o=(t,e)=>{if(e(t),t.content)for(let a of t.content)o(a,e)}},80660:function(){}}]); 2//# sourceMappingURL=8438.039333584caf3b07.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.