wizards 0.3.8 → 0.4.0
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.
- package/README.md +28 -14
- package/apps/runtime/dist/auth/account.js +36 -4
- package/apps/runtime/dist/auth/device.js +101 -0
- package/apps/runtime/dist/auth/index.js +4 -4
- package/apps/runtime/dist/cli/account.js +289 -0
- package/apps/runtime/dist/cli/install-env.js +33 -0
- package/apps/runtime/dist/cli/main.js +17 -3
- package/apps/runtime/dist/cli/menu.js +19 -5
- package/apps/runtime/dist/cli/setup.js +9 -16
- package/apps/runtime/dist/cli/status.js +4 -1
- package/apps/runtime/dist/cli/ui.js +14 -0
- package/apps/runtime/dist/docs/user/command-line.md +3 -2
- package/apps/runtime/dist/docs/user/create-account.md +47 -0
- package/apps/runtime/dist/docs/user/first-start.md +9 -1
- package/apps/runtime/dist/docs/user/index.md +16 -12
- package/apps/runtime/dist/docs/user/install.md +3 -1
- package/apps/runtime/dist/docs/user/local-only.md +38 -0
- package/apps/runtime/dist/docs/user/meta.json +3 -1
- package/apps/runtime/dist/docs/user/models.md +3 -2
- package/apps/runtime/dist/manage.js +12 -0
- package/apps/runtime/dist/plugins/pro.js +16 -16
- package/apps/runtime/dist/routes/studio.js +41 -2
- package/apps/runtime/dist/services/cloud.js +10 -10
- package/apps/runtime/dist/services/onboarding.js +152 -0
- package/apps/web/dist/assets/{AboutDialog-ClV4gNiW.js → AboutDialog-CPQiN7H9.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-DsSEkayM.js → ChangelogDialog-DynvQuuR.js} +1 -1
- package/apps/web/dist/assets/{ChatView-BdYCnDLk.js → ChatView-CKo_9IZD.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-7PZzkNBT.js → EditorPage-CDIJXC4T.js} +1 -1
- package/apps/web/dist/assets/{FlowPreview-C_x5Kc2j.js → FlowPreview-BZLnG7GV.js} +1 -1
- package/apps/web/dist/assets/{Harness-CvvtSTZC.js → Harness-CNh3nbB_.js} +1 -1
- package/apps/web/dist/assets/{NewWizardChannels-g1qCd_tQ.js → NewWizardChannels-C1Ss9UMY.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-B3hswj5r.js → NewWizardPage-2qLAbvDL.js} +1 -1
- package/apps/web/dist/assets/OnboardingPage-C1FJwEsT.js +1 -0
- package/apps/web/dist/assets/{ProjectPage-CFDncRxT.js → ProjectPage-CGuLUuOs.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-C9N5r-sT.js → PublicRunner-BKw1lOW4.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-C1UcqOlS.js → ReadOnly-DTjv2Jzm.js} +1 -1
- package/apps/web/dist/assets/{RunDrawer-B8YzFvgz.js → RunDrawer-D1I5xqVf.js} +1 -1
- package/apps/web/dist/assets/{RunnerView-ii-PP5c-.js → RunnerView-BPPmlv9z.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-ClEP5Q0t.js → SettingsPage-zbomQfGy.js} +1 -1
- package/apps/web/dist/assets/SetupPage-D3F7M6Pz.js +1 -0
- package/apps/web/dist/assets/{SharePage-BV2S0g84.js → SharePage-BY49IJgT.js} +1 -1
- package/apps/web/dist/assets/changelog-DYZC2E6q.js +1 -0
- package/apps/web/dist/assets/{circle-alert-D-Q6DK7b.js → circle-alert-CVOH4wAv.js} +1 -1
- package/apps/web/dist/assets/{esm-CTna4iL0.js → esm-BfXdeWaI.js} +1 -1
- package/apps/web/dist/assets/index-B9xVkr2X.css +1 -0
- package/apps/web/dist/assets/index-BH0PYgov.js +15 -0
- package/apps/web/dist/assets/{lock-DwGN_KOC.js → lock-DHBh62LA.js} +1 -1
- package/apps/web/dist/assets/{phone-XIVIe17d.js → phone-Bt1cyWpY.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-JuSRq6NP.js → settings-menu-ace1vI3i.js} +1 -1
- package/apps/web/dist/assets/{ui-DrjXmHdO.js → ui-D2SqIZeQ.js} +1 -1
- package/apps/web/dist/assets/{upload-CDxTpAqx.js → upload-CCEq88l4.js} +1 -1
- package/apps/web/dist/index.html +3 -3
- package/apps/web/dist/install.sh +17 -7
- package/apps/web/dist/mcp/flow.html +2 -2
- package/package.json +1 -1
- package/apps/web/dist/assets/SetupPage-CDFzo6LT.js +0 -1
- package/apps/web/dist/assets/changelog-wZI-UaUi.js +0 -1
- package/apps/web/dist/assets/index-DUjJx-uk.css +0 -1
- package/apps/web/dist/assets/index-DnQgOKOQ.js +0 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Et as r}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Et as r}from"./ui-D2SqIZeQ.js";import{a as i,c as a,i as o,n as s,r as c,s as l,t as u}from"./esm-BfXdeWaI.js";var d=e(t(),1),f=e(n(),1),p=208,m=42,h=26,g=22,_=132;function v({data:e}){let t=e.icon;return(0,f.jsxs)(`div`,{style:{width:p,height:m},className:r(`flex cursor-default items-center gap-2.5 rounded-xl px-2.5`,e.optional?`border border-ink-4 border-dashed`:`bg-paper-2 ring-1 ring-border-soft`),children:[(0,f.jsx)(c,{type:`target`,position:a.Top}),(0,f.jsx)(c,{type:`target`,id:`in`,position:a.Right}),(0,f.jsx)(`span`,{className:r(`inline-flex size-6 shrink-0 items-center justify-center rounded-md`,e.tone),children:(0,f.jsx)(t,{className:`size-3.5`})}),(0,f.jsx)(`span`,{className:`truncate font-medium text-[0.8125rem] text-ink`,children:e.title}),(0,f.jsx)(c,{type:`source`,position:a.Bottom}),(0,f.jsx)(c,{type:`source`,id:`out`,position:a.Right})]})}function y({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,markerEnd:a}){let o=Math.max(e,n)+g,c=[`M ${e} ${t}`,`H ${o-8}`,`Q ${o} ${t} ${o} ${t+8}`,`V ${r-8}`,`Q ${o} ${r} ${o-8} ${r}`,`H ${n}`].join(` `);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u,{path:c,markerEnd:a,style:{strokeDasharray:`5 4`}}),(0,f.jsx)(s,{children:(0,f.jsx)(`div`,{style:{width:_,transform:`translate(${o+8}px, ${(t+r)/2}px) translateY(-50%)`},className:`absolute text-[0.6875rem] text-ink-2 leading-snug`,children:i})})]})}var b={step:v},x={branch:y};function S(e){let t={markerEnd:{type:l.ArrowClosed,width:14,height:14,color:`var(--ink-4)`}},n=e.map((e,t)=>({id:e.id,type:`step`,position:{x:0,y:t*68},data:{title:e.title,icon:e.icon,tone:e.tone,optional:e.optional},draggable:!1})),r=[],i=!1;return e.forEach((n,a)=>{let o=e[a+1];for(let[a,o]of(n.branches??[]).entries())e.some(e=>e.id===o.to)&&(i=!0,r.push({id:`b-${n.id}-${a}`,type:`branch`,source:n.id,sourceHandle:`out`,target:o.to,targetHandle:`in`,label:o.when,...t}));o&&r.push({id:`n-${n.id}`,type:`straight`,source:n.id,target:o.id,...t})}),{nodes:n,edges:r,width:p+(i?162:0),height:e.length*68-h}}function C({steps:e}){let{nodes:t,edges:n,width:r,height:a}=(0,d.useMemo)(()=>S(e),[e]);return e.length?(0,f.jsx)(`div`,{className:`max-w-full`,style:{width:r,height:a+4},children:(0,f.jsx)(o,{children:(0,f.jsx)(i,{nodes:t,edges:n,nodeTypes:b,edgeTypes:x,defaultViewport:{x:1,y:2,zoom:1},minZoom:1,maxZoom:1,nodesConnectable:!1,nodesDraggable:!1,nodesFocusable:!1,edgesFocusable:!1,elementsSelectable:!1,panOnDrag:!1,panOnScroll:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0}})})}):null}export{C as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r}from"./logo-C4V2_3Ar.js";import{At as i,Et as a,sn as o,u as s,ut as c,y as l,zt as u}from"./ui-DrjXmHdO.js";import{ut as d,vn as f}from"./index-DnQgOKOQ.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r}from"./logo-C4V2_3Ar.js";import{At as i,Et as a,sn as o,u as s,ut as c,y as l,zt as u}from"./ui-D2SqIZeQ.js";import{ut as d,vn as f}from"./index-BH0PYgov.js";var p=e(t(),1),m=2,h=1,g=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(m,Math.floor(u/e.css.cell.width)),rows:Math.max(h,Math.floor(l/e.css.cell.height))}}},_=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=te.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function ee(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var te=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!ee(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},ne=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function re(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var ie=class{constructor(e=re,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||ne;this._linkProvider=this._terminal.registerLinkProvider(new _(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ae=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,se=(e,t)=>{for(var n in t)ae(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?oe(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&ae(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ce=`Terminal input`,b={get:()=>ce,set:e=>ce=e},le=`Too much output to announce, navigate to rows manually to read`,ue={get:()=>le,set:e=>le=e};function de(e){return e.replace(/\r?\n/g,`\r`)}function x(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function fe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function pe(e,t,n,r){e.stopPropagation(),e.clipboardData&&me(e.clipboardData.getData(`text/plain`),t,n,r)}function me(e,t,n,r){e=de(e),e=x(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function he(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ge(e,t,n,r,i){he(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _e(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ve=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ye=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},be=``,xe=` `,Se=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ce}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ce=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},C=class e extends Se{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ce,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},we=`di$target`,Te=`di$dependencies`,Ee=new Map;function De(e){return e[Te]||[]}function w(e){if(Ee.has(e))return Ee.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Oe(t,e,r)};return t._id=e,Ee.set(e,t),t}function Oe(e,t,n){t[we]===t?t[Te].push({id:e,index:n}):(t[Te]=[{id:e,index:n}],t[we]=t)}var T=w(`BufferService`),ke=w(`CoreMouseService`),Ae=w(`CoreService`),je=w(`CharsetService`),Me=w(`InstantiationService`),Ne=w(`LogService`),E=w(`OptionsService`),Pe=w(`OscLinkService`),Fe=w(`UnicodeService`),Ie=w(`DecorationService`),Le=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new C,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Re(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Le=v([y(0,T),y(1,E),y(2,Pe)],Le);function Re(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ze=w(`CharSizeService`),Be=w(`CoreBrowserService`),Ve=w(`MouseService`),He=w(`RenderService`),Ue=w(`SelectionService`),We=w(`CharacterJoinerService`),Ge=w(`ThemeService`),Ke=w(`LinkProviderService`),qe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$e.isErrorNoTelemetry(e)?new $e(e.message+`
|
|
4
4
|
|
package/apps/web/dist/assets/{NewWizardChannels-g1qCd_tQ.js → NewWizardChannels-C1Ss9UMY.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{At as r,Et as i,Nt as a,cn as o,pn as s,sn as c,z as l}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{At as r,Et as i,Nt as a,cn as o,pn as s,sn as c,z as l}from"./ui-D2SqIZeQ.js";import{t as u}from"./phone-Bt1cyWpY.js";import{an as d,ln as f,nn as p,rn as m}from"./index-BH0PYgov.js";var h={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};h.node;var g=s(h),_=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...l],[..._];var v={default:`steps`,enabled:[`steps`,`chat`]},y=e(t(),1),b=e(n(),1),x=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:d},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:m},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:o},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:a},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:u},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:g},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],S=[{id:`web`,label:`new.web`,icon:f},{id:`phone`,label:`new.phone`,icon:u},{id:`message`,label:`new.messages`,icon:p}],C=x.filter(e=>v.enabled.includes(e.id)).map(e=>e.id),w=e=>x.filter(t=>e.includes(t.id));function T(e){return e.length===C.length&&C.every(t=>e.includes(t))}function E(e){let t=w(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??v.default,enabled:n}}var D=e=>e.map(e=>r(e.label));function O(e){return x.find(t=>t.runner===e)}function k(e){return x.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function A(e){let t=w(e),n=S.flatMap(e=>{let n=D(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${r(e.label)}: ${n.join(`, `)}`]:[]});return`${r(`new.runsAs`)}: ${n.join(` · `)}`}function j(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function M({channel:e,className:t}){let n=e.icon;return n?(0,b.jsx)(n,{className:t??`size-4`}):(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function N(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`,`talk`,`video`]);return x.filter(e=>t.has(e.runner))}function P({value:e,onChange:t,runners:n,without:a,disabled:o}){let s=N(n).filter(e=>!a?.includes(e.id)),l=t=>e.includes(t.id),u=n=>{o||l(n)&&e.length===1||t(l(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=S.find(e=>e.id===t),a=s.filter(e=>e.group===t);if(!(n&&a.length))return null;let d=n.icon;return(0,b.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col border-0 p-0`,children:[(0,b.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,b.jsx)(d,{className:`size-3.5`}),` `,r(n.label)]}),a.map(t=>(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`label`,{className:i(`flex h-10 w-full cursor-pointer items-center gap-2.5 rounded-lg px-2 text-[0.875rem] transition hover:bg-accent has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-focus coarse:h-11`,l(t)&&`bg-paper-2`),children:[(0,b.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,b.jsx)(M,{channel:t})}),(0,b.jsx)(`span`,{className:`flex-1`,children:r(t.label)}),(0,b.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":r(t.label),checked:l(t),disabled:o,"aria-disabled":l(t)&&e.length===1,onChange:()=>u(t)}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:i(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,l(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:l(t)?(0,b.jsx)(c,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&l(t)?(0,b.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:r(`new.callHandoff`)}):null]},t.id))]})};return(0,b.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function F({value:e,onChange:t,runners:n,className:a}){let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(0),u=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!o)return;let e=e=>{u.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[o]);let d=N(n),f=S.filter(e=>d.some(t=>t.group===e.id)),p=t=>e.includes(t.id);return(0,b.jsxs)(`div`,{ref:u,className:i(`relative flex flex-wrap items-center gap-1.5`,a),children:[(0,b.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:r(`new.runsAs`)}),f.map(e=>{let t=D(d.filter(t=>t.group===e.id&&p(t))),n=e.icon;return(0,b.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":o,"aria-label":`${r(e.label)}: ${t.length?t.join(`, `):r(`new.off`)}`,onClick:e=>{let t=e.currentTarget;l(t.offsetLeft+t.offsetWidth/2),s(e=>!e)},className:i(`inline-flex h-9 items-center justify-center gap-1.5 rounded-full font-medium text-[0.8125rem] transition coarse:h-11`,t.length?`bg-ink px-3 text-paper`:`w-9 text-ink-3 ring-1 ring-border hover:text-ink coarse:w-11`),children:[(0,b.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,b.jsx)(`span`,{className:`truncate`,children:j(t)}):null]},e.id)}),o?(0,b.jsxs)(`div`,{role:`dialog`,"aria-label":r(`new.where`),style:{transformOrigin:`${c}px top`},className:`absolute top-full left-0 z-20 mt-2 w-[min(32rem,calc(100vw-2rem))] animate-unfold rounded-2xl bg-card p-3 text-left shadow-overlay ring-1 ring-border`,children:[(0,b.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:r(`new.where`)}),(0,b.jsx)(P,{value:e,onChange:t,runners:n})]}):null]})}export{C as a,k as c,F as i,T as l,M as n,A as o,P as r,O as s,S as t,E as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i,v as a}from"./logo-C4V2_3Ar.js";import{At as o,Cn as s,Et as c,Gt as l,Mt as u,Ot as d,Tt as f,Vt as p,_n as m,a as h,c as g,ct as _,ft as v,l as y,o as b,pt as x,r as S,s as ee,u as C,un as te,ut as w,xn as T,y as E}from"./ui-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i,v as a}from"./logo-C4V2_3Ar.js";import{At as o,Cn as s,Et as c,Gt as l,Mt as u,Ot as d,Tt as f,Vt as p,_n as m,a as h,c as g,ct as _,ft as v,l as y,o as b,pt as x,r as S,s as ee,u as C,un as te,ut as w,xn as T,y as E}from"./ui-D2SqIZeQ.js";import{a as ne,i as re,l as D,o as O,u as ie}from"./NewWizardChannels-C1Ss9UMY.js";import{t as k}from"./upload-CCEq88l4.js";import{It as ae,Ot as A,S as j,b as oe,jt as M,vn as N,x as P,y as F}from"./index-BH0PYgov.js";var I=[[`id`,8],[`toolId`,10],[`moduleId`,7],[`pluginId`,6],[`title`,6],[`description`,4],[`tags`,3],[`path`,3],[`inputSchema`,2],[`outputSchema`,2],[`request`,1],[`response`,1]];function L(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function R(e){return L(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function z(e){return e==null?``:Array.isArray(e)?e.map(z).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(z).filter(Boolean).join(` `):String(e)}function B(e,t){let n=t.map(([t,n])=>({text:z(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>R(e.text))}}function V(e){let t=[e];if(e.length<5)return t;if(e.endsWith(`ing`)){let n=e.slice(0,-3);n.length>=3&&t.push(n,`${n}e`)}else if(e.endsWith(`ies`)&&e.length>=6)t.push(`${e.slice(0,-3)}y`);else if(e.endsWith(`es`))t.push(e.slice(0,-2),e.slice(0,-1));else if(e.endsWith(`ed`)){let n=e.slice(0,-2);t.push(n,`${n}e`)}else e.endsWith(`s`)&&!e.endsWith(`ss`)&&t.push(e.slice(0,-1));return[...new Set(t)]}function H(e,t){if(e===t)return 1;let n=0;for(let r of V(e))for(let i of V(t)){if(r===i){n=Math.max(n,r===e&&i===t?1:.75);continue}r.length>=2&&i.startsWith(r)&&(n=Math.max(n,.55*(r.length/i.length))),i.length>=4&&r.startsWith(i)&&(n=Math.max(n,.4*(i.length/r.length)))}return n}function U(e,t){return e.reduce((e,n)=>e+H(t,n),0)}function W(e,t,n=I){if(!t?.trim())return 0;let r=R(t);if(r.length===0)return 0;let i=B(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>U(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=R(n.text),i=U(r,t);if(i===0)return e;let a=i*2.2/(i+1.2+r.length/16);return e+n.weight*a},0),0)}var G=new Set(R(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
|
|
2
2
|
des die dies diese dieser doch du ein eine einem einen einer eines er es etwas fuer für gerne
|
|
3
3
|
habe haben hat ich ihr im in ist kann können koennen mache machen mag mein meine meinem meinen
|
|
4
4
|
meiner mich mir mit möchte moechte nach nicht noch nur oder sich sie sind soll suche suchen
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,t as i}from"./logo-C4V2_3Ar.js";import{At as a,Et as o,Qt as s,sn as c,u as l,un as u,xn as d}from"./ui-D2SqIZeQ.js";import{t as f}from"./upload-CCEq88l4.js";import{It as p,Mt as m,Ot as h,Rt as g,dt as _,vn as v}from"./index-BH0PYgov.js";var y=e(t(),1),b=e(n(),1),x=`oklch(50% 0.2 262)`,S=`oklch(32% 0.15 262)`,C={"--on":`white`,"--dot":`oklch(90% 0.1 80)`,"--ink-2":`oklch(96% 0.02 262)`,"--ink-3":`oklch(90% 0.035 262)`,"--moss":`oklch(90% 0.14 150)`,"--rose":`oklch(89% 0.09 45)`},w=`w-full rounded-[18px] border border-white/30 bg-white/15 px-6 py-5 text-[1.375rem] text-white outline-none placeholder:text-white/55 focus:border-white/60`;function T(){return(0,b.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,b.jsx)(i,{size:28}),(0,b.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,b.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,b.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function E({children:e,busy:t,onClick:n,type:r=`button`}){return(0,b.jsxs)(`button`,{type:r,disabled:t,onClick:n,className:`inline-flex h-13 cursor-pointer items-center gap-2.5 rounded-full bg-white px-7 font-semibold text-[1rem] transition hover:bg-white/90 disabled:cursor-default disabled:opacity-70`,style:{color:S},children:[e,(0,b.jsx)(u,{className:`size-[18px]`})]})}function D({children:e,onClick:t}){return(0,b.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function O({step:e}){return(0,b.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":a(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,b.jsx)(`span`,{className:o(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}function k(){g(x);let e=m(),t=r(),n=d(),{project:i}=h(),[u,k]=(0,y.useState)(1),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(``),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)([]),B=(0,y.useRef)(null),V=v({mutationFn:e=>l.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),H=v({mutationFn:e=>l.post(`/api/studio/projects/${i?.id}/website`,{url:e}),onSuccess:async e=>{L(e),await t.invalidateQueries({queryKey:[`projects`]})}}),U=v({mutationFn:e=>l.patch(`/api/studio/projects/${i?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),W=v({mutationFn:()=>l.post(`/api/studio/onboarding/done`),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),G=e.data?.user.name??``,K=G.includes(`@`)?``:G.split(` `)[0],q=async e=>{if(e&&i){for(let t of Array.from(e)){z(e=>[...e,{name:t.name,state:`uploading`}]);try{await l.upload(`/api/studio/projects/${i.id}/files?kind=document`,t),z(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{z(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},J=I?[I.about?a(`onboard.readAbout`):``,I.colors?a(`onboard.readColors`,{n:I.colors}):``,I.logo?a(`onboard.readLogo`):``].join(``):``;return(0,b.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...C,background:x},children:[(0,b.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,b.jsx)(T,{}),(0,b.jsx)(_,{tone:`ground`,ink:S})]}),(0,b.jsxs)(`main`,{className:`mx-auto grid w-full max-w-6xl flex-1 items-center gap-10 py-10 lg:grid-cols-[5fr_7fr] lg:gap-12`,children:[(0,b.jsx)(`div`,{className:`flex justify-center max-lg:order-first`,children:(0,b.jsx)(p,{kind:`drop`,size:240,fluffy:!0,coat:`fur`})}),(0,b.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[u===1?(0,b.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=A.trim();t?V.mutate(t,{onSuccess:()=>k(2)}):k(2)},children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:K?a(`onboard.kicker1`,{name:K}):a(`onboard.kicker1Anon`)}),(0,b.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:a(`onboard.team`)}),(0,b.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:a(`onboard.teamSub`)}),(0,b.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:a(`onboard.teamPlaceholder`),maxLength:80,"aria-label":a(`onboard.team`),className:w}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,b.jsx)(E,{type:`submit`,busy:V.isPending,children:a(`onboard.continue`)}),(0,b.jsx)(O,{step:1})]})]}):null,u===2?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:a(`onboard.kicker2`)}),(0,b.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:a(`onboard.site`)}),(0,b.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:a(`onboard.siteSub`)}),P===null?(0,b.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),M.trim()&&!H.isPending&&H.mutate(M.trim())},children:[(0,b.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:a(`onboard.sitePlaceholder`),inputMode:`url`,autoCapitalize:`none`,"aria-label":a(`onboard.site`),className:w}),I?(0,b.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,b.jsx)(c,{className:`size-4`}),a(`onboard.readDone`,{name:I.name,details:J})]}):H.isError?(0,b.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:a(`onboard.readFailed`)}):null,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[I?(0,b.jsx)(E,{onClick:()=>k(3),children:a(`onboard.continue`)}):(0,b.jsx)(E,{type:`submit`,busy:H.isPending,children:H.isPending?a(`onboard.reading`):a(`onboard.read`)}),(0,b.jsx)(D,{onClick:()=>F(``),children:a(`onboard.line`)}),(0,b.jsx)(D,{onClick:()=>k(3),children:a(`onboard.skip`)}),(0,b.jsx)(O,{step:2})]})]}):(0,b.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=P.trim();t?U.mutate(t,{onSuccess:()=>k(3)}):k(3)},children:[(0,b.jsx)(`textarea`,{value:P,onChange:e=>F(e.target.value),placeholder:a(`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":a(`onboard.line`),className:o(w,`resize-none text-[1.125rem] leading-relaxed`)}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,b.jsx)(E,{type:`submit`,busy:U.isPending,children:a(`onboard.continue`)}),(0,b.jsx)(D,{onClick:()=>F(null),children:a(`onboard.site`)}),(0,b.jsx)(D,{onClick:()=>k(3),children:a(`onboard.skip`)}),(0,b.jsx)(O,{step:2})]})]})]}):null,u===3?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:a(`onboard.kicker3`)}),(0,b.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:a(`onboard.know`)}),(0,b.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:a(`onboard.knowSub`)}),(0,b.jsxs)(`button`,{type:`button`,onClick:()=>B.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),q(e.dataTransfer.files)},className:`flex cursor-pointer flex-col items-center gap-2 rounded-[18px] border-2 border-white/45 border-dashed bg-white/10 px-6 py-7 text-center transition hover:bg-white/15`,children:[(0,b.jsx)(f,{className:`size-7`}),(0,b.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:a(`onboard.drop`)}),(0,b.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,b.jsx)(`input`,{ref:B,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{q(e.target.files),e.target.value=``}})]}),R.length?(0,b.jsx)(`ul`,{className:`flex flex-col gap-2`,children:R.map(e=>(0,b.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-xl bg-white/15 px-3.5 py-2.5 text-[0.875rem]`,children:[(0,b.jsx)(s,{className:`size-4 shrink-0`}),(0,b.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,b.jsx)(`span`,{className:o(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?a(`onboard.uploading`):e.state===`done`?a(`onboard.uploaded`):a(`onboard.uploadFailed`)})]},e.name))}):null,(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,b.jsx)(E,{busy:R.some(e=>e.state===`uploading`),onClick:()=>k(4),children:a(`onboard.continue`)}),R.length?null:(0,b.jsx)(D,{onClick:()=>k(4),children:a(`onboard.skip`)}),(0,b.jsx)(O,{step:3})]})]}):null,u===4?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:a(`onboard.kicker4`)}),(0,b.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:a(`onboard.space`)}),(0,b.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:a(`onboard.spaceSub`,{space:i?.name??``})}),(0,b.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(I||P)],[`partKnow`,`partKnowText`,R.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-2xl border border-white/20 bg-white/10 px-4.5 py-4`,children:[(0,b.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,b.jsx)(c,{className:`size-4 text-(color:--moss)`}):null,a(`onboard.${e}`)]}),(0,b.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:a(`onboard.${t}`)})]},e))}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,b.jsx)(E,{busy:W.isPending,onClick:()=>W.mutate(),children:a(`onboard.build`)}),(0,b.jsx)(O,{step:4})]})]}):null]},u)]}),(0,b.jsxs)(`footer`,{className:`mx-auto flex w-full max-w-6xl items-center justify-between pb-6 text-[0.75rem] text-white/55 sm:pb-8`,children:[(0,b.jsx)(`span`,{children:`engenty`}),(0,b.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{k as OnboardingPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{$t as a,At as o,Cn as s,Ct as c,E as l,Et as u,Gt as d,Ht as f,Lt as p,Ot as m,Pt as h,Qt as g,Sn as _,St as v,Tt as y,Vt as b,Yt as x,Zt as S,_n as C,_t as w,bn as ee,bt as T,dt as E,en as D,ft as O,gt as k,ht as A,ln as te,mt as j,nn as M,pn as N,pt as P,sn as F,u as I,ut as L,wt as ne,xn as re,xt as R,zt as ie}from"./ui-DrjXmHdO.js";import{_ as ae,a as oe,b as z,c as se,d as ce,f as B,g as le,h as ue,i as de,l as fe,m as pe,n as V,o as me,p as he,s as ge,u as _e,v as ve,x as H,y as U}from"./RunDrawer-B8YzFvgz.js";import{t as W}from"./phone-XIVIe17d.js";import{n as ye,r as be,t as xe}from"./ReadOnly-C1UcqOlS.js";import{t as G}from"./upload-CDxTpAqx.js";import{$ as Se,At as Ce,B as we,G as K,H as Te,I as q,J as Ee,K as De,Kt as Oe,L as J,Ot as ke,Q as Ae,R as je,U as Y,V as Me,Vt as Ne,W as Pe,Wt as Fe,X as Ie,Xt as Le,Y as Re,Yt as ze,Z as X,Zt as Be,_ as Ve,an as He,at as Ue,ct as We,d as Ge,et as Ke,f as qe,g as Je,in as Ye,it as Xe,kt as Ze,l as Qe,mt as $e,nt as et,ot as tt,p as nt,q as rt,rt as it,s as at,st as ot,tt as st,u as ct,un as lt,v as ut,vn as dt,z as ft}from"./index-DnQgOKOQ.js";import{a as Z,c as pt,f as mt,i as ht,n as gt,o as _t,r as vt,s as yt,t as bt,u as xt}from"./settings-menu-JuSRq6NP.js";import{t as St}from"./RunnerView-ii-PP5c-.js";var Ct={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Ct.node;var wt=N(Ct),Tt={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};Tt.node;var Et=N(Tt),Dt={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};Dt.node;var Ot=N(Dt),kt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};kt.node;var At=N(kt),jt={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};jt.node;var Mt=N(jt),Nt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Nt.node;var Pt=N(Nt),Ft={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Ft.node;var It=N(Ft),Lt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Lt.node;var Rt=N(Lt),zt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};zt.node;var Bt=N(zt),Vt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};Vt.node;var Ht=N(Vt),Q=e(t(),1),$=e(n(),1),Ut={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Wt({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let s=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:o(s?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function Gt(e,t){confirm(o(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Kt({projectId:e,file:t,small:n}){let r=Xe(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:u(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(qt,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(Ht,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(g,{className:i}):t.mime===`application/json`?(0,$.jsx)(p,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Et,{className:i}):(0,$.jsx)(S,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function qt({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,$.jsx)(`div`,{className:u(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Jt=`application/x-wizards-logo`;function Yt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:s,onPreview:c,mainId:l,onMakeMain:u,moveTo:d,onRemove:f}){let p=e=>f?f(e):Gt(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:d&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Jt,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===l?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(O,{tone:`ember`,children:o(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Ut:void 0,children:[c&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${o(`project.preview`)}: ${n.name}`,onClick:()=>c(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Kt,{projectId:e,file:n})}):(0,$.jsx)(Kt,{projectId:e,file:n}),(0,$.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[c?(0,$.jsx)(A,{label:o(`project.preview`),onClick:()=>c(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(lt,{className:`size-4`})}):null,u&&n.id!==l&&!r.readOnly?(0,$.jsx)(A,{label:o(`project.logoMakeMain`),onClick:()=>u(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Oe,{className:`size-4`})}):null,d&&!r.readOnly?(0,$.jsx)(we,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(Wt,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(je,{accept:i,multiple:!1,onFiles:e=>s?s(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(R,{className:`size-5`}):(0,$.jsx)(b,{className:`size-5`}),a]}):null]})}function Xt({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),g=async()=>{c(!0),d(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(p(a.candidates),h([a.candidates[0].url])):d(o(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}c(!1)},_=async()=>{c(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}c(!1),e.length&&n(e),e.length===m.length&&r()};return(0,$.jsx)(P,{open:!0,onClose:r,wide:f?!0:void 0,title:o(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:u(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Ut,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:u(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]},t.url)})}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>p(null),children:o(`run.back`)}),(0,$.jsx)(L,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?o(`project.addMany`,{n:m.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:s,disabled:!i.trim(),children:o(`run.next`)})]})]})})}function Zt(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>I.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function Qt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var $t=e=>[Qt(e),e.pages?o(`project.pages`,{n:e.pages}):null,it(e.size)].filter(Boolean).join(` · `),en=2e5;function tn({projectId:e,fileId:t,readOnly:n,onGone:i}){let s=r(),c=We(e),l=pe(e),d=tt(e,n),f=c.data?.files.find(e=>e.id===t),p=f?f.mime===`application/pdf`||f.mime.startsWith(`image/`):!1,[m,g]=(0,Q.useState)(null);if(!f)return c.isLoading?(0,$.jsx)(R,{className:`mx-auto text-ink-3`}):null;let _=m??(p?`original`:`text`),v=l.data?.items.find(e=>e.key===`f:${f.id}`),y=Xe(e,f.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":_===e,onClick:()=>g(e),className:u(`rounded-full px-3 py-1 text-[0.8125rem] transition`,_===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:f.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:$t(f)}),(0,$.jsx)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,"aria-label":o(`project.openOriginal`),title:o(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(a,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{label:o(`project.reindex`),onClick:async()=>{await d.reindex(f.id),await s.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(ie,{className:`size-4`})}),(0,$.jsx)(A,{label:o(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(o(`data.confirmDelete`,{title:f.name}))&&(await d.remove(f.id),await s.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,$.jsx)(h,{className:`size-4`})})]})]}),(0,$.jsx)(B,{projectId:e,itemKey:`f:${f.id}`,has:v?.categories??[],originLabel:v?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Wt,{file:f,actions:d})}),f.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null,(0,$.jsxs)(E,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[p?b(`original`,o(`project.original`)):null,b(`text`,o(`project.readText`))]}),_===`original`?f.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:y,title:f.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:y,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(nn,{projectId:e,file:f})]})]})}function nn({projectId:e,file:t}){let n=Zt(e,t,en);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(R,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(l,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:o(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:o(`project.noText`)})}var rn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,an=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),it(e.size)].filter(Boolean).join(` · `);function on({projectId:e,file:t,actions:n,onClose:r}){let i=Xe(e,t.id);return(0,$.jsxs)(P,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:an(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":o(`project.openOriginal`),title:o(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(a,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Ut,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Wt,{file:t,actions:n})})]})}function sn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${o(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Kt,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:an(t)})]}),(0,$.jsx)(Wt,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,$.jsx)(A,{label:o(`project.preview`),onClick:i,children:(0,$.jsx)(lt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(we,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})}function cn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(P,{open:!0,onClose:r,title:o(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.assetSectionName`)}),(0,$.jsx)(k,{autoFocus:!0,value:i,maxLength:80,placeholder:o(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(L,{variant:`danger`,onClick:n,children:o(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,disabled:!i.trim(),children:o(e?`settings.save`:`project.add`)})]})]})})}function ln({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=tt(e,n),[s,c]=ot(`assets`,`cards`),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null),C=Ue({assetSections:m},i),w=t.files.filter(e=>e.kind===`asset`),ee=new Map(w.map(e=>[e.id,e])),T=new Set(m.flatMap(e=>e.assets)),E=m.find(e=>e.id===g)??null,D=E?E.assets.map(e=>ee.get(e)).filter(e=>!!e):w.filter(e=>!T.has(e.id)),O=w.find(e=>e.id===d),k=l.trim().toLowerCase(),te=k?D.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(k)):D,j=(e,t)=>h(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),M=async e=>{let t=E?.id??null;for(let n of await a.upload(`asset`,e))j(n.id,t)},N=e=>{confirm(o(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),j(e.id,null))},P=m.length?{options:[{value:``,label:o(`project.assetsGeneral`)},...m.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],current:e=>m.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>j(e.id,t||null)}:void 0,F=[{label:o(`project.assetUpload`),icon:(0,$.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>S.current?.click()},{label:o(`project.assetFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>x(!0)},...m.length<X.logoSections?[{label:o(`project.assetSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>y(`new`)}]:[]],I=m.length||w.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[m.length?(0,$.jsx)(ne,{value:g,onChange:e=>{_(e),u(``)},label:o(`project.assets`),options:[{id:``,label:o(`project.assetsGeneral`)},...m.map(e=>({id:e.id,label:e.title||o(`project.sectionUntitled`)}))]}):null,E&&!n?(0,$.jsx)(A,{label:o(`project.assetSectionRename`),onClick:()=>y(`current`),children:(0,$.jsx)(f,{className:`size-4`})}):null]}),D.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(Te,{value:l,onChange:u,placeholder:o(`project.assetSearch`)})}),(0,$.jsx)(A,{label:o(s===`list`?`project.viewCards`:`project.viewList`),onClick:c,children:s===`list`?(0,$.jsx)(It,{className:`size-4`}):(0,$.jsx)(Bt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(Y,{title:o(`project.assets`),hint:o(`project.assetsHint`),save:C,tabs:I,action:n?null:(0,$.jsx)(q,{entries:F}),children:[(0,$.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:rn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&M(t)}}),te.length?s===`cards`?(0,$.jsx)(Yt,{projectId:e,kind:`asset`,files:te,actions:a,moveTo:P,onRemove:N,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,$.jsx)(sn,{projectId:e,file:t,actions:a,moveTo:P,onPreview:()=>p(t.id),onRemove:()=>N(t)},t.id))}):D.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.staysLocal`)}):(0,$.jsxs)(je,{accept:rn,onFiles:e=>void M(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(R,{className:`size-4`}):(0,$.jsx)(G,{className:`size-4`}),o(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:o(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,O?(0,$.jsx)(on,{projectId:e,file:O,actions:a,onClose:()=>p(null)}):null,v?(0,$.jsx)(cn,{section:v===`current`?E:null,onClose:()=>y(null),onSave:e=>{if(v===`current`&&E)h(t=>t.map(t=>t.id===E.id?{...t,title:e}:t));else{let t=K();h(n=>[...n,{id:t,title:e,assets:[]}]),_(t)}},onRemove:v===`current`&&E?()=>{(!E.assets.length||confirm(o(`project.assetSectionRemoveConfirm`,{name:E.title})))&&(h(e=>e.filter(e=>e.id!==E.id)),_(``),y(null))}:void 0}):null,b?(0,$.jsx)(Xt,{kind:`asset`,onClose:()=>x(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)j(t.id,E?.id??null)}}):null]})}var un=/^#[0-9a-fA-F]{6}$/;async function dn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var fn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function pn({gradient:e,brand:t,onSave:n,onClose:r}){let[i,a]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(Ke(e)),[l,d]=(0,Q.useState)(!1),f=e=>{a(e),c(Ke(e)),d(!1)},p=(e,t)=>f({...i,stops:i.stops.map((n,r)=>r===e?{...n,...t}:n)}),m=e=>{let t=[...i.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));f({...i,stops:[...i.stops,{color:e??t[0]?.color??`#888888`,at:n}]})};return(0,$.jsx)(P,{open:!0,onClose:r,wide:!0,title:o(`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:Ke(i)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-48 flex-1`,children:[(0,$.jsx)(w,{children:o(`project.gradientName`)}),(0,$.jsx)(k,{value:i.name,maxLength:80,placeholder:o(`project.gradientNamePlaceholder`),onChange:e=>a({...i,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:Ie.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":i.type===e,onClick:()=>f({...i,type:e}),className:u(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,i.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:o(fn[e])},e))})]}),i.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(w,{children:o(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:i.angle,"aria-label":o(`project.gradientAngle`),onChange:e=>f({...i,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(i.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(v,{value:un.test(e.color)?e.color:`#888888`,onChange:e=>p(t,{color:e.target.value})}),(0,$.jsx)(k,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();un.test(n)&&p(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":o(`project.gradientAt`),onChange:e=>p(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(A,{label:o(`project.remove`),disabled:i.stops.length<=2,onClick:()=>f({...i,stops:i.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[i.stops.length<12?(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>m(),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.gradientStopAdd`)]}):null,t.length&&i.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:o(`project.gradientFromBrand`)}),t.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>m(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:`CSS`}),(0,$.jsx)(k,{value:s,spellCheck:!1,onChange:e=>{c(e.target.value);let t=et(e.target.value);d(!t),t&&a({...i,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:u(`mt-1.5 text-[0.8125rem]`,l?`text-rose`:`text-ink-3`),children:o(l?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{onClick:()=>{n(i),r()},children:o(`settings.save`)})]})]})})}var mn=`flex shrink-0 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`;function hn({gradient:e,readOnly:t,onEdit:n,onRename:r,onRemove:i}){let a=Ke(e),[s,c]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":o(`project.gradientEdit`),onClick:n,className:`h-28 rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-0.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,$.jsx)(`span`,{className:`text-[0.875rem]`,children:e.name}):(0,$.jsx)(ft,{value:e.name,label:o(`project.gradientName`),placeholder:o(`project.gradientName`),maxLength:80,onChange:r,className:`font-medium text-[0.875rem]`})}),(0,$.jsxs)(`div`,{className:mn,children:[(0,$.jsx)(A,{label:o(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),c(!0),setTimeout(()=>c(!1),1500)},className:`size-8`,children:(0,$.jsx)(M,{className:`size-4`})}),(0,$.jsx)(A,{label:o(`project.download`),onClick:()=>void dn(e,e.name),className:`size-8`,children:(0,$.jsx)(D,{className:`size-4`})}),t?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:i,className:`size-8 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})]})}function gn({projectId:e,pattern:t,fileName:n,readOnly:r,onChange:i,onRemove:a}){let s=Xe(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`div`,{className:`h-28 rounded-md ring-1 ring-border-soft`,style:{backgroundImage:`url("${s}")`,backgroundSize:t.tile?`64px`:`cover`,backgroundRepeat:t.tile?`repeat`:`no-repeat`,backgroundPosition:`center`}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-0.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:r?(0,$.jsx)(`span`,{className:`text-[0.875rem]`,children:t.name||n}):(0,$.jsx)(ft,{value:t.name,label:o(`project.patternName`),placeholder:n,maxLength:80,onChange:e=>i({name:e}),className:`font-medium text-[0.875rem]`})}),(0,$.jsxs)(`div`,{className:mn,children:[r?null:(0,$.jsx)(A,{label:t.tile?o(`project.patternFill`):o(`project.patternTile`),"aria-pressed":!!t.tile,onClick:()=>i({tile:!t.tile}),className:u(`size-8`,t.tile&&`bg-paper-2 text-ink`),children:(0,$.jsx)(Mt,{className:`size-4`})}),(0,$.jsx)(`a`,{href:s,download:n,"aria-label":o(`project.download`),title:o(`project.download`),className:`inline-flex size-8 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(D,{className:`size-4`})}),r?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`size-8 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})]})}var _n=/^#[0-9a-fA-F]{6}$/;function vn({sections:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(`#e0531b`),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),u=_n.test(r);return(0,$.jsx)(P,{open:!0,onClose:n,title:o(`project.colorAddTitle`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u&&(t({name:a.trim(),value:r.toLowerCase(),...c?{section:c}:{}}),n())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(v,{value:u?r:`#888888`,onChange:e=>i(e.target.value)}),(0,$.jsx)(k,{value:r,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>i(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorUseLabel`)}),(0,$.jsx)(k,{autoFocus:!0,value:a,maxLength:120,placeholder:o(`project.colorName`),onChange:e=>s(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorUse`)})]}),e.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorSectionLabel`)}),(0,$.jsx)(T,{value:c,onChange:l,options:[{value:``,label:o(`project.sectionStandard`)},...e.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))]})]}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,disabled:!u,children:o(`project.add`)})]})]})})}function yn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{colors:t}=await I.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):l(o(`project.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(P,{open:!0,onClose:n,wide:d?!0:void 0,title:o(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:u(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>f(null),children:o(`run.back`)}),(0,$.jsx)(L,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?o(`project.addMany`,{n:p.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:a,disabled:!r.trim(),children:o(`run.next`)})]})]})})}function bn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:s,save:c,readOnly:l}){let[u,d]=(0,Q.useState)(()=>n.map(e=>({...e,id:K()}))),[f,p]=(0,Q.useState)(r),[m,g]=(0,Q.useState)(i),[_,y]=(0,Q.useState)(a),[x,S]=(0,Q.useState)(null),C=tt(e,l),w=De(s),[ee,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=Ue({colors:u.filter(e=>_n.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:f,gradients:m,patterns:_,colorRules:w.rules},c),P=f.filter(e=>(e.kind??`colors`)===`colors`),F=e=>P.some(t=>t.id===e.section),I=u.filter(e=>!F(e)),L=(I[0]??u[0])?.id,ne=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,...t}:n)),re=e=>d(t=>[...t,...e.map(e=>({...e,id:K()}))].slice(0,X.colors)),ie=[{value:``,label:o(`project.sectionStandard`)},...P.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],ae=(e,t)=>{let n=K();T(n),p(r=>[...r,{id:n,title:t,description:``,...e===`colors`?{}:{kind:e}}])},oe=e=>({id:K(),name:``,section:e,type:`linear`,angle:90,stops:[{color:u[0]?.value&&_n.test(u[0].value)?u[0].value:`#4b73ff`,at:0},{color:u[1]?.value&&_n.test(u[1].value)?u[1].value:`#ff6d1b`,at:100}]}),z=async(e,t)=>{let n=await C.upload(`pattern`,t);y(t=>[...t,...n.map(t=>({id:K(),name:t.name.replace(/\.[^.]+$/,``),section:e,file:t.id}))])},se=[...u.length<X.colors?[{label:o(`project.colorNew`),icon:(0,$.jsx)(b,{className:`size-4 shrink-0`}),onPick:()=>D(!0)},{label:o(`project.colorsFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...f.length<X.logoSections?[{label:o(`project.colorSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>ae(`colors`,``)},{label:o(`project.gradientSectionAdd`),icon:(0,$.jsx)(wt,{className:`size-4 shrink-0`}),onPick:()=>ae(`gradients`,o(`project.gradientSectionTitle`))},{label:o(`project.patternSectionAdd`),icon:(0,$.jsx)(Mt,{className:`size-4 shrink-0`}),onPick:()=>ae(`patterns`,o(`project.patternSectionTitle`))}]:[],...w.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>w.add()}]],ce=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(v,{value:_n.test(e.value)?e.value:`#888888`,onChange:t=>ne(e.id,{value:t.target.value})}),(0,$.jsx)(k,{value:e.name,placeholder:o(`project.colorName`),maxLength:120,onChange:t=>ne(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(k,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>ne(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===L?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(O,{tone:`ember`,children:o(`project.colorAccent`)})}):l?null:(0,$.jsx)(A,{label:o(`project.colorFirst`),onClick:()=>d(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,$.jsx)(te,{className:`size-4`})}),l||!f.length?null:(0,$.jsx)(we,{options:ie,value:F(e)?e.section??``:``,onChange:t=>ne(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),l?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>d(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]},e.id);return(0,$.jsxs)(Y,{title:o(`project.colors`),hint:o(`project.colorsHint`),save:N,locked:l,action:l?null:(0,$.jsx)(q,{entries:se}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[I.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:I.map(ce)}),l?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorUse`)})]}):u.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.colorsEmpty`)}),f.map(n=>{let r=n.kind??`colors`,i=u.filter(e=>e.section===n.id),a=m.filter(e=>e.section===n.id),s=_.filter(e=>e.section===n.id),c=r===`gradients`?a.length:r===`patterns`?s.length:i.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(Pe,{title:n.title,description:n.description,titlePlaceholder:o(r===`gradients`?`project.gradientSectionTitlePlaceholder`:r===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),descriptionPlaceholder:o(`project.colorSectionUse`),autoFocus:ee===n.id,readOnly:l,onChange:e=>p(t=>t.map(t=>t.id===n.id?{...t,...e}:t)),onRemove:()=>{if(!c||confirm(o(r===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:n.title||o(`project.sectionUntitled`)}))){p(e=>e.filter(e=>e.id!==n.id)),d(e=>e.map(e=>e.section===n.id?{...e,section:void 0}:e)),g(e=>e.filter(e=>e.section!==n.id));for(let e of s)C.remove(e.file);y(e=>e.filter(e=>e.section!==n.id))}}}),r===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,$.jsx)(hn,{gradient:e,readOnly:l,onEdit:()=>S(e),onRename:t=>g(n=>n.map(n=>n.id===e.id?{...n,name:t}:n)),onRemove:()=>g(t=>t.filter(t=>t.id!==e.id))},e.id)),l||m.length>=X.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(oe(n.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,$.jsx)(b,{className:`size-5`}),o(`project.gradientAdd`)]})]}):r===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[s.map(n=>(0,$.jsx)(gn,{projectId:e,pattern:n,fileName:t.files.find(e=>e.id===n.file)?.name??`pattern`,readOnly:l,onChange:e=>y(t=>t.map(t=>t.id===n.id?{...t,...e}:t)),onRemove:()=>{C.remove(n.file),y(e=>e.filter(e=>e.id!==n.id))}},n.id)),l?null:(0,$.jsxs)(je,{accept:`image/*`,onFiles:e=>void z(n.id,e),className:`min-h-28 flex-col p-3`,children:[C.busy?(0,$.jsx)(R,{className:`size-5`}):(0,$.jsx)(b,{className:`size-5`}),o(`project.patternAdd`)]})]}):i.length?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(ce)}):null]},n.id)}),(0,$.jsx)(Me,{rules:w,placeholder:o(`project.colorRulePlaceholder`),readOnly:l})]}),C.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:C.error}):null,E?(0,$.jsx)(vn,{sections:P,onClose:()=>D(!1),onAdd:e=>re([e])}):null,x?(0,$.jsx)(pn,{gradient:x,brand:u.filter(e=>_n.test(e.value)),onClose:()=>S(null),onSave:e=>g(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,$.jsx)(yn,{projectId:e,onClose:()=>M(!1),onAdd:re}):null]})}var xn=e=>/^(ja|yes|true)$/i.test(e.trim()),Sn={text:Fe,longtext:be,number:z,date:H,url:x,email:Ye,phone:W,boolean:U};function Cn({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Sn[e??t],d=`${o(`project.factType`)}: ${o(`project.type.${e??t}`)}`,f=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,p=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":d,title:d,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:u(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:u(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:f,onClick:()=>p(void 0),children:[(0,$.jsx)(Ne,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:o(`project.type.${t}`)}),(0,$.jsx)(F,{className:u(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Sn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:f,onClick:()=>p(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`project.type.${t}`)}),(0,$.jsx)(F,{className:u(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function wn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,s]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),l=Ue(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),u=(e,t)=>s(n=>n.map(n=>n.id===e?{...n,...t}:n)),d=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};s(e=>n?[o,...e]:[...e,o])},f=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},p=rt.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(Y,{title:o(`project.facts`),hint:o(`project.factsHint`),save:l,locked:n,action:a.length<X.facts&&!n?(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>d({},`label`,!0),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ae(e.value),r=e.type??t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,$.jsx)(k,{ref:f(`${e.id}:label`),value:e.label,placeholder:o(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>u(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&u(e.id,{key:Se(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(c,{checked:xn(e.value),label:e.label,onChange:t=>u(e.id,{value:o(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:xn(e.value)?o(`project.yes`):o(`project.no`)})]}):(0,$.jsx)(y,{ref:f(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:o(`project.factValue`),onChange:t=>u(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Cn,{type:e.type,detected:t,onChange:t=>u(e.id,{type:t})}),n?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>s(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]},e.id)})}),a.length<X.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>d({},`label`),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.factAdd`)]}),p.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d({key:e.key,label:m===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(b,{className:`size-3.5`}),` `,m===`en`?e.en:e.de]},e.key))]}):null]})}function Tn({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(Jt);i(!1),n&&(t.preventDefault(),e(n))},className:u(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function En({projectId:e,data:t,readOnly:n,sections:r,rules:i,save:a}){let s=tt(e,n),[c,l]=(0,Q.useState)(r),u=De(i),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=Ue({logoSections:c,logoRules:u.rules},a),_=t.files.filter(e=>e.kind===`logo`),v=new Map(_.map(e=>[e.id,e])),y=new Set(c.flatMap(e=>e.logos)),b=_.filter(e=>!y.has(e.id)),x=st(_,c)?.id,S=(e,t)=>l(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),C=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=async(e,t)=>{let n=await s.upload(`logo`,e);for(let e of n)S(e.id,t)},ee=c.length?{options:[{value:``,label:o(`project.sectionStandard`)},...c.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],current:e=>c.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>S(e.id,t||null)}:void 0,T=(t,n,r)=>(0,$.jsx)(Yt,{projectId:e,kind:`logo`,files:t,actions:s,accept:`image/*`,addLabel:r?o(`project.logoAdd`):void 0,onUpload:e=>void w(e,n),mainId:x,onMakeMain:e=>{S(e.id,null),s.order(`logo`,[e.id,..._.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:e=>{confirm(o(`project.removeConfirm`,{name:e.name}))&&(s.remove(e.id),S(e.id,null))}}),E=n?void 0:e=>t=>S(t,e),D=[{label:o(`project.logoUpload`),icon:(0,$.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>h.current?.click()},{label:o(`project.logoFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>m(!0)},...c.length<X.logoSections?[{label:o(`project.logoSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>{let e=K();f(e),l(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...u.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>u.add()}]];return(0,$.jsxs)(Y,{title:o(`project.logos`),hint:o(`project.logosHint`),save:g,action:n?null:(0,$.jsx)(q,{entries:D}),children:[(0,$.jsx)(`input`,{ref:h,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&w(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(Tn,{onLogo:E?.(null),children:T(b,null,!0)}),c.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Tn,{onLogo:E?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(Pe,{title:e.title,description:e.description,titlePlaceholder:o(`project.logoSectionTitle`),descriptionPlaceholder:o(`project.logoSectionUse`),autoFocus:d===e.id,readOnly:n,onChange:t=>C(e.id,t),onRemove:()=>{(!e.logos.length||confirm(o(`project.logoSectionRemoveConfirm`,{name:e.title||o(`project.sectionUntitled`)})))&&l(t=>t.filter(t=>t.id!==e.id))}}),T(e.logos.map(e=>v.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),(0,$.jsx)(Me,{rules:u,placeholder:o(`project.logoRulePlaceholder`),readOnly:n})]}),s.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error}):null,p?(0,$.jsx)(Xt,{kind:`logo`,onClose:()=>m(!1),fetchUrl:e=>s.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)S(t.id,null)}}):null]})}var Dn=new Set;function On(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Dn.has(t))return;Dn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Re.join(`,`)}&display=swap`,document.head.append(n)},[e])}var kn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function An({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var jn=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`;function Mn({font:e,first:t,readOnly:n,autoFocus:r,onChange:i,onRemove:a}){return On(e.family),(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:kn(e.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ft,{value:e.family,label:o(`project.fontFamily`),placeholder:o(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>i({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(ft,{value:e.role,label:o(`project.fontRole`),placeholder:o(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>i({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Re.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>i({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:kn(e.family),fontWeight:t},className:u(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),n?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})}function Nn({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:kn(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,$.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(ft,{value:e.name,label:o(`project.styleName`),placeholder:o(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":o(`project.styleFont`),value:c?.id??``,onChange:e=>a({font:e.target.value}),className:u(jn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||o(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":o(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:jn,children:[...new Set([...Re,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(An,{unit:`px`,label:o(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(An,{unit:o(`project.styleLine`),label:o(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(An,{unit:o(`project.styleTracking`),label:o(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:o(`project.styleUpper`),"aria-label":o(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:u(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,$.jsx)(Ot,{className:`size-4`})})]}),r?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})}function Pn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{fonts:t}=await I.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(o(`project.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(P,{open:!0,onClose:n,wide:u?!0:void 0,title:o(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(Fn,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>d(null),children:o(`run.back`)}),(0,$.jsx)(L,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?o(`project.addMany`,{n:f.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.fontsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:a,disabled:!r.trim(),children:o(`run.next`)})]})]})})}function Fn({font:e,on:t,onToggle:n}){return On(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:u(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:kn(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):o(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]})}function In({projectId:e,fonts:t,styles:n,rules:r,sample:i,save:a,readOnly:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=De(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=Ue({fonts:c,textStyles:u,typeRules:f.rules},a),v=(e,t=!1)=>{let n=e.map(e=>({id:K(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,X.fonts))},y=()=>{let e=K();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...c.length<X.fonts?[{label:o(`project.fontNew`),icon:(0,$.jsx)(b,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:o(`project.fontsFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<X.textStyles?[{label:o(`project.styleNew`),icon:(0,$.jsx)(Le,{className:`size-4 shrink-0`}),onPick:y}]:[],...f.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(Y,{title:o(`project.typography`),hint:o(`project.typographyHint`),save:_,action:s?null:(0,$.jsx)(q,{entries:x}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((e,t)=>(0,$.jsx)(Mn,{font:e,first:t===0,readOnly:s,autoFocus:p===e.id,onChange:t=>l(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>l(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:o(`project.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:o(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(Nn,{style:e,fonts:c,sample:i,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,(0,$.jsx)(Me,{rules:f,placeholder:o(`project.typeRulePlaceholder`),readOnly:s})]}),h?(0,$.jsx)(Pn,{projectId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}function Ln({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),s=Ue({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(Y,{title:o(`project.base`),hint:o(`project.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.title`)}),(0,$.jsx)(k,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.about`)}),(0,$.jsx)(y,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.aboutHint`)})]})]})})}function Rn({project:e,group:t,children:n}){let i=r(),a=We(e.id),[s,c]=(0,Q.useState)(0),l=async t=>{await I.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},u=dt({mutationFn:()=>I.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),d=Ce(),f=Ze(),p=a.data??{files:[],embeddings:!0},m=`${e.id}:${s}`,h=e.readOnly,g=t===`knowledge`;return $e(h?{}:{title:o(g?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:o(g?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:o(g?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:g?[{label:o(`assistant.suggest.knowledgeHow`)},{label:o(`assistant.suggest.knowledgeSite`),fill:!0},{label:o(`assistant.suggest.knowledgeCategories`)}]:[{label:o(`assistant.suggest.readSite`),fill:!0},{label:o(`assistant.suggest.missing`)},{label:o(`assistant.suggest.facts`)}],summary:g?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${p.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>c(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[h?(0,$.jsx)(xe,{children:ye(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{id:`base`,children:(0,$.jsx)(Ln,{project:e,save:l},`base:${m}`)}),(0,$.jsx)(J,{id:`facts`,children:(0,$.jsx)(wn,{facts:e.facts,save:e=>l({facts:e}),readOnly:h},`facts:${m}`)}),(0,$.jsx)(J,{id:`logos`,children:(0,$.jsx)(En,{projectId:e.id,data:p,readOnly:h,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],save:e=>l({brand:e})},`logos:${m}`)}),(0,$.jsx)(J,{id:`colors`,children:(0,$.jsx)(bn,{projectId:e.id,data:p,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],save:e=>l({brand:e}),readOnly:h},`colors:${m}`)}),(0,$.jsx)(J,{id:`typography`,children:(0,$.jsx)(In,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],sample:e.brand.name||o(`project.typeSample`),save:e=>l({brand:e}),readOnly:h},`typography:${m}`)}),(0,$.jsx)(J,{id:`assets`,children:(0,$.jsx)(ln,{projectId:e.id,data:p,readOnly:h,sections:e.brand.assetSections??[],save:e=>l({brand:e})},`assets:${m}`)})]}):null,n,t===`info`&&d&&!h&&f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(L,{variant:`danger`,busy:u.isPending,onClick:()=>confirm(`${o(`settings.delete`)}?`)&&u.mutate(),children:o(`settings.delete`)}),u.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:u.error.message}):null]}):null]})}var zn={q:``,mode:``,days:0};function Bn(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let a=r.toString();return i({queryKey:[`results`,e,a],queryFn:()=>I.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Vn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(ze,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(k,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:o(`space.resultsSearch`),"aria-label":o(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(T,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:o(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(T,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:o(`space.resultsAnyTime`)},{value:`1`,label:o(`space.resultsDay`)},{value:`7`,label:o(`space.resultsDays`,{n:7})},{value:`30`,label:o(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Hn({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(m,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{title:t?s(t):o(`space.resultsAll`),hint:o(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Vn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(E,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,o(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:o(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(d,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(O,{children:`Test`}):(0,$.jsxs)(O,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(E,{children:(0,$.jsx)(j,{children:n.q.trim()||n.mode||n.days?o(`space.resultsNone`):o(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(V,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(i.wizardId)}),i.mode===`test`?(0,$.jsx)(O,{children:`Test`}):(0,$.jsxs)(O,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(St,{runId:i.id,compact:!0},i.id)}):null]})}function Un({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),s=dt({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{label:o(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(f,{className:`size-4`})}),(0,$.jsx)(P,{open:n,onClose:()=>r(!1),title:o(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&s.mutate()},children:[(0,$.jsx)(k,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),s.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>r(!1),children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:s.isPending,disabled:!i.trim(),children:o(`settings.save`)})]})]})})]})}function Wn({project:e}){let t=r();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ut,{}),e.readOnly?null:(0,$.jsx)(Un,{project:e,save:async n=>{await I.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Gn(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Je(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Kn(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function qn({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Z,{icon:e.icon??Be,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(ht,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Jn(){let{group:e}=_(),[t,n]=s(),r=re(),i=ee(),{hash:a}=i,{project:c,loading:l}=ke(),d=Ce(),f=Qe(),p=xt(),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),x=Ge(e)?e:void 0,S=i.state?.parts===!0,w=nt().map(e=>({...e,to:`/space/${e.id}`})),T=w.find(e=>e.id===x),E=t.get(`show`),D=x?E?2:1:0,O=p?Math.min(D,1):x&&y!==x&&!S?1:0,k=mt(O),A=mt(D),te=(0,Q.useMemo)(()=>({slot:m,narrow:p,setDetail:v}),[m,p]),M=c?c.brand.name?.trim()||c.name:o(`nav.project`),N=x&&x!==`results`?qe(x,f):[],P=x?qe(x,f).filter(e=>e.plugin):[],F=Gn([...N,...x===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=x===`results`&&E&&E!==`all`?E:null,[L,ne]=(0,Q.useState)(zn),R=Bn(x===`results`?c?.id:void 0,I,L),ie=R.data?.wizards.find(e=>e.id===I)?.title,z=x===`data`&&E&&E!==`all`||x===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,B=z?.startsWith(`s:`)?f.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=x===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,H=se(x===`data`?c?.id:void 0),U=pe(x===`knowledge`?c?.id:void 0),W=ve(z?.startsWith(`v:`)?z.slice(2):``),ye=U.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):W.data?.category.id)),be=x===`knowledge`?B?B.label():z?.startsWith(`v:`)?W.data&&`${W.data.category.name}: ${W.data.value}`:z?.startsWith(`c:`)?ye?.name:U.data?.items.find(e=>e.key===z)?.title:H.data?ge(H.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;Ve([{label:o(`nav.project`),to:`/space`},...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(g??ie??be)?[{label:g??ie??be}]:[]]);let xe={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};$e({...x===`data`||x===`results`?{compact:!0}:{},...x===`data`?{suggestions:[{label:o(`assistant.suggest.dataWhat`)},{label:o(`assistant.suggest.dataWho`)},{label:o(`assistant.suggest.dataEdit`)}]}:x===`results`?{suggestions:[{label:o(`assistant.suggest.resultsFailed`)},{label:o(`assistant.suggest.resultsCost`)},{label:o(`assistant.suggest.resultsShare`)}]}:{},...z&&be?{open:{kind:xe[z[0]]??`item`,id:z.slice(2),label:be}}:I&&ie?{open:{kind:`wizard`,id:I,label:ie}}:{}});let G=x===`results`||x===`data`||z?a.slice(1):E||a.slice(1),Se=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${x}#${G}`;G&&Se.current!==e&&document.getElementById(G)&&(Se.current=e,requestAnimationFrame(()=>Kn(G,!1)))},[x,G,c?.id,f.spaceSections]),!x){let t=a.slice(1),n=t?ct(t,f):null;if(n===`knowledge`&&f.spaceSections.some(e=>e.id===t))return(0,$.jsx)(C,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(C,{to:p?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&f.status!==`ready`)return null;if(e!==void 0||!p)return(0,$.jsx)(C,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(x===`knowledge`&&!E&&f.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(C,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let we=e=>{if(p){r({search:`?show=${e}`});return}Se.current=`${x}#${e}`,Kn(e,!0),r({search:``,hash:e},{replace:!0})},K=e=>p?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Te=e=>e.flatMap(e=>e.sections).map(e=>f.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(J,{id:e.id,children:(0,$.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(at,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),q=p?void 0:F;return(0,$.jsx)(_t.Provider,{value:te,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:u(`min-w-0 md:sticky md:top-6 md:self-start`,p&&D===2&&`hidden`,p&&A===`back`&&pt(`back`)),children:[(0,$.jsx)(gt,{title:M,open:O===1?T??null:null,onBack:()=>p?r(`/space`):b(x??null)}),(0,$.jsx)(`div`,{className:u(pt(k)),children:O===0?(0,$.jsx)(vt,{entries:w,current:p?void 0:T,onPick:()=>b(null)}):(0,$.jsx)(`div`,{ref:h})},O)]}),x?(0,$.jsxs)(`div`,{className:u(`min-w-0`,p&&D<2&&`hidden`,p&&A===`deeper`&&pt(`deeper`)),children:[p?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(bt,{label:T?.label??M,onBack:()=>r(`/space/${x}`)})}):null,d&&c?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Wn,{project:c})}):null,x===`results`?(0,$.jsxs)(yt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Z,{icon:Pt,label:o(`space.resultsAll`),selected:!p&&!I,onPick:()=>K(`all`)}),R.data?.wizards.filter(e=>e.results||e.id===I).map(e=>(0,$.jsx)(Z,{icon:Ne,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!p&&e.id===I,onPick:()=>K(e.id)},e.id))]}),(0,$.jsx)(qn,{groups:P,current:q,onPick:we})]}):x===`data`?(0,$.jsxs)(yt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:It,label:o(`data.all`),selected:!p&&!z,onPick:()=>K(`all`)})}),H.data?ge(H.data).map(e=>(0,$.jsx)(ht,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Z,{icon:oe[e.kind],label:e.title,selected:!p&&e.key===z,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,$.jsx)(qn,{groups:P,current:q,onPick:we})]}):x===`knowledge`?(0,$.jsxs)(yt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:It,label:o(`know.all`),selected:!(p||z),onPick:()=>K(`all`)})}),U.data?.categories.length?(0,$.jsx)(ht,{label:o(`know.categories`),children:U.data.categories.map(e=>(0,$.jsx)(Z,{icon:ue[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!p&&(z===`c:${e.id}`||W.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(qn,{groups:P,current:p?void 0:B?.id,onPick:e=>K(`s:${e}`)})]}):(0,$.jsx)(yt,{children:(0,$.jsx)(qn,{groups:N,current:q,onPick:we})}),c&&(x===`info`||x===`knowledge`)?(0,$.jsxs)(Rn,{project:c,group:x,children:[x===`knowledge`?V?V.startsWith(`p:`)?(0,$.jsx)(fe,{pageId:V.slice(2),onGone:()=>K(`all`),onOpen:K},V):V.startsWith(`t:`)?(0,$.jsx)(de,{tableId:V.slice(2),onGone:()=>K(`all`)},V):(0,$.jsx)(tn,{projectId:c.id,fileId:V.slice(2),readOnly:c.readOnly,onGone:()=>K(`all`)},V):U.data?B?(0,$.jsx)(Y,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(at,{of:B,children:(0,$.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?ye?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(le,{projectId:c.id,category:ye,readOnly:c.readOnly,onOpen:K,onGone:()=>K(`all`)}),ye.type===`choice`?null:(0,$.jsx)(_e,{projectId:c.id,category:ye,categories:U.data.categories,onOpen:K})]},z):null:z?.startsWith(`v:`)?W.data?(0,$.jsx)(ae,{value:W.data,readOnly:c.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[W.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:W.data.items.map(e=>(0,$.jsx)(ce,{item:e,categories:U.data.categories.filter(e=>e.id!==W.data?.category.id),onOpen:K},e.key))}):null,W.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:o(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(J,{id:`documents`,children:(0,$.jsx)(he,{projectId:c.id,data:U.data,readOnly:c.readOnly,onOpen:K})}):null:null,x===`info`?Te(P):null]},c.id):null,c&&x===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(de,{tableId:z.slice(2),onGone:()=>K(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(fe,{pageId:z.slice(2),onGone:()=>K(`all`)},z):(0,$.jsxs)($.Fragment,{children:[H.data?(0,$.jsx)(me,{projectId:c.id,data:H.data,readOnly:c.readOnly,onOpen:K}):null,Te(P)]})}):null,c&&x===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,$.jsx)(Hn,{data:R.data,wizardId:I,filter:L,onFilter:ne}):null,R.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,Te(P)]}):null,c||l?null:(0,$.jsx)(j,{children:o(`settings.noProject`)})]}):null]})})})}export{Jn as ProjectPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{O as r,r as i}from"./logo-C4V2_3Ar.js";import{$t as a,At as o,Cn as s,Ct as c,E as l,Et as u,Gt as d,Ht as f,Lt as p,Ot as m,Pt as h,Qt as g,Sn as _,St as v,Tt as y,Vt as b,Yt as x,Zt as S,_n as C,_t as w,bn as ee,bt as T,dt as E,en as D,ft as O,gt as k,ht as A,ln as te,mt as j,nn as M,pn as N,pt as P,sn as F,u as I,ut as L,wt as ne,xn as re,xt as R,zt as ie}from"./ui-D2SqIZeQ.js";import{_ as ae,a as oe,b as z,c as se,d as ce,f as B,g as le,h as ue,i as de,l as fe,m as pe,n as V,o as me,p as he,s as ge,u as _e,v as ve,x as H,y as U}from"./RunDrawer-D1I5xqVf.js";import{t as W}from"./phone-Bt1cyWpY.js";import{n as ye,r as be,t as xe}from"./ReadOnly-DTjv2Jzm.js";import{t as G}from"./upload-CCEq88l4.js";import{$ as Se,At as Ce,B as we,G as K,H as Te,I as q,J as Ee,K as De,Kt as Oe,L as J,Ot as ke,Q as Ae,R as je,U as Y,V as Me,Vt as Ne,W as Pe,Wt as Fe,X as Ie,Xt as Le,Y as Re,Yt as ze,Z as X,Zt as Be,_ as Ve,an as He,at as Ue,ct as We,d as Ge,et as Ke,f as qe,g as Je,in as Ye,it as Xe,kt as Ze,l as Qe,mt as $e,nt as et,ot as tt,p as nt,q as rt,rt as it,s as at,st as ot,tt as st,u as ct,un as lt,v as ut,vn as dt,z as ft}from"./index-BH0PYgov.js";import{a as Z,c as pt,f as mt,i as ht,n as gt,o as _t,r as vt,s as yt,t as bt,u as xt}from"./settings-menu-ace1vI3i.js";import{t as St}from"./RunnerView-BPPmlv9z.js";var Ct={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Ct.node;var wt=N(Ct),Tt={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};Tt.node;var Et=N(Tt),Dt={name:`case-upper`,size:24,node:[[`path`,{d:`M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5`,key:`nxs35`}],[`path`,{d:`m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16`,key:`d5nyq2`}],[`path`,{d:`M3.304 13h6.392`,key:`1q3zxz`}]]};Dt.node;var Ot=N(Dt),kt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};kt.node;var At=N(kt),jt={name:`grid-2x2`,size:24,node:[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]],aliases:[`grid-2-x-2`]};jt.node;var Mt=N(jt),Nt={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Nt.node;var Pt=N(Nt),Ft={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};Ft.node;var It=N(Ft),Lt={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};Lt.node;var Rt=N(Lt),zt={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};zt.node;var Bt=N(zt),Vt={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};Vt.node;var Ht=N(Vt),Q=e(t(),1),$=e(n(),1),Ut={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function Wt({file:e,actions:t}){let[n,r]=(0,Q.useState)(e.description),i=(0,Q.useRef)(e.description),a=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,Q.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let s=e.status===`pending`&&!n;return t.readOnly?n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-2 leading-snug`,children:n}):null:(0,$.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:o(s?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[0.8125rem] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function Gt(e,t){confirm(o(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Kt({projectId:e,file:t,small:n}){let r=Xe(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:u(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)});if(t.mime.startsWith(`video/`))return(0,$.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`});if(t.mime.startsWith(`font/`))return(0,$.jsx)(qt,{src:r,small:n});let i=n?`size-5`:`size-7`;return(0,$.jsxs)(`div`,{className:`flex size-full flex-col items-center justify-center gap-1.5 text-ink-3`,children:[t.mime.startsWith(`audio/`)?(0,$.jsx)(Ht,{className:i}):t.mime===`application/pdf`?(0,$.jsx)(g,{className:i}):t.mime===`application/json`?(0,$.jsx)(p,{className:i}):t.mime.startsWith(`model/`)?(0,$.jsx)(Et,{className:i}):(0,$.jsx)(S,{className:i}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function qt({src:e,small:t}){let[n,r]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{let t=`asset-${e.split(`/`).slice(-2,-1)[0]}`;new FontFace(t,`url("${e}")`).load().then(e=>{document.fonts.add(e),r(t)}).catch(()=>r(null))},[e]),(0,$.jsx)(`div`,{className:u(`flex size-full items-center justify-center text-ink`,t?`text-[1.25rem]`:`text-[2.75rem]`),style:n?{fontFamily:`"${n}"`}:void 0,children:`Aa`})}var Jt=`application/x-wizards-logo`;function Yt({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:s,onPreview:c,mainId:l,onMakeMain:u,moveTo:d,onRemove:f}){let p=e=>f?f(e):Gt(e,r);return(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map(n=>(0,$.jsxs)(`div`,{draggable:d&&!r.readOnly?!0:void 0,onDragStart:e=>e.dataTransfer.setData(Jt,n.id),className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[n.id===l?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(O,{tone:`ember`,children:o(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Ut:void 0,children:[c&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${o(`project.preview`)}: ${n.name}`,onClick:()=>c(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(Kt,{projectId:e,file:n})}):(0,$.jsx)(Kt,{projectId:e,file:n}),(0,$.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[c?(0,$.jsx)(A,{label:o(`project.preview`),onClick:()=>c(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(lt,{className:`size-4`})}):null,u&&n.id!==l&&!r.readOnly?(0,$.jsx)(A,{label:o(`project.logoMakeMain`),onClick:()=>u(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(Oe,{className:`size-4`})}):null,d&&!r.readOnly?(0,$.jsx)(we,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]}),t===`asset`?(0,$.jsx)(`div`,{className:`truncate px-0.5 text-[0.75rem] text-ink-3`,title:n.name,children:n.name}):null,(0,$.jsx)(Wt,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(je,{accept:i,multiple:!1,onFiles:e=>s?s(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(R,{className:`size-5`}):(0,$.jsx)(b,{className:`size-5`}),a]}):null]})}function Xt({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,a]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),g=async()=>{c(!0),d(null);try{let a=await t(i.trim());a.file?(n([a.file]),r()):a.candidates?.length?(p(a.candidates),h([a.candidates[0].url])):d(o(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){d(e.message)}c(!1)},_=async()=>{c(!0),d(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){d(e.message)}c(!1),e.length&&n(e),e.length===m.length&&r()};return(0,$.jsx)(P,{open:!0,onClose:r,wide:f?!0:void 0,title:o(f?e===`logo`?`project.logoFound`:`project.assetFound`:e===`logo`?`project.logoFromUrl`:`project.assetFromUrl`),children:f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(e===`logo`?`project.logoFoundHint`:`project.assetFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-3`,children:f.map(t=>{let n=m.includes(t.url);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,title:t.hint,onClick:()=>h(e=>n?e.filter(e=>e!==t.url):[...e,t.url]),className:u(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:Ut,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:u(`size-full`,e===`logo`?`object-contain p-3`:`object-cover`)}),n?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]},t.url)})}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>p(null),children:o(`run.back`)}),(0,$.jsx)(L,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?o(`project.addMany`,{n:m.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(e===`logo`?`project.logoUrlHint`:`project.assetUrlHint`)})]}),l?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:l}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:s,disabled:!i.trim(),children:o(`run.next`)})]})]})})}function Zt(e,t,n){return i({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>I.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function Qt(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var $t=e=>[Qt(e),e.pages?o(`project.pages`,{n:e.pages}):null,it(e.size)].filter(Boolean).join(` · `),en=2e5;function tn({projectId:e,fileId:t,readOnly:n,onGone:i}){let s=r(),c=We(e),l=pe(e),d=tt(e,n),f=c.data?.files.find(e=>e.id===t),p=f?f.mime===`application/pdf`||f.mime.startsWith(`image/`):!1,[m,g]=(0,Q.useState)(null);if(!f)return c.isLoading?(0,$.jsx)(R,{className:`mx-auto text-ink-3`}):null;let _=m??(p?`original`:`text`),v=l.data?.items.find(e=>e.key===`f:${f.id}`),y=Xe(e,f.id),b=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":_===e,onClick:()=>g(e),className:u(`rounded-full px-3 py-1 text-[0.8125rem] transition`,_===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,$.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate font-display font-semibold text-lg`,children:f.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:$t(f)}),(0,$.jsx)(`a`,{href:y,target:`_blank`,rel:`noreferrer`,"aria-label":o(`project.openOriginal`),title:o(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(a,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{label:o(`project.reindex`),onClick:async()=>{await d.reindex(f.id),await s.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(ie,{className:`size-4`})}),(0,$.jsx)(A,{label:o(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(o(`data.confirmDelete`,{title:f.name}))&&(await d.remove(f.id),await s.invalidateQueries({queryKey:[`knowledge`,e]}),i())},children:(0,$.jsx)(h,{className:`size-4`})})]})]}),(0,$.jsx)(B,{projectId:e,itemKey:`f:${f.id}`,has:v?.categories??[],originLabel:v?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(Wt,{file:f,actions:d})}),f.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:f.error}):null,(0,$.jsxs)(E,{className:`flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-border-soft border-b px-2 py-1.5`,children:[p?b(`original`,o(`project.original`)):null,b(`text`,o(`project.readText`))]}),_===`original`?f.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:y,title:f.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:y,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(nn,{projectId:e,file:f})]})]})}function nn({projectId:e,file:t}){let n=Zt(e,t,en);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(R,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(l,{text:n.data.text,className:`text-[0.875rem]`}),n.data.chars>n.data.text.length?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-ink-3`,children:o(`project.textCut`,{shown:n.data.text.length.toLocaleString(),total:n.data.chars.toLocaleString()})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:o(`project.noText`)})}var rn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,an=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),it(e.size)].filter(Boolean).join(` · `);function on({projectId:e,file:t,actions:n,onClose:r}){let i=Xe(e,t.id);return(0,$.jsxs)(P,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,$.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:an(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":o(`project.openOriginal`),title:o(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(a,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Ut,children:(0,$.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,$.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,$.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Wt,{file:t,actions:n})})]})}function sn({projectId:e,file:t,actions:n,moveTo:r,onPreview:i,onRemove:a}){return(0,$.jsxs)(`li`,{className:`group/row flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${o(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(Kt,{projectId:e,file:t,small:!0})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,title:t.name,className:`min-w-0 truncate font-medium text-[0.875rem] hover:underline`,children:t.name}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:an(t)})]}),(0,$.jsx)(Wt,{file:t,actions:n})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start opacity-0 transition focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:[(0,$.jsx)(A,{label:o(`project.preview`),onClick:i,children:(0,$.jsx)(lt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(we,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})}function cn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,a]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(P,{open:!0,onClose:r,title:o(e?`project.assetSectionRename`:`project.assetSectionAdd`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&(t(i.trim()),r())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.assetSectionName`)}),(0,$.jsx)(k,{autoFocus:!0,value:i,maxLength:80,placeholder:o(`project.assetSectionTitle`),onChange:e=>a(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(L,{variant:`danger`,onClick:n,children:o(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,disabled:!i.trim(),children:o(e?`settings.save`:`project.add`)})]})]})})}function ln({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=tt(e,n),[s,c]=ot(`assets`,`cards`),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(r),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(!1),S=(0,Q.useRef)(null),C=Ue({assetSections:m},i),w=t.files.filter(e=>e.kind===`asset`),ee=new Map(w.map(e=>[e.id,e])),T=new Set(m.flatMap(e=>e.assets)),E=m.find(e=>e.id===g)??null,D=E?E.assets.map(e=>ee.get(e)).filter(e=>!!e):w.filter(e=>!T.has(e.id)),O=w.find(e=>e.id===d),k=l.trim().toLowerCase(),te=k?D.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(k)):D,j=(e,t)=>h(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),M=async e=>{let t=E?.id??null;for(let n of await a.upload(`asset`,e))j(n.id,t)},N=e=>{confirm(o(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),j(e.id,null))},P=m.length?{options:[{value:``,label:o(`project.assetsGeneral`)},...m.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],current:e=>m.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>j(e.id,t||null)}:void 0,F=[{label:o(`project.assetUpload`),icon:(0,$.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>S.current?.click()},{label:o(`project.assetFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>x(!0)},...m.length<X.logoSections?[{label:o(`project.assetSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>y(`new`)}]:[]],I=m.length||w.length?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`-mx-1 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-1 pb-0.5`,children:[m.length?(0,$.jsx)(ne,{value:g,onChange:e=>{_(e),u(``)},label:o(`project.assets`),options:[{id:``,label:o(`project.assetsGeneral`)},...m.map(e=>({id:e.id,label:e.title||o(`project.sectionUntitled`)}))]}):null,E&&!n?(0,$.jsx)(A,{label:o(`project.assetSectionRename`),onClick:()=>y(`current`),children:(0,$.jsx)(f,{className:`size-4`})}):null]}),D.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(Te,{value:l,onChange:u,placeholder:o(`project.assetSearch`)})}),(0,$.jsx)(A,{label:o(s===`list`?`project.viewCards`:`project.viewList`),onClick:c,children:s===`list`?(0,$.jsx)(It,{className:`size-4`}):(0,$.jsx)(Bt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(Y,{title:o(`project.assets`),hint:o(`project.assetsHint`),save:C,tabs:I,action:n?null:(0,$.jsx)(q,{entries:F}),children:[(0,$.jsx)(`input`,{ref:S,type:`file`,multiple:!0,accept:rn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&M(t)}}),te.length?s===`cards`?(0,$.jsx)(Yt,{projectId:e,kind:`asset`,files:te,actions:a,moveTo:P,onRemove:N,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:te.map(t=>(0,$.jsx)(sn,{projectId:e,file:t,actions:a,moveTo:P,onPreview:()=>p(t.id),onRemove:()=>N(t)},t.id))}):D.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.staysLocal`)}):(0,$.jsxs)(je,{accept:rn,onFiles:e=>void M(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(R,{className:`size-4`}):(0,$.jsx)(G,{className:`size-4`}),o(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:o(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,O?(0,$.jsx)(on,{projectId:e,file:O,actions:a,onClose:()=>p(null)}):null,v?(0,$.jsx)(cn,{section:v===`current`?E:null,onClose:()=>y(null),onSave:e=>{if(v===`current`&&E)h(t=>t.map(t=>t.id===E.id?{...t,title:e}:t));else{let t=K();h(n=>[...n,{id:t,title:e,assets:[]}]),_(t)}},onRemove:v===`current`&&E?()=>{(!E.assets.length||confirm(o(`project.assetSectionRemoveConfirm`,{name:E.title})))&&(h(e=>e.filter(e=>e.id!==E.id)),_(``),y(null))}:void 0}):null,b?(0,$.jsx)(Xt,{kind:`asset`,onClose:()=>x(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)j(t.id,E?.id??null)}}):null]})}var un=/^#[0-9a-fA-F]{6}$/;async function dn(e,t){let[n,r]=[1920,1080],i=document.createElement(`canvas`);i.width=n,i.height=r;let a=i.getContext(`2d`);if(!a)return;let o=e.angle*Math.PI/180,s;if(e.type===`radial`)s=a.createRadialGradient(n/2,r/2,0,n/2,r/2,Math.hypot(n,r)/2);else if(e.type===`conic`)s=a.createConicGradient(o-Math.PI/2,n/2,r/2);else{let e=Math.abs(n*Math.sin(o))+Math.abs(r*Math.cos(o)),[t,i]=[Math.sin(o)*e/2,-Math.cos(o)*e/2];s=a.createLinearGradient(n/2-t,r/2-i,n/2+t,r/2+i)}for(let t of[...e.stops].sort((e,t)=>e.at-t.at))s.addColorStop(Math.min(1,Math.max(0,t.at/100)),t.color);a.fillStyle=s,a.fillRect(0,0,n,r);let c=await new Promise(e=>i.toBlob(e,`image/png`));if(c){let e=document.createElement(`a`);e.href=URL.createObjectURL(c),e.download=`${t||`gradient`}.png`,e.click(),setTimeout(()=>URL.revokeObjectURL(e.href),5e3)}}var fn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function pn({gradient:e,brand:t,onSave:n,onClose:r}){let[i,a]=(0,Q.useState)(e),[s,c]=(0,Q.useState)(Ke(e)),[l,d]=(0,Q.useState)(!1),f=e=>{a(e),c(Ke(e)),d(!1)},p=(e,t)=>f({...i,stops:i.stops.map((n,r)=>r===e?{...n,...t}:n)}),m=e=>{let t=[...i.stops].sort((e,t)=>e.at-t.at),n=50,r=-1;for(let e=0;e<t.length-1;e++)t[e+1].at-t[e].at>r&&(r=t[e+1].at-t[e].at,n=Math.round((t[e].at+t[e+1].at)/2));f({...i,stops:[...i.stops,{color:e??t[0]?.color??`#888888`,at:n}]})};return(0,$.jsx)(P,{open:!0,onClose:r,wide:!0,title:o(`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:Ke(i)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-48 flex-1`,children:[(0,$.jsx)(w,{children:o(`project.gradientName`)}),(0,$.jsx)(k,{value:i.name,maxLength:80,placeholder:o(`project.gradientNamePlaceholder`),onChange:e=>a({...i,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:Ie.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":i.type===e,onClick:()=>f({...i,type:e}),className:u(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,i.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:o(fn[e])},e))})]}),i.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(w,{children:o(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:i.angle,"aria-label":o(`project.gradientAngle`),onChange:e=>f({...i,angle:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-12 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(i.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(v,{value:un.test(e.color)?e.color:`#888888`,onChange:e=>p(t,{color:e.target.value})}),(0,$.jsx)(k,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();un.test(n)&&p(t,{color:n.toLowerCase()})},className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:100,value:e.at,"aria-label":o(`project.gradientAt`),onChange:e=>p(t,{at:Number(e.target.value)}),className:`flex-1 accent-ink`}),(0,$.jsxs)(`span`,{className:`w-10 text-right text-[0.875rem] text-ink-2 tabular-nums`,children:[Math.round(e.at),`%`]}),(0,$.jsx)(A,{label:o(`project.remove`),disabled:i.stops.length<=2,onClick:()=>f({...i,stops:i.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[i.stops.length<12?(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>m(),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.gradientStopAdd`)]}):null,t.length&&i.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:o(`project.gradientFromBrand`)}),t.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>m(e.value),className:`size-6 rounded-full ring-1 ring-border transition hover:scale-110`,style:{background:e.value}},e.value))]}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:`CSS`}),(0,$.jsx)(k,{value:s,spellCheck:!1,onChange:e=>{c(e.target.value);let t=et(e.target.value);d(!t),t&&a({...i,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:u(`mt-1.5 text-[0.8125rem]`,l?`text-rose`:`text-ink-3`),children:o(l?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:r,children:o(`common.cancel`)}),(0,$.jsx)(L,{onClick:()=>{n(i),r()},children:o(`settings.save`)})]})]})})}var mn=`flex shrink-0 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`;function hn({gradient:e,readOnly:t,onEdit:n,onRename:r,onRemove:i}){let a=Ke(e),[s,c]=(0,Q.useState)(!1);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":o(`project.gradientEdit`),onClick:n,className:`h-28 rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-0.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:t?(0,$.jsx)(`span`,{className:`text-[0.875rem]`,children:e.name}):(0,$.jsx)(ft,{value:e.name,label:o(`project.gradientName`),placeholder:o(`project.gradientName`),maxLength:80,onChange:r,className:`font-medium text-[0.875rem]`})}),(0,$.jsxs)(`div`,{className:mn,children:[(0,$.jsx)(A,{label:o(s?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),c(!0),setTimeout(()=>c(!1),1500)},className:`size-8`,children:(0,$.jsx)(M,{className:`size-4`})}),(0,$.jsx)(A,{label:o(`project.download`),onClick:()=>void dn(e,e.name),className:`size-8`,children:(0,$.jsx)(D,{className:`size-4`})}),t?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:i,className:`size-8 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})]})}function gn({projectId:e,pattern:t,fileName:n,readOnly:r,onChange:i,onRemove:a}){let s=Xe(e,t.file);return(0,$.jsxs)(`div`,{className:`group/card flex flex-col gap-2 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,$.jsx)(`div`,{className:`h-28 rounded-md ring-1 ring-border-soft`,style:{backgroundImage:`url("${s}")`,backgroundSize:t.tile?`64px`:`cover`,backgroundRepeat:t.tile?`repeat`:`no-repeat`,backgroundPosition:`center`}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-0.5`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:r?(0,$.jsx)(`span`,{className:`text-[0.875rem]`,children:t.name||n}):(0,$.jsx)(ft,{value:t.name,label:o(`project.patternName`),placeholder:n,maxLength:80,onChange:e=>i({name:e}),className:`font-medium text-[0.875rem]`})}),(0,$.jsxs)(`div`,{className:mn,children:[r?null:(0,$.jsx)(A,{label:t.tile?o(`project.patternFill`):o(`project.patternTile`),"aria-pressed":!!t.tile,onClick:()=>i({tile:!t.tile}),className:u(`size-8`,t.tile&&`bg-paper-2 text-ink`),children:(0,$.jsx)(Mt,{className:`size-4`})}),(0,$.jsx)(`a`,{href:s,download:n,"aria-label":o(`project.download`),title:o(`project.download`),className:`inline-flex size-8 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,$.jsx)(D,{className:`size-4`})}),r?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`size-8 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})]})}var _n=/^#[0-9a-fA-F]{6}$/;function vn({sections:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(`#e0531b`),[a,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),u=_n.test(r);return(0,$.jsx)(P,{open:!0,onClose:n,title:o(`project.colorAddTitle`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u&&(t({name:a.trim(),value:r.toLowerCase(),...c?{section:c}:{}}),n())},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorValue`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(v,{value:u?r:`#888888`,onChange:e=>i(e.target.value)}),(0,$.jsx)(k,{value:r,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>i(e.target.value.trim()),className:`font-mono text-[0.875rem]`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorUseLabel`)}),(0,$.jsx)(k,{autoFocus:!0,value:a,maxLength:120,placeholder:o(`project.colorName`),onChange:e=>s(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorUse`)})]}),e.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.colorSectionLabel`)}),(0,$.jsx)(T,{value:c,onChange:l,options:[{value:``,label:o(`project.sectionStandard`)},...e.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))]})]}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,disabled:!u,children:o(`project.add`)})]})]})})}function yn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{colors:t}=await I.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):l(o(`project.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(P,{open:!0,onClose:n,wide:d?!0:void 0,title:o(d?`project.colorsFound`:`project.colorsFromUrl`),children:d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:d.map(e=>{let t=p.includes(e.value);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(n=>t?n.filter(t=>t!==e.value):[...n,e.value]),className:u(`relative flex flex-col overflow-hidden rounded-lg text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`h-16`,style:{background:e.value}}),(0,$.jsxs)(`span`,{className:`flex flex-col px-2.5 py-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[0.8125rem] text-ink-2`,children:e.name||`—`}),(0,$.jsx)(`span`,{className:`font-mono text-[0.75rem] text-ink-3`,children:e.value})]}),t?(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>f(null),children:o(`run.back`)}),(0,$.jsx)(L,{disabled:!p.length,onClick:()=>{t(d.filter(e=>p.includes(e.value))),n()},children:p.length>1?o(`project.addMany`,{n:p.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:a,disabled:!r.trim(),children:o(`run.next`)})]})]})})}function bn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:s,save:c,readOnly:l}){let[u,d]=(0,Q.useState)(()=>n.map(e=>({...e,id:K()}))),[f,p]=(0,Q.useState)(r),[m,g]=(0,Q.useState)(i),[_,y]=(0,Q.useState)(a),[x,S]=(0,Q.useState)(null),C=tt(e,l),w=De(s),[ee,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),N=Ue({colors:u.filter(e=>_n.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:f,gradients:m,patterns:_,colorRules:w.rules},c),P=f.filter(e=>(e.kind??`colors`)===`colors`),F=e=>P.some(t=>t.id===e.section),I=u.filter(e=>!F(e)),L=(I[0]??u[0])?.id,ne=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,...t}:n)),re=e=>d(t=>[...t,...e.map(e=>({...e,id:K()}))].slice(0,X.colors)),ie=[{value:``,label:o(`project.sectionStandard`)},...P.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],ae=(e,t)=>{let n=K();T(n),p(r=>[...r,{id:n,title:t,description:``,...e===`colors`?{}:{kind:e}}])},oe=e=>({id:K(),name:``,section:e,type:`linear`,angle:90,stops:[{color:u[0]?.value&&_n.test(u[0].value)?u[0].value:`#4b73ff`,at:0},{color:u[1]?.value&&_n.test(u[1].value)?u[1].value:`#ff6d1b`,at:100}]}),z=async(e,t)=>{let n=await C.upload(`pattern`,t);y(t=>[...t,...n.map(t=>({id:K(),name:t.name.replace(/\.[^.]+$/,``),section:e,file:t.id}))])},se=[...u.length<X.colors?[{label:o(`project.colorNew`),icon:(0,$.jsx)(b,{className:`size-4 shrink-0`}),onPick:()=>D(!0)},{label:o(`project.colorsFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>M(!0)}]:[],...f.length<X.logoSections?[{label:o(`project.colorSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>ae(`colors`,``)},{label:o(`project.gradientSectionAdd`),icon:(0,$.jsx)(wt,{className:`size-4 shrink-0`}),onPick:()=>ae(`gradients`,o(`project.gradientSectionTitle`))},{label:o(`project.patternSectionAdd`),icon:(0,$.jsx)(Mt,{className:`size-4 shrink-0`}),onPick:()=>ae(`patterns`,o(`project.patternSectionTitle`))}]:[],...w.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>w.add()}]],ce=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(v,{value:_n.test(e.value)?e.value:`#888888`,onChange:t=>ne(e.id,{value:t.target.value})}),(0,$.jsx)(k,{value:e.name,placeholder:o(`project.colorName`),maxLength:120,onChange:t=>ne(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(k,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>ne(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[0.8125rem]`}),(0,$.jsxs)(`div`,{className:`flex w-28 shrink-0 items-center justify-end max-sm:w-auto`,children:[e.id===L?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(O,{tone:`ember`,children:o(`project.colorAccent`)})}):l?null:(0,$.jsx)(A,{label:o(`project.colorFirst`),onClick:()=>d(t=>[{...e,section:void 0},...t.filter(t=>t.id!==e.id)]),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`,children:(0,$.jsx)(te,{className:`size-4`})}),l||!f.length?null:(0,$.jsx)(we,{options:ie,value:F(e)?e.section??``:``,onChange:t=>ne(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),l?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>d(t=>t.filter(t=>t.id!==e.id)),className:`opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]},e.id);return(0,$.jsxs)(Y,{title:o(`project.colors`),hint:o(`project.colorsHint`),save:N,locked:l,action:l?null:(0,$.jsx)(q,{entries:se}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[I.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:I.map(ce)}),l?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.colorUse`)})]}):u.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.colorsEmpty`)}),f.map(n=>{let r=n.kind??`colors`,i=u.filter(e=>e.section===n.id),a=m.filter(e=>e.section===n.id),s=_.filter(e=>e.section===n.id),c=r===`gradients`?a.length:r===`patterns`?s.length:i.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(Pe,{title:n.title,description:n.description,titlePlaceholder:o(r===`gradients`?`project.gradientSectionTitlePlaceholder`:r===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),descriptionPlaceholder:o(`project.colorSectionUse`),autoFocus:ee===n.id,readOnly:l,onChange:e=>p(t=>t.map(t=>t.id===n.id?{...t,...e}:t)),onRemove:()=>{if(!c||confirm(o(r===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:n.title||o(`project.sectionUntitled`)}))){p(e=>e.filter(e=>e.id!==n.id)),d(e=>e.map(e=>e.section===n.id?{...e,section:void 0}:e)),g(e=>e.filter(e=>e.section!==n.id));for(let e of s)C.remove(e.file);y(e=>e.filter(e=>e.section!==n.id))}}}),r===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(e=>(0,$.jsx)(hn,{gradient:e,readOnly:l,onEdit:()=>S(e),onRename:t=>g(n=>n.map(n=>n.id===e.id?{...n,name:t}:n)),onRemove:()=>g(t=>t.filter(t=>t.id!==e.id))},e.id)),l||m.length>=X.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>S(oe(n.id)),className:`flex min-h-28 flex-col items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[0.875rem] text-ink-3 transition hover:border-ink-4 hover:text-ink`,children:[(0,$.jsx)(b,{className:`size-5`}),o(`project.gradientAdd`)]})]}):r===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[s.map(n=>(0,$.jsx)(gn,{projectId:e,pattern:n,fileName:t.files.find(e=>e.id===n.file)?.name??`pattern`,readOnly:l,onChange:e=>y(t=>t.map(t=>t.id===n.id?{...t,...e}:t)),onRemove:()=>{C.remove(n.file),y(e=>e.filter(e=>e.id!==n.id))}},n.id)),l?null:(0,$.jsxs)(je,{accept:`image/*`,onFiles:e=>void z(n.id,e),className:`min-h-28 flex-col p-3`,children:[C.busy?(0,$.jsx)(R,{className:`size-5`}):(0,$.jsx)(b,{className:`size-5`}),o(`project.patternAdd`)]})]}):i.length?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(ce)}):null]},n.id)}),(0,$.jsx)(Me,{rules:w,placeholder:o(`project.colorRulePlaceholder`),readOnly:l})]}),C.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:C.error}):null,E?(0,$.jsx)(vn,{sections:P,onClose:()=>D(!1),onAdd:e=>re([e])}):null,x?(0,$.jsx)(pn,{gradient:x,brand:u.filter(e=>_n.test(e.value)),onClose:()=>S(null),onSave:e=>g(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,j?(0,$.jsx)(yn,{projectId:e,onClose:()=>M(!1),onAdd:re}):null]})}var xn=e=>/^(ja|yes|true)$/i.test(e.trim()),Sn={text:Fe,longtext:be,number:z,date:H,url:x,email:Ye,phone:W,boolean:U};function Cn({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{c.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let l=Sn[e??t],d=`${o(`project.factType`)}: ${o(`project.type.${e??t}`)}`,f=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[0.875rem] text-ink-2 hover:bg-accent hover:text-ink`,p=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":d,title:d,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{s(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:u(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,$.jsx)(l,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:u(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:f,onClick:()=>p(void 0),children:[(0,$.jsx)(Ne,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:o(`project.type.${t}`)}),(0,$.jsx)(F,{className:u(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),Ee.map(t=>{let n=Sn[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:f,onClick:()=>p(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:o(`project.type.${t}`)}),(0,$.jsx)(F,{className:u(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function wn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,s]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),l=Ue(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),u=(e,t)=>s(n=>n.map(n=>n.id===e?{...n,...t}:n)),d=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};s(e=>n?[o,...e]:[...e,o])},f=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},p=rt.filter(e=>!a.some(t=>t.key===e.key));return(0,$.jsxs)(Y,{title:o(`project.facts`),hint:o(`project.factsHint`),save:l,locked:n,action:a.length<X.facts&&!n?(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>d({},`label`,!0),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ae(e.value),r=e.type??t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,$.jsx)(k,{ref:f(`${e.id}:label`),value:e.label,placeholder:o(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>u(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&u(e.id,{key:Se(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(c,{checked:xn(e.value),label:e.label,onChange:t=>u(e.id,{value:o(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:xn(e.value)?o(`project.yes`):o(`project.no`)})]}):(0,$.jsx)(y,{ref:f(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:o(`project.factValue`),onChange:t=>u(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Cn,{type:e.type,detected:t,onChange:t=>u(e.id,{type:t})}),n?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:()=>s(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]},e.id)})}),a.length<X.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(L,{variant:`secondary`,size:`sm`,onClick:()=>d({},`label`),children:[(0,$.jsx)(b,{className:`size-4`}),` `,o(`project.factAdd`)]}),p.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d({key:e.key,label:m===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[0.8125rem] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,$.jsx)(b,{className:`size-3.5`}),` `,m===`en`?e.en:e.de]},e.key))]}):null]})}function Tn({onLogo:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1);return e?(0,$.jsx)(`div`,{onDragOver:e=>{e.dataTransfer.types.includes(`application/x-wizards-logo`)&&(e.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:t=>{let n=t.dataTransfer.getData(Jt);i(!1),n&&(t.preventDefault(),e(n))},className:u(`-m-2 rounded-xl p-2 transition`,r&&`bg-paper-2 ring-1 ring-focus`,n),children:t}):(0,$.jsx)(`div`,{className:n,children:t})}function En({projectId:e,data:t,readOnly:n,sections:r,rules:i,save:a}){let s=tt(e,n),[c,l]=(0,Q.useState)(r),u=De(i),[d,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)(!1),h=(0,Q.useRef)(null),g=Ue({logoSections:c,logoRules:u.rules},a),_=t.files.filter(e=>e.kind===`logo`),v=new Map(_.map(e=>[e.id,e])),y=new Set(c.flatMap(e=>e.logos)),b=_.filter(e=>!y.has(e.id)),x=st(_,c)?.id,S=(e,t)=>l(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),C=(e,t)=>l(n=>n.map(n=>n.id===e?{...n,...t}:n)),w=async(e,t)=>{let n=await s.upload(`logo`,e);for(let e of n)S(e.id,t)},ee=c.length?{options:[{value:``,label:o(`project.sectionStandard`)},...c.map(e=>({value:e.id,label:e.title||o(`project.sectionUntitled`)}))],current:e=>c.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>S(e.id,t||null)}:void 0,T=(t,n,r)=>(0,$.jsx)(Yt,{projectId:e,kind:`logo`,files:t,actions:s,accept:`image/*`,addLabel:r?o(`project.logoAdd`):void 0,onUpload:e=>void w(e,n),mainId:x,onMakeMain:e=>{S(e.id,null),s.order(`logo`,[e.id,..._.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:ee,onRemove:e=>{confirm(o(`project.removeConfirm`,{name:e.name}))&&(s.remove(e.id),S(e.id,null))}}),E=n?void 0:e=>t=>S(t,e),D=[{label:o(`project.logoUpload`),icon:(0,$.jsx)(G,{className:`size-4 shrink-0`}),onPick:()=>h.current?.click()},{label:o(`project.logoFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>m(!0)},...c.length<X.logoSections?[{label:o(`project.logoSectionAdd`),icon:(0,$.jsx)(At,{className:`size-4 shrink-0`}),onPick:()=>{let e=K();f(e),l(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...u.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>u.add()}]];return(0,$.jsxs)(Y,{title:o(`project.logos`),hint:o(`project.logosHint`),save:g,action:n?null:(0,$.jsx)(q,{entries:D}),children:[(0,$.jsx)(`input`,{ref:h,type:`file`,accept:`image/*`,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&w(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(Tn,{onLogo:E?.(null),children:T(b,null,!0)}),c.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(Tn,{onLogo:E?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(Pe,{title:e.title,description:e.description,titlePlaceholder:o(`project.logoSectionTitle`),descriptionPlaceholder:o(`project.logoSectionUse`),autoFocus:d===e.id,readOnly:n,onChange:t=>C(e.id,t),onRemove:()=>{(!e.logos.length||confirm(o(`project.logoSectionRemoveConfirm`,{name:e.title||o(`project.sectionUntitled`)})))&&l(t=>t.filter(t=>t.id!==e.id))}}),T(e.logos.map(e=>v.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),(0,$.jsx)(Me,{rules:u,placeholder:o(`project.logoRulePlaceholder`),readOnly:n})]}),s.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error}):null,p?(0,$.jsx)(Xt,{kind:`logo`,onClose:()=>m(!1),fetchUrl:e=>s.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)S(t.id,null)}}):null]})}var Dn=new Set;function On(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Dn.has(t))return;Dn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${Re.join(`,`)}&display=swap`,document.head.append(n)},[e])}var kn=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function An({unit:e,label:t,...n}){return(0,$.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3`,title:t,children:[(0,$.jsx)(`input`,{type:`number`,"aria-label":t,className:`h-8 w-14 rounded-md border border-input bg-card px-1.5 text-right text-[0.8125rem] text-ink tabular-nums outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`,...n}),e]})}var jn=`h-8 rounded-md border border-input bg-card px-1.5 text-[0.8125rem] text-ink outline-none transition focus:border-focus focus:ring-2 focus:ring-focus-glow`;function Mn({font:e,first:t,readOnly:n,autoFocus:r,onChange:i,onRemove:a}){return On(e.family),(0,$.jsxs)(`div`,{className:`group/font relative flex flex-col gap-2 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,$.jsxs)(`div`,{className:`flex h-28 items-end justify-between overflow-hidden rounded-md bg-card px-4 pb-3 ring-1 ring-border-soft`,style:{fontFamily:kn(e.family)},children:[(0,$.jsx)(`span`,{className:`text-[3.5rem] text-ink leading-none`,children:`Aa`}),(0,$.jsx)(`span`,{className:`truncate pl-3 text-[0.875rem] text-ink-3`,children:`ABCDEFG abcdefg 0123456789`})]}),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`font-medium text-[0.9375rem]`,children:e.family}),e.role?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:e.role}):null]}):(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ft,{value:e.family,label:o(`project.fontFamily`),placeholder:o(`project.fontFamily`),maxLength:80,autoFocus:r,onChange:e=>i({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(ft,{value:e.role,label:o(`project.fontRole`),placeholder:o(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>i({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Re.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>i({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:kn(e.family),fontWeight:t},className:u(`h-7 rounded-full px-2.5 text-[0.8125rem] tabular-nums transition`,r?`bg-ink text-paper`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:t},t)})}),n?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:a,className:`absolute top-4 right-4 size-8 bg-card opacity-0 shadow-soft transition focus:opacity-100 group-hover/font:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})}function Nn({style:e,fonts:t,sample:n,readOnly:r,autoFocus:i,onChange:a,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:kn(c?.family),fontWeight:e.weight,fontSize:`${Math.min(e.size,56)}px`,lineHeight:`${e.lineHeight}%`,letterSpacing:`${e.tracking/100}em`,textTransform:e.uppercase?`uppercase`:void 0};return(0,$.jsxs)(`li`,{className:`group/row flex flex-col gap-2 border-border-soft border-b py-4 first:pt-1 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-ink`,style:l,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r?(0,$.jsx)(`span`,{className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`,children:e.name}):(0,$.jsx)(`div`,{className:`w-40`,children:(0,$.jsx)(ft,{value:e.name,label:o(`project.styleName`),placeholder:o(`project.styleName`),maxLength:60,autoFocus:i,onChange:e=>a({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:r,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":o(`project.styleFont`),value:c?.id??``,onChange:e=>a({font:e.target.value}),className:u(jn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||o(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":o(`project.styleWeight`),value:e.weight,onChange:e=>a({weight:Number(e.target.value)}),className:jn,children:[...new Set([...Re,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(An,{unit:`px`,label:o(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>a({size:Number(e.target.value)||16})}),(0,$.jsx)(An,{unit:o(`project.styleLine`),label:o(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>a({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(An,{unit:o(`project.styleTracking`),label:o(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>a({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:o(`project.styleUpper`),"aria-label":o(`project.styleUpper`),onClick:()=>a({uppercase:!e.uppercase}),className:u(`grid size-8 place-items-center rounded-md transition`,e.uppercase?`bg-ink text-paper`:`text-ink-3 hover:bg-paper-2 hover:text-ink`),children:(0,$.jsx)(Ot,{className:`size-4`})})]}),r?null:(0,$.jsx)(A,{label:o(`project.remove`),onClick:s,className:`ml-auto size-8 opacity-0 transition focus:opacity-100 group-hover/row:opacity-100 coarse:opacity-100 hover:text-rose`,children:(0,$.jsx)(h,{className:`size-4`})})]})]})}function Pn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[a,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)([]),m=async()=>{s(!0),l(null);try{let{fonts:t}=await I.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(d(t),p(t.slice(0,2).map(e=>e.family))):l(o(`project.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(P,{open:!0,onClose:n,wide:u?!0:void 0,title:o(u?`project.fontsFound`:`project.fontsFromUrl`),children:u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-3`,children:o(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(Fn,{font:e,on:f.includes(e.family),onToggle:()=>p(t=>t.includes(e.family)?t.filter(t=>t!==e.family):[...t,e.family])},e.family))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>d(null),children:o(`run.back`)}),(0,$.jsx)(L,{disabled:!f.length,onClick:()=>{t(u.filter(e=>f.includes(e.family))),n()},children:f.length>1?o(`project.addMany`,{n:f.length}):o(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.logoUrl`)}),(0,$.jsx)(k,{autoFocus:!0,value:r,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>i(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.fontsUrlHint`)})]}),c?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:n,children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:a,disabled:!r.trim(),children:o(`run.next`)})]})]})})}function Fn({font:e,on:t,onToggle:n}){return On(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:u(`flex items-center gap-4 rounded-lg px-4 py-3 text-left ring-1 transition`,t?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),children:[(0,$.jsx)(`span`,{className:`text-[2rem] text-ink leading-none`,style:{fontFamily:kn(e.family)},children:`Aa`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[0.9375rem]`,children:e.family}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:e.weights.length?e.weights.join(` · `):o(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(F,{className:`size-3.5`})}):null]})}function In({projectId:e,fonts:t,styles:n,rules:r,sample:i,save:a,readOnly:s}){let[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(n),f=De(r),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(!1),_=Ue({fonts:c,textStyles:u,typeRules:f.rules},a),v=(e,t=!1)=>{let n=e.map(e=>({id:K(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&m(n[0].id),l(e=>[...e,...n].slice(0,X.fonts))},y=()=>{let e=K();m(e),d(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},x=[...c.length<X.fonts?[{label:o(`project.fontNew`),icon:(0,$.jsx)(b,{className:`size-4 shrink-0`}),onPick:()=>v([{family:``,weights:[400,700]}],!0)},{label:o(`project.fontsFromUrl`),icon:(0,$.jsx)(Rt,{className:`size-4 shrink-0`}),onPick:()=>g(!0)}]:[],...u.length<X.textStyles?[{label:o(`project.styleNew`),icon:(0,$.jsx)(Le,{className:`size-4 shrink-0`}),onPick:y}]:[],...f.full?[]:[{label:o(`project.ruleNew`),icon:(0,$.jsx)(He,{className:`size-4 shrink-0`}),onPick:()=>f.add()}]];return(0,$.jsxs)(Y,{title:o(`project.typography`),hint:o(`project.typographyHint`),save:_,action:s?null:(0,$.jsx)(q,{entries:x}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[c.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:c.map((e,t)=>(0,$.jsx)(Mn,{font:e,first:t===0,readOnly:s,autoFocus:p===e.id,onChange:t=>l(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>l(t=>t.filter(t=>t.id!==e.id))},e.id))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:o(`project.fontsEmpty`)}),u.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:o(`project.styles`)}),s?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:o(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:u.map(e=>(0,$.jsx)(Nn,{style:e,fonts:c,sample:i,readOnly:s,autoFocus:p===e.id,onChange:t=>d(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>d(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,(0,$.jsx)(Me,{rules:f,placeholder:o(`project.typeRulePlaceholder`),readOnly:s})]}),h?(0,$.jsx)(Pn,{projectId:e,onClose:()=>g(!1),onAdd:e=>v(e)}):null]})}function Ln({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),s=Ue({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(Y,{title:o(`project.base`),hint:o(`project.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.title`)}),(0,$.jsx)(k,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(w,{children:o(`project.about`)}),(0,$.jsx)(y,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:o(`project.aboutHint`)})]})]})})}function Rn({project:e,group:t,children:n}){let i=r(),a=We(e.id),[s,c]=(0,Q.useState)(0),l=async t=>{await I.patch(`/api/studio/projects/${e.id}`,t),await i.invalidateQueries({queryKey:[`projects`]})},u=dt({mutationFn:()=>I.del(`/api/studio/projects/${e.id}`),onSuccess:()=>i.invalidateQueries({queryKey:[`projects`]})}),d=Ce(),f=Ze(),p=a.data??{files:[],embeddings:!0},m=`${e.id}:${s}`,h=e.readOnly,g=t===`knowledge`;return $e(h?{}:{title:o(g?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:o(g?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:o(g?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:g?[{label:o(`assistant.suggest.knowledgeHow`)},{label:o(`assistant.suggest.knowledgeSite`),fill:!0},{label:o(`assistant.suggest.knowledgeCategories`)}]:[{label:o(`assistant.suggest.readSite`),fill:!0},{label:o(`assistant.suggest.missing`)},{label:o(`assistant.suggest.facts`)}],summary:g?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${p.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>c(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[h?(0,$.jsx)(xe,{children:ye(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(J,{id:`base`,children:(0,$.jsx)(Ln,{project:e,save:l},`base:${m}`)}),(0,$.jsx)(J,{id:`facts`,children:(0,$.jsx)(wn,{facts:e.facts,save:e=>l({facts:e}),readOnly:h},`facts:${m}`)}),(0,$.jsx)(J,{id:`logos`,children:(0,$.jsx)(En,{projectId:e.id,data:p,readOnly:h,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],save:e=>l({brand:e})},`logos:${m}`)}),(0,$.jsx)(J,{id:`colors`,children:(0,$.jsx)(bn,{projectId:e.id,data:p,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],save:e=>l({brand:e}),readOnly:h},`colors:${m}`)}),(0,$.jsx)(J,{id:`typography`,children:(0,$.jsx)(In,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],sample:e.brand.name||o(`project.typeSample`),save:e=>l({brand:e}),readOnly:h},`typography:${m}`)}),(0,$.jsx)(J,{id:`assets`,children:(0,$.jsx)(ln,{projectId:e.id,data:p,readOnly:h,sections:e.brand.assetSections??[],save:e=>l({brand:e})},`assets:${m}`)})]}):null,n,t===`info`&&d&&!h&&f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(L,{variant:`danger`,busy:u.isPending,onClick:()=>confirm(`${o(`settings.delete`)}?`)&&u.mutate(),children:o(`settings.delete`)}),u.error?(0,$.jsx)(`p`,{className:`mt-2 text-[0.875rem] text-rose`,children:u.error.message}):null]}):null]})}var zn={q:``,mode:``,days:0};function Bn(e,t,n){let r=new URLSearchParams;t&&r.set(`wizard`,t),n.q.trim()&&r.set(`q`,n.q.trim()),n.mode&&r.set(`mode`,n.mode),n.days&&r.set(`days`,String(n.days));let a=r.toString();return i({queryKey:[`results`,e,a],queryFn:()=>I.get(`/api/studio/projects/${e}/results${a&&`?${a}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function Vn({filter:e,onFilter:t}){let[n,r]=(0,Q.useState)(e.q);return(0,Q.useEffect)(()=>{if(n===e.q)return;let r=setTimeout(()=>t({...e,q:n}),250);return()=>clearTimeout(r)},[n,e,t]),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-56`,children:[(0,$.jsx)(ze,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(k,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:o(`space.resultsSearch`),"aria-label":o(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(T,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:o(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(T,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:o(`space.resultsAnyTime`)},{value:`1`,label:o(`space.resultsDay`)},{value:`7`,label:o(`space.resultsDays`,{n:7})},{value:`30`,label:o(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function Hn({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),s=t=>e.wizards.find(e=>e.id===t)?.title??``,c=new Intl.DateTimeFormat(m,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{title:t?s(t):o(`space.resultsAll`),hint:o(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(Vn,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(E,{className:`flex flex-col p-1.5`,children:e.runs.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex items-center gap-3 rounded-lg px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-[0.875rem]`,children:t?c.format(new Date(e.doneAt)):s(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${c.format(new Date(e.doneAt))} · `,o(`space.resultCredits`,{n:e.credits})]})]}),e.assets?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.75rem] text-ink-3 tabular-nums`,title:o(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(d,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(O,{children:`Test`}):(0,$.jsxs)(O,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(E,{children:(0,$.jsx)(j,{children:n.q.trim()||n.mode||n.days?o(`space.resultsNone`):o(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(V,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:s(i.wizardId)}),i.mode===`test`?(0,$.jsx)(O,{children:`Test`}):(0,$.jsxs)(O,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(St,{runId:i.id,compact:!0},i.id)}):null]})}function Un({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(e.name),s=dt({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{label:o(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,$.jsx)(f,{className:`size-4`})}),(0,$.jsx)(P,{open:n,onClose:()=>r(!1),title:o(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&s.mutate()},children:[(0,$.jsx)(k,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),s.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:s.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(L,{variant:`ghost`,onClick:()=>r(!1),children:o(`common.cancel`)}),(0,$.jsx)(L,{type:`submit`,busy:s.isPending,disabled:!i.trim(),children:o(`settings.save`)})]})]})})]})}function Wn({project:e}){let t=r();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ut,{}),e.readOnly?null:(0,$.jsx)(Un,{project:e,save:async n=>{await I.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function Gn(e){let t=e.join(` `),[n,r]=(0,Q.useState)(e[0]);return(0,Q.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=Je(),i=t.scrollTop>0&&t.clientHeight+t.scrollTop>=t.scrollHeight-4,a=(t===document.documentElement?0:t.getBoundingClientRect().top)+Math.max(120,t.clientHeight/3),o=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=a&&(o=t)}r(i?e.at(-1):o)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0,capture:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a,{capture:!0}),window.removeEventListener(`resize`,a)}},[t]),n}function Kn(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function qn({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(Z,{icon:e.icon??Be,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(ht,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function Jn(){let{group:e}=_(),[t,n]=s(),r=re(),i=ee(),{hash:a}=i,{project:c,loading:l}=ke(),d=Ce(),f=Qe(),p=xt(),[m,h]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(null),x=Ge(e)?e:void 0,S=i.state?.parts===!0,w=nt().map(e=>({...e,to:`/space/${e.id}`})),T=w.find(e=>e.id===x),E=t.get(`show`),D=x?E?2:1:0,O=p?Math.min(D,1):x&&y!==x&&!S?1:0,k=mt(O),A=mt(D),te=(0,Q.useMemo)(()=>({slot:m,narrow:p,setDetail:v}),[m,p]),M=c?c.brand.name?.trim()||c.name:o(`nav.project`),N=x&&x!==`results`?qe(x,f):[],P=x?qe(x,f).filter(e=>e.plugin):[],F=Gn([...N,...x===`results`?P:[]].flatMap(e=>e.sections.map(e=>e.id))),I=x===`results`&&E&&E!==`all`?E:null,[L,ne]=(0,Q.useState)(zn),R=Bn(x===`results`?c?.id:void 0,I,L),ie=R.data?.wizards.find(e=>e.id===I)?.title,z=x===`data`&&E&&E!==`all`||x===`knowledge`&&E&&/^[ptfcvs]:/.test(E)?E:null,B=z?.startsWith(`s:`)?f.spaceSections.find(e=>e.id===z.slice(2)):void 0,V=x===`knowledge`&&z&&/^[ptf]:/.test(z)?z:null,H=se(x===`data`?c?.id:void 0),U=pe(x===`knowledge`?c?.id:void 0),W=ve(z?.startsWith(`v:`)?z.slice(2):``),ye=U.data?.categories.find(e=>e.id===(z?.startsWith(`c:`)?z.slice(2):W.data?.category.id)),be=x===`knowledge`?B?B.label():z?.startsWith(`v:`)?W.data&&`${W.data.category.name}: ${W.data.value}`:z?.startsWith(`c:`)?ye?.name:U.data?.items.find(e=>e.key===z)?.title:H.data?ge(H.data).flatMap(e=>e.items).find(e=>e.key===z)?.title:void 0;Ve([{label:o(`nav.project`),to:`/space`},...T?[{label:T.label,to:`/space/${T.id}`}]:[],...T&&(g??ie??be)?[{label:g??ie??be}]:[]]);let xe={p:`page`,t:`table`,f:`file`,c:`kategorie`,v:`kategorie value`,s:`plugin section`};$e({...x===`data`||x===`results`?{compact:!0}:{},...x===`data`?{suggestions:[{label:o(`assistant.suggest.dataWhat`)},{label:o(`assistant.suggest.dataWho`)},{label:o(`assistant.suggest.dataEdit`)}]}:x===`results`?{suggestions:[{label:o(`assistant.suggest.resultsFailed`)},{label:o(`assistant.suggest.resultsCost`)},{label:o(`assistant.suggest.resultsShare`)}]}:{},...z&&be?{open:{kind:xe[z[0]]??`item`,id:z.slice(2),label:be}}:I&&ie?{open:{kind:`wizard`,id:I,label:ie}}:{}});let G=x===`results`||x===`data`||z?a.slice(1):E||a.slice(1),Se=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${x}#${G}`;G&&Se.current!==e&&document.getElementById(G)&&(Se.current=e,requestAnimationFrame(()=>Kn(G,!1)))},[x,G,c?.id,f.spaceSections]),!x){let t=a.slice(1),n=t?ct(t,f):null;if(n===`knowledge`&&f.spaceSections.some(e=>e.id===t))return(0,$.jsx)(C,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(C,{to:p?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if(t&&f.status!==`ready`)return null;if(e!==void 0||!p)return(0,$.jsx)(C,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(x===`knowledge`&&!E&&f.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(C,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let we=e=>{if(p){r({search:`?show=${e}`});return}Se.current=`${x}#${e}`,Kn(e,!0),r({search:``,hash:e},{replace:!0})},K=e=>p?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Te=e=>e.flatMap(e=>e.sections).map(e=>f.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(J,{id:e.id,children:(0,$.jsx)(Y,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(at,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),q=p?void 0:F;return(0,$.jsx)(_t.Provider,{value:te,children:(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,$.jsxs)(`aside`,{className:u(`min-w-0 md:sticky md:top-6 md:self-start`,p&&D===2&&`hidden`,p&&A===`back`&&pt(`back`)),children:[(0,$.jsx)(gt,{title:M,open:O===1?T??null:null,onBack:()=>p?r(`/space`):b(x??null)}),(0,$.jsx)(`div`,{className:u(pt(k)),children:O===0?(0,$.jsx)(vt,{entries:w,current:p?void 0:T,onPick:()=>b(null)}):(0,$.jsx)(`div`,{ref:h})},O)]}),x?(0,$.jsxs)(`div`,{className:u(`min-w-0`,p&&D<2&&`hidden`,p&&A===`deeper`&&pt(`deeper`)),children:[p?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(bt,{label:T?.label??M,onBack:()=>r(`/space/${x}`)})}):null,d&&c?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(Wn,{project:c})}):null,x===`results`?(0,$.jsxs)(yt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Z,{icon:Pt,label:o(`space.resultsAll`),selected:!p&&!I,onPick:()=>K(`all`)}),R.data?.wizards.filter(e=>e.results||e.id===I).map(e=>(0,$.jsx)(Z,{icon:Ne,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!p&&e.id===I,onPick:()=>K(e.id)},e.id))]}),(0,$.jsx)(qn,{groups:P,current:q,onPick:we})]}):x===`data`?(0,$.jsxs)(yt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:It,label:o(`data.all`),selected:!p&&!z,onPick:()=>K(`all`)})}),H.data?ge(H.data).map(e=>(0,$.jsx)(ht,{label:e.label,children:e.items.map(e=>(0,$.jsx)(Z,{icon:oe[e.kind],label:e.title,selected:!p&&e.key===z,onPick:()=>K(e.key)},e.key))},e.key)):null,(0,$.jsx)(qn,{groups:P,current:q,onPick:we})]}):x===`knowledge`?(0,$.jsxs)(yt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(Z,{icon:It,label:o(`know.all`),selected:!(p||z),onPick:()=>K(`all`)})}),U.data?.categories.length?(0,$.jsx)(ht,{label:o(`know.categories`),children:U.data.categories.map(e=>(0,$.jsx)(Z,{icon:ue[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!p&&(z===`c:${e.id}`||W.data?.category.id===e.id),onPick:()=>K(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(qn,{groups:P,current:p?void 0:B?.id,onPick:e=>K(`s:${e}`)})]}):(0,$.jsx)(yt,{children:(0,$.jsx)(qn,{groups:N,current:q,onPick:we})}),c&&(x===`info`||x===`knowledge`)?(0,$.jsxs)(Rn,{project:c,group:x,children:[x===`knowledge`?V?V.startsWith(`p:`)?(0,$.jsx)(fe,{pageId:V.slice(2),onGone:()=>K(`all`),onOpen:K},V):V.startsWith(`t:`)?(0,$.jsx)(de,{tableId:V.slice(2),onGone:()=>K(`all`)},V):(0,$.jsx)(tn,{projectId:c.id,fileId:V.slice(2),readOnly:c.readOnly,onGone:()=>K(`all`)},V):U.data?B?(0,$.jsx)(Y,{title:B.label(),hint:B.hint?.(),plain:!0,children:(0,$.jsx)(at,{of:B,children:(0,$.jsx)(B.component,{})})},z):z?.startsWith(`c:`)?ye?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(le,{projectId:c.id,category:ye,readOnly:c.readOnly,onOpen:K,onGone:()=>K(`all`)}),ye.type===`choice`?null:(0,$.jsx)(_e,{projectId:c.id,category:ye,categories:U.data.categories,onOpen:K})]},z):null:z?.startsWith(`v:`)?W.data?(0,$.jsx)(ae,{value:W.data,readOnly:c.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[W.data.items.length?(0,$.jsx)(`div`,{className:`flex flex-col rounded-xl bg-card p-1.5 shadow-soft ring-1 ring-border-soft`,children:W.data.items.map(e=>(0,$.jsx)(ce,{item:e,categories:U.data.categories.filter(e=>e.id!==W.data?.category.id),onOpen:K},e.key))}):null,W.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>K(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:o(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},z):null:(0,$.jsx)(J,{id:`documents`,children:(0,$.jsx)(he,{projectId:c.id,data:U.data,readOnly:c.readOnly,onOpen:K})}):null:null,x===`info`?Te(P):null]},c.id):null,c&&x===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:z?.startsWith(`t:`)?(0,$.jsx)(de,{tableId:z.slice(2),onGone:()=>K(`all`)},z):z?.startsWith(`p:`)?(0,$.jsx)(fe,{pageId:z.slice(2),onGone:()=>K(`all`)},z):(0,$.jsxs)($.Fragment,{children:[H.data?(0,$.jsx)(me,{projectId:c.id,data:H.data,readOnly:c.readOnly,onOpen:K}):null,Te(P)]})}):null,c&&x===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[R.data?(0,$.jsx)(Hn,{data:R.data,wizardId:I,filter:L,onFilter:ne}):null,R.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:R.error.message}):null,Te(P)]}):null,c||l?null:(0,$.jsx)(j,{children:o(`settings.noProject`)})]}):null]})})})}export{Jn as ProjectPage};
|