wizards 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/apps/web/dist/assets/{AboutDialog-BcTtA42P.js → AboutDialog-CpI-cGpz.js} +1 -1
  2. package/apps/web/dist/assets/{ChangelogDialog-DMOWV_Iu.js → ChangelogDialog-BW56Y5UR.js} +1 -1
  3. package/apps/web/dist/assets/{ChatView-CrnrYHjp.js → ChatView-CH8U-tRy.js} +1 -1
  4. package/apps/web/dist/assets/{EditorPage-DpEw3eOu.js → EditorPage-Be5J_y4F.js} +1 -1
  5. package/apps/web/dist/assets/{Harness-DipH0Vec.js → Harness-CJKWO3AK.js} +1 -1
  6. package/apps/web/dist/assets/{NewWizardChannels-DShu0PP6.js → NewWizardChannels-Ca2niMTY.js} +1 -1
  7. package/apps/web/dist/assets/{NewWizardPage-HSa6PNJs.js → NewWizardPage-D5gi4TYE.js} +1 -1
  8. package/apps/web/dist/assets/{OnboardingPage-CPADMs4c.js → OnboardingPage-Bm-c-D21.js} +1 -1
  9. package/apps/web/dist/assets/{ProjectPage-DMPcrhgt.js → ProjectPage-C8nJCBZP.js} +1 -1
  10. package/apps/web/dist/assets/{PublicRunner-DZ5sWmtg.js → PublicRunner-anxg3Rxz.js} +1 -1
  11. package/apps/web/dist/assets/{ReadOnly-B9xaq_M3.js → ReadOnly-i-6WBMSE.js} +1 -1
  12. package/apps/web/dist/assets/{RunDrawer-9nMGhbSm.js → RunDrawer-4yvfW_2c.js} +1 -1
  13. package/apps/web/dist/assets/{RunnerView-NSSP3tc6.js → RunnerView-BkWQBa_M.js} +1 -1
  14. package/apps/web/dist/assets/{SettingsPage-Dy9MbwQh.js → SettingsPage-NL8r9S6R.js} +1 -1
  15. package/apps/web/dist/assets/{SetupPage-kemgI7v5.js → SetupPage-Crcfx4-p.js} +1 -1
  16. package/apps/web/dist/assets/{SharePage-CQfIdcwy.js → SharePage-CDEAtmBC.js} +1 -1
  17. package/apps/web/dist/assets/changelog-BGBuldNF.js +1 -0
  18. package/apps/web/dist/assets/{index-DQ9qAB4v.js → index-C74LSJ-W.js} +3 -3
  19. package/apps/web/dist/index.html +1 -1
  20. package/bin/wizards.mjs +15 -2
  21. package/package.json +5 -1
  22. package/apps/web/dist/assets/changelog-BW40vzI6.js +0 -1
@@ -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{$ as r,Dt as i,Gr as a,Nn as o,Ut as s,W as c,Yt as l,nr as u}from"./ui-EuR3jezP.js";import{B as d,Zt as f}from"./index-DQ9qAB4v.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{$ as r,Dt as i,Gr as a,Nn as o,Ut as s,W as c,Yt as l,nr as u}from"./ui-EuR3jezP.js";import{B as d,Zt as f}from"./index-C74LSJ-W.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
 
@@ -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{En as r,Fn as i,Ut as a,Yt as o,cr as s,nn as c,nr as l,rr as u}from"./ui-EuR3jezP.js";import{t as d}from"./phone-3fG1okFs.js";import{Ft as f,It as p,Rt as m,Ut as h}from"./index-DQ9qAB4v.js";var g={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`}]]};g.node;var _=s(g),v=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...c],[...v];var y={default:`steps`,enabled:[`steps`,`chat`]},b=e(t(),1),x=e(n(),1),S=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:m},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:p},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:u},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:r},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:d},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:_},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],C=[{id:`web`,label:`new.web`,icon:h},{id:`phone`,label:`new.phone`,icon:d},{id:`message`,label:`new.messages`,icon:f}],w=S.filter(e=>y.enabled.includes(e.id)).map(e=>e.id),T=e=>S.filter(t=>e.includes(t.id));function E(e){return e.length===w.length&&w.every(t=>e.includes(t))}function D(e){let t=T(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??y.default,enabled:n}}var O=e=>e.map(e=>o(e.label));function k(e){return S.find(t=>t.runner===e)}function A(e){return S.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function j(e){let t=T(e),n=C.flatMap(e=>{let n=O(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${o(e.label)}: ${n.join(`, `)}`]:[]});return`${o(`new.runsAs`)}: ${n.join(` · `)}`}function M(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function N({channel:e,className:t}){let n=e.icon;return n?(0,x.jsx)(n,{className:t??`size-4`}):(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function P(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`,`talk`,`video`]);return S.filter(e=>t.has(e.runner))}function F({value:e,onChange:t,runners:n,without:r,disabled:i}){let s=P(n).filter(e=>!r?.includes(e.id)),c=t=>e.includes(t.id),u=n=>{i||c(n)&&e.length===1||t(c(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=C.find(e=>e.id===t),r=s.filter(e=>e.group===t);if(!(n&&r.length))return null;let d=n.icon;return(0,x.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,x.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,x.jsx)(d,{className:`size-3.5`}),` `,o(n.label)]}),r.map(t=>(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`label`,{className:a(`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`,c(t)&&`bg-paper-2`),children:[(0,x.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,x.jsx)(N,{channel:t})}),(0,x.jsx)(`span`,{className:`flex-1`,children:o(t.label)}),(0,x.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":o(t.label),checked:c(t),disabled:i,"aria-disabled":c(t)&&e.length===1,onChange:()=>u(t)}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:a(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,c(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:c(t)?(0,x.jsx)(l,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&c(t)?(0,x.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:o(`new.callHandoff`)}):null]},t.id))]})};return(0,x.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function I({value:e,onChange:t,runners:n,className:r}){let[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!s)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[s]);let f=P(n),p=C.filter(e=>f.some(t=>t.group===e.id)),m=t=>e.includes(t.id);return(0,x.jsxs)(`div`,{ref:d,className:a(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,x.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:o(`new.runsAs`)}),p.map(e=>{let t=O(f.filter(t=>t.group===e.id&&m(t))),n=e.icon;return(0,x.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":`${o(e.label)}: ${t.length?t.join(`, `):o(`new.off`)}`,onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:a(`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,x.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,x.jsx)(`span`,{className:`truncate`,children:M(t)}):null]},e.id)}),(0,x.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":o(`new.where`),onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,x.jsx)(i,{className:`size-4`})}),s?(0,x.jsxs)(`div`,{role:`dialog`,"aria-label":o(`new.where`),style:{transformOrigin:`${l}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,x.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:o(`new.where`)}),(0,x.jsx)(F,{value:e,onChange:t,runners:n})]}):null]})}export{j as a,E as c,I as i,D as l,N as n,k as o,F as r,A as s,C as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{En as r,Fn as i,Ut as a,Yt as o,cr as s,nn as c,nr as l,rr as u}from"./ui-EuR3jezP.js";import{t as d}from"./phone-3fG1okFs.js";import{Ft as f,It as p,Rt as m,Ut as h}from"./index-C74LSJ-W.js";var g={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`}]]};g.node;var _=s(g),v=[`text`,`data`,`image`,`video`,`voice`,`document`,`dashboard`,`widget`,`film`,`surface`];[...c],[...v];var y={default:`steps`,enabled:[`steps`,`chat`]},b=e(t(),1),x=e(n(),1),S=[{id:`steps`,group:`web`,runner:`steps`,label:`new.ch.steps`,icon:m},{id:`chat`,group:`web`,runner:`chat`,label:`new.ch.chat`,icon:p},{id:`talk`,group:`web`,runner:`talk`,label:`new.ch.talk`,icon:u},{id:`video`,group:`web`,runner:`video`,label:`new.ch.video`,icon:r},{id:`call`,group:`phone`,runner:`call`,label:`new.ch.call`,icon:d},{id:`wacall`,group:`phone`,runner:`call`,label:`new.ch.whatsapp`,icon:null},{id:`sms`,group:`message`,runner:`sms`,label:`new.ch.sms`,icon:_},{id:`whatsapp`,group:`message`,runner:`whatsapp`,label:`new.ch.whatsapp`,icon:null}],C=[{id:`web`,label:`new.web`,icon:h},{id:`phone`,label:`new.phone`,icon:d},{id:`message`,label:`new.messages`,icon:f}],w=S.filter(e=>y.enabled.includes(e.id)).map(e=>e.id),T=e=>S.filter(t=>e.includes(t.id));function E(e){return e.length===w.length&&w.every(t=>e.includes(t))}function D(e){let t=T(e),n=[...new Set(t.map(e=>e.runner))];return{default:t.find(e=>e.group===`web`)?.runner??n[0]??y.default,enabled:n}}var O=e=>e.map(e=>o(e.label));function k(e){return S.find(t=>t.runner===e)}function A(e){return S.filter(t=>t.id!==`wacall`&&e.includes(t.runner)).map(e=>e.id)}function j(e){let t=T(e),n=C.flatMap(e=>{let n=O(t.filter(t=>t.group===e.id));return n.length?[e.id===`web`?n.join(`, `):`${o(e.label)}: ${n.join(`, `)}`]:[]});return`${o(`new.runsAs`)}: ${n.join(` · `)}`}function M(e){return e.length<=2?e.join(`, `):`${e.slice(0,2).join(`, `)} +${e.length-2}`}function N({channel:e,className:t}){let n=e.icon;return n?(0,x.jsx)(n,{className:t??`size-4`}):(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-[0.625rem] tracking-wide`,children:`WA`})}function P(e){let t=new Set(e?.map(e=>e.id)??[`steps`,`chat`,`talk`,`video`]);return S.filter(e=>t.has(e.runner))}function F({value:e,onChange:t,runners:n,without:r,disabled:i}){let s=P(n).filter(e=>!r?.includes(e.id)),c=t=>e.includes(t.id),u=n=>{i||c(n)&&e.length===1||t(c(n)?e.filter(e=>e!==n.id):[...e,n.id])},d=t=>{let n=C.find(e=>e.id===t),r=s.filter(e=>e.group===t);if(!(n&&r.length))return null;let d=n.icon;return(0,x.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-0.5 border-0 p-0`,children:[(0,x.jsxs)(`legend`,{className:`flex items-center gap-1.5 px-2 pt-2 pb-1 text-[0.75rem] text-ink-3`,children:[(0,x.jsx)(d,{className:`size-3.5`}),` `,o(n.label)]}),r.map(t=>(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`label`,{className:a(`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`,c(t)&&`bg-paper-2`),children:[(0,x.jsx)(`span`,{className:`flex w-5 justify-center text-ink-3`,children:(0,x.jsx)(N,{channel:t})}),(0,x.jsx)(`span`,{className:`flex-1`,children:o(t.label)}),(0,x.jsx)(`input`,{type:`checkbox`,className:`sr-only`,"aria-label":o(t.label),checked:c(t),disabled:i,"aria-disabled":c(t)&&e.length===1,onChange:()=>u(t)}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:a(`flex size-[1.125rem] items-center justify-center rounded-md ring-1`,c(t)?`bg-ink text-paper ring-ink`:`ring-border`),children:c(t)?(0,x.jsx)(l,{className:`size-3`,strokeWidth:3}):null})]}),t.id===`call`&&c(t)?(0,x.jsx)(`p`,{className:`px-2 pb-1.5 pl-9 text-[0.75rem] text-ink-3`,children:o(`new.callHandoff`)}):null]},t.id))]})};return(0,x.jsxs)(`div`,{className:`grid gap-x-4 sm:grid-cols-2`,children:[d(`web`),(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[d(`phone`),d(`message`)]})]})}function I({value:e,onChange:t,runners:n,className:r}){let[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!s)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[s]);let f=P(n),p=C.filter(e=>f.some(t=>t.group===e.id)),m=t=>e.includes(t.id);return(0,x.jsxs)(`div`,{ref:d,className:a(`relative flex flex-wrap items-center gap-1.5`,r),children:[(0,x.jsx)(`span`,{className:`mr-0.5 px-1 text-[0.8125rem] text-ink-3`,children:o(`new.runsAs`)}),p.map(e=>{let t=O(f.filter(t=>t.group===e.id&&m(t))),n=e.icon;return(0,x.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":`${o(e.label)}: ${t.length?t.join(`, `):o(`new.off`)}`,onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:a(`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,x.jsx)(n,{className:`size-4 shrink-0`}),t.length?(0,x.jsx)(`span`,{className:`truncate`,children:M(t)}):null]},e.id)}),(0,x.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":o(`new.where`),onClick:e=>{let t=e.currentTarget;u(t.offsetLeft+t.offsetWidth/2),c(e=>!e)},className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 ring-1 ring-border transition hover:text-ink coarse:size-11`,children:(0,x.jsx)(i,{className:`size-4`})}),s?(0,x.jsxs)(`div`,{role:`dialog`,"aria-label":o(`new.where`),style:{transformOrigin:`${l}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,x.jsx)(`p`,{className:`px-2 pt-1 font-semibold text-[0.9375rem]`,children:o(`new.where`)}),(0,x.jsx)(F,{value:e,onChange:t,runners:n})]}):null]})}export{j as a,E as c,I as i,D as l,N as n,k as o,F as r,A as s,C as t};
@@ -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{$ as r,At as i,Dt as a,Fn as o,Fr as s,Gr as c,Gt as l,Ht as u,Tn as d,Ut as f,W as p,Yt as m,ar as h,br as g,bt as _,c as v,d as y,f as b,fr as ee,gr as x,kt as S,m as te,p as ne,u as re,vr as ie,zn as ae}from"./ui-EuR3jezP.js";import{a as oe,c as C,i as w,l as T}from"./NewWizardChannels-DShu0PP6.js";import{t as E}from"./upload-BsMUhEfX.js";import{C as se,S as D,T as O,Zt as k,lt as A,mt as ce,ot as j,rt as M,tt as N,w as P}from"./index-DQ9qAB4v.js";var F=[[`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 I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(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 V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(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 H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(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 W=new Set(L(`aber als also am an auch auf aus bei bin bitte brauche brauchen braucht das dass dem den der
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$ as r,At as i,Dt as a,Fn as o,Fr as s,Gr as c,Gt as l,Ht as u,Tn as d,Ut as f,W as p,Yt as m,ar as h,br as g,bt as _,c as v,d as y,f as b,fr as ee,gr as x,kt as S,m as te,p as ne,u as re,vr as ie,zn as ae}from"./ui-EuR3jezP.js";import{a as oe,c as C,i as w,l as T}from"./NewWizardChannels-Ca2niMTY.js";import{t as E}from"./upload-BsMUhEfX.js";import{C as se,S as D,T as O,Zt as k,lt as A,mt as ce,ot as j,rt as M,tt as N,w as P}from"./index-C74LSJ-W.js";var F=[[`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 I(e){return e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/([a-z])([A-Z])/g,`$1 $2`).toLowerCase()}function L(e){return I(e).split(/[^a-z0-9]+/).map(e=>e.trim()).filter(e=>e.length>1)}function R(e){return e==null?``:Array.isArray(e)?e.map(R).filter(Boolean).join(` `):typeof e==`object`?Object.values(e).map(R).filter(Boolean).join(` `):String(e)}function z(e,t){let n=t.map(([t,n])=>({text:R(e[t]),weight:n})).filter(e=>e.text.length>0);return{fields:n,tokens:n.flatMap(e=>L(e.text))}}function B(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 V(e,t){if(e===t)return 1;let n=0;for(let r of B(e))for(let i of B(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 H(e,t){return e.reduce((e,n)=>e+V(t,n),0)}function U(e,t,n=F){if(!t?.trim())return 0;let r=L(t);if(r.length===0)return 0;let i=z(e,n);return i.tokens.length===0?0:r.reduce((e,t)=>H(i.tokens,t)===0?e:e+i.fields.reduce((e,n)=>{let r=L(n.text),i=H(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 W=new Set(L(`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
@@ -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{Gr as r,Ut as i,W as a,Yt as o,ar as s,gr as c,nr as l,qn as u}from"./ui-EuR3jezP.js";import{t as d}from"./upload-BsMUhEfX.js";import{V as f,Zt as p,gt as m,mt as h,ot as g,rt as _,ut as v,yt as y}from"./index-DQ9qAB4v.js";var b=e(t(),1),x=e(n(),1),S=`oklch(50% 0.2 262)`,C=`oklch(32% 0.15 262)`,w={"--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)`},T=`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 E(){return(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,x.jsx)(y,{size:28}),(0,x.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,x.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,x.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function D({children:e,busy:t,onClick:n,type:r=`button`}){return(0,x.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:C},children:[e,(0,x.jsx)(s,{className:`size-[18px]`})]})}function O({children:e,onClick:t}){return(0,x.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function k({step:e}){return(0,x.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":o(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,x.jsx)(`span`,{className:i(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}function A(){m(S);let e=v(),t=r(),n=c(),{project:s}=g(),[y,A]=(0,b.useState)(1),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)(null),[z,B]=(0,b.useState)([]),V=(0,b.useRef)(null),[H]=(0,b.useState)(_),U=p({mutationFn:e=>a.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),W=p({mutationFn:e=>a.post(`/api/studio/projects/${s?.id}/website`,{url:e}),onSuccess:async e=>{R(e),await t.invalidateQueries({queryKey:[`projects`]})}}),G=p({mutationFn:e=>a.patch(`/api/studio/projects/${s?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),K=p({mutationFn:()=>a.post(`/api/studio/onboarding/done`),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),q=e.data?.user.name??``,J=q.includes(`@`)?``:q.split(` `)[0],Y=async e=>{if(e&&s){for(let t of Array.from(e)){B(e=>[...e,{name:t.name,state:`uploading`}]);try{await a.upload(`/api/studio/projects/${s.id}/files?kind=document`,t),B(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{B(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},X=L?[L.about?o(`onboard.readAbout`):``,L.colors?o(`onboard.readColors`,{n:L.colors}):``,L.logo?o(`onboard.readLogo`):``].join(``):``;return(0,x.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...w,background:S},children:[(0,x.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,x.jsx)(E,{}),(0,x.jsx)(f,{tone:`ground`,ink:C})]}),(0,x.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,x.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,x.jsx)(h,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),H?(0,x.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,x.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.wish`)}),(0,x.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:H}),(0,x.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:o(`onboard.wishNext`)})]}):null]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[y===1?(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=j.trim();t?U.mutate(t,{onSuccess:()=>A(2)}):A(2)},children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:J?o(`onboard.kicker1`,{name:J}):o(`onboard.kicker1Anon`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.team`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.teamSub`)}),(0,x.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:o(`onboard.teamPlaceholder`),maxLength:80,"aria-label":o(`onboard.team`),className:T}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{type:`submit`,busy:U.isPending,children:o(`onboard.continue`)}),(0,x.jsx)(k,{step:1})]})]}):null,y===2?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker2`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.site`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.siteSub`)}),F===null?(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),N.trim()&&!W.isPending&&W.mutate(N.trim())},children:[(0,x.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),placeholder:o(`onboard.sitePlaceholder`),inputMode:`url`,autoCapitalize:`none`,"aria-label":o(`onboard.site`),className:T}),L?(0,x.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,x.jsx)(l,{className:`size-4`}),o(`onboard.readDone`,{name:L.name,details:X})]}):W.isError?(0,x.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:o(`onboard.readFailed`)}):null,(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[L?(0,x.jsx)(D,{onClick:()=>A(3),children:o(`onboard.continue`)}):(0,x.jsx)(D,{type:`submit`,busy:W.isPending,children:W.isPending?o(`onboard.reading`):o(`onboard.read`)}),(0,x.jsx)(O,{onClick:()=>I(``),children:o(`onboard.line`)}),(0,x.jsx)(O,{onClick:()=>A(3),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:2})]})]}):(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=F.trim();t?G.mutate(t,{onSuccess:()=>A(3)}):A(3)},children:[(0,x.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:o(`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":o(`onboard.line`),className:i(T,`resize-none text-[1.125rem] leading-relaxed`)}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{type:`submit`,busy:G.isPending,children:o(`onboard.continue`)}),(0,x.jsx)(O,{onClick:()=>I(null),children:o(`onboard.site`)}),(0,x.jsx)(O,{onClick:()=>A(3),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:2})]})]})]}):null,y===3?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker3`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.know`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.knowSub`)}),(0,x.jsxs)(`button`,{type:`button`,onClick:()=>V.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),Y(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,x.jsx)(d,{className:`size-7`}),(0,x.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:o(`onboard.drop`)}),(0,x.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,x.jsx)(`input`,{ref:V,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{Y(e.target.files),e.target.value=``}})]}),z.length?(0,x.jsx)(`ul`,{className:`flex flex-col gap-2`,children:z.map(e=>(0,x.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,x.jsx)(u,{className:`size-4 shrink-0`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,x.jsx)(`span`,{className:i(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?o(`onboard.uploading`):e.state===`done`?o(`onboard.uploaded`):o(`onboard.uploadFailed`)})]},e.name))}):null,(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{busy:z.some(e=>e.state===`uploading`),onClick:()=>A(4),children:o(`onboard.continue`)}),z.length?null:(0,x.jsx)(O,{onClick:()=>A(4),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:3})]})]}):null,y===4?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker4`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.space`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.spaceSub`,{space:s?.name??``})}),(0,x.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(L||F)],[`partKnow`,`partKnowText`,z.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,x.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,x.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,x.jsx)(l,{className:`size-4 text-(color:--moss)`}):null,o(`onboard.${e}`)]}),(0,x.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:o(`onboard.${t}`)})]},e))}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{busy:K.isPending,onClick:()=>K.mutate(),children:o(`onboard.build`)}),(0,x.jsx)(k,{step:4})]})]}):null]},y)]}),(0,x.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,x.jsx)(`span`,{children:`engenty`}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{A as OnboardingPage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Gr as r,Ut as i,W as a,Yt as o,ar as s,gr as c,nr as l,qn as u}from"./ui-EuR3jezP.js";import{t as d}from"./upload-BsMUhEfX.js";import{V as f,Zt as p,gt as m,mt as h,ot as g,rt as _,ut as v,yt as y}from"./index-C74LSJ-W.js";var b=e(t(),1),x=e(n(),1),S=`oklch(50% 0.2 262)`,C=`oklch(32% 0.15 262)`,w={"--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)`},T=`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 E(){return(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-2.5`,children:[(0,x.jsx)(y,{size:28}),(0,x.jsxs)(`span`,{className:`font-display font-semibold text-[1.0625rem] tracking-tight`,children:[`engenty`,(0,x.jsx)(`span`,{className:`mr-[0.09em] ml-[0.06em] text-(color:--dot)`,children:`.`}),(0,x.jsx)(`span`,{className:`font-normal text-white/70`,children:`wizards`})]})]})}function D({children:e,busy:t,onClick:n,type:r=`button`}){return(0,x.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:C},children:[e,(0,x.jsx)(s,{className:`size-[18px]`})]})}function O({children:e,onClick:t}){return(0,x.jsx)(`button`,{type:`button`,onClick:t,className:`cursor-pointer font-semibold text-[0.9375rem] text-white/85 transition hover:text-white`,children:e})}function k({step:e}){return(0,x.jsx)(`span`,{className:`ml-auto inline-flex gap-1.5`,role:`img`,"aria-label":o(`onboard.step`,{n:e}),children:[1,2,3,4].map(t=>(0,x.jsx)(`span`,{className:i(`size-2 rounded-full`,t===e?`bg-white`:`bg-white/40`)},t))})}function A(){m(S);let e=v(),t=r(),n=c(),{project:s}=g(),[y,A]=(0,b.useState)(1),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)(null),[z,B]=(0,b.useState)([]),V=(0,b.useRef)(null),[H]=(0,b.useState)(_),U=p({mutationFn:e=>a.put(`/api/studio/team`,{name:e}),onSuccess:()=>t.invalidateQueries({queryKey:[`team`]})}),W=p({mutationFn:e=>a.post(`/api/studio/projects/${s?.id}/website`,{url:e}),onSuccess:async e=>{R(e),await t.invalidateQueries({queryKey:[`projects`]})}}),G=p({mutationFn:e=>a.patch(`/api/studio/projects/${s?.id}`,{brand:{about:e}}),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),K=p({mutationFn:()=>a.post(`/api/studio/onboarding/done`),onSuccess:async()=>{await t.invalidateQueries({queryKey:[`me`]}),n(`/new`,{replace:!0})}}),q=e.data?.user.name??``,J=q.includes(`@`)?``:q.split(` `)[0],Y=async e=>{if(e&&s){for(let t of Array.from(e)){B(e=>[...e,{name:t.name,state:`uploading`}]);try{await a.upload(`/api/studio/projects/${s.id}/files?kind=document`,t),B(e=>e.map(e=>e.name===t.name?{...e,state:`done`}:e))}catch{B(e=>e.map(e=>e.name===t.name?{...e,state:`failed`}:e))}}await t.invalidateQueries({queryKey:[`projects`]})}},X=L?[L.about?o(`onboard.readAbout`):``,L.colors?o(`onboard.readColors`,{n:L.colors}):``,L.logo?o(`onboard.readLogo`):``].join(``):``;return(0,x.jsxs)(`div`,{className:`flex min-h-dvh flex-col px-6 text-white sm:px-10`,style:{...w,background:S},children:[(0,x.jsxs)(`header`,{className:`flex items-center justify-between pt-6 sm:pt-8`,children:[(0,x.jsx)(E,{}),(0,x.jsx)(f,{tone:`ground`,ink:C})]}),(0,x.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,x.jsxs)(`div`,{className:`flex flex-col items-center gap-8 max-lg:order-first`,children:[(0,x.jsx)(h,{kind:`drop`,size:240,fluffy:!0,coat:`fur`}),H?(0,x.jsxs)(`figure`,{className:`w-full max-w-sm rounded-[18px] bg-white/15 px-5 py-4`,children:[(0,x.jsx)(`figcaption`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.wish`)}),(0,x.jsx)(`blockquote`,{className:`mt-1.5 line-clamp-6 whitespace-pre-line break-words text-[1rem] leading-relaxed`,children:H}),(0,x.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-white/75`,children:o(`onboard.wishNext`)})]}):null]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 max-w-2xl animate-rise flex-col gap-5`,children:[y===1?(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=j.trim();t?U.mutate(t,{onSuccess:()=>A(2)}):A(2)},children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:J?o(`onboard.kicker1`,{name:J}):o(`onboard.kicker1Anon`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.team`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.teamSub`)}),(0,x.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:o(`onboard.teamPlaceholder`),maxLength:80,"aria-label":o(`onboard.team`),className:T}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{type:`submit`,busy:U.isPending,children:o(`onboard.continue`)}),(0,x.jsx)(k,{step:1})]})]}):null,y===2?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker2`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.site`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.siteSub`)}),F===null?(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault(),N.trim()&&!W.isPending&&W.mutate(N.trim())},children:[(0,x.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),placeholder:o(`onboard.sitePlaceholder`),inputMode:`url`,autoCapitalize:`none`,"aria-label":o(`onboard.site`),className:T}),L?(0,x.jsxs)(`p`,{className:`flex items-center gap-2 text-[0.9375rem] text-(color:--moss)`,children:[(0,x.jsx)(l,{className:`size-4`}),o(`onboard.readDone`,{name:L.name,details:X})]}):W.isError?(0,x.jsx)(`p`,{className:`text-[0.9375rem] text-(color:--rose)`,children:o(`onboard.readFailed`)}):null,(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[L?(0,x.jsx)(D,{onClick:()=>A(3),children:o(`onboard.continue`)}):(0,x.jsx)(D,{type:`submit`,busy:W.isPending,children:W.isPending?o(`onboard.reading`):o(`onboard.read`)}),(0,x.jsx)(O,{onClick:()=>I(``),children:o(`onboard.line`)}),(0,x.jsx)(O,{onClick:()=>A(3),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:2})]})]}):(0,x.jsxs)(`form`,{className:`contents`,onSubmit:e=>{e.preventDefault();let t=F.trim();t?G.mutate(t,{onSuccess:()=>A(3)}):A(3)},children:[(0,x.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:o(`onboard.linePlaceholder`),rows:3,maxLength:8e3,"aria-label":o(`onboard.line`),className:i(T,`resize-none text-[1.125rem] leading-relaxed`)}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{type:`submit`,busy:G.isPending,children:o(`onboard.continue`)}),(0,x.jsx)(O,{onClick:()=>I(null),children:o(`onboard.site`)}),(0,x.jsx)(O,{onClick:()=>A(3),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:2})]})]})]}):null,y===3?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker3`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.know`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.knowSub`)}),(0,x.jsxs)(`button`,{type:`button`,onClick:()=>V.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault(),Y(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,x.jsx)(d,{className:`size-7`}),(0,x.jsx)(`span`,{className:`font-semibold text-[1.0625rem]`,children:o(`onboard.drop`)}),(0,x.jsx)(`span`,{className:`text-[0.875rem] text-white/80`,children:`PDF · Word · Excel · Markdown`}),(0,x.jsx)(`input`,{ref:V,type:`file`,multiple:!0,className:`sr-only`,onChange:e=>{Y(e.target.files),e.target.value=``}})]}),z.length?(0,x.jsx)(`ul`,{className:`flex flex-col gap-2`,children:z.map(e=>(0,x.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,x.jsx)(u,{className:`size-4 shrink-0`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,x.jsx)(`span`,{className:i(`text-white/80`,e.state===`failed`?`text-(color:--rose)`:``),children:e.state===`uploading`?o(`onboard.uploading`):e.state===`done`?o(`onboard.uploaded`):o(`onboard.uploadFailed`)})]},e.name))}):null,(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{busy:z.some(e=>e.state===`uploading`),onClick:()=>A(4),children:o(`onboard.continue`)}),z.length?null:(0,x.jsx)(O,{onClick:()=>A(4),children:o(`onboard.skip`)}),(0,x.jsx)(k,{step:3})]})]}):null,y===4?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`p`,{className:`font-medium text-[0.75rem] text-white/85 uppercase tracking-[0.14em]`,children:o(`onboard.kicker4`)}),(0,x.jsx)(`h1`,{className:`font-display font-bold text-[2.5rem] leading-[1.05] tracking-[-0.02em] sm:text-[3.25rem]`,children:o(`onboard.space`)}),(0,x.jsx)(`p`,{className:`text-[1.0625rem] text-white/90 leading-relaxed`,children:o(`onboard.spaceSub`,{space:s?.name??``})}),(0,x.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[[`partInfo`,`partInfoText`,!!(L||F)],[`partKnow`,`partKnowText`,z.some(e=>e.state===`done`)],[`partData`,`partDataText`,!1],[`partResults`,`partResultsText`,!1]].map(([e,t,n])=>(0,x.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,x.jsxs)(`span`,{className:`flex items-center gap-2 font-semibold text-[1rem]`,children:[n?(0,x.jsx)(l,{className:`size-4 text-(color:--moss)`}):null,o(`onboard.${e}`)]}),(0,x.jsx)(`span`,{className:`text-[0.84375rem] text-white/85 leading-snug`,children:o(`onboard.${t}`)})]},e))}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-5`,children:[(0,x.jsx)(D,{busy:K.isPending,onClick:()=>K.mutate(),children:o(`onboard.build`)}),(0,x.jsx)(k,{step:4})]})]}):null]},y)]}),(0,x.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,x.jsx)(`span`,{children:`engenty`}),(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`size-[3px] bg-(color:--dot)`})]})]})}export{A 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{A as r,An as i,At as a,B as o,Bt as s,C as c,D as l,Dn as u,Dt as d,E as f,F as p,Fn as m,Gr as h,Gt as g,H as _,Ht as v,I as y,In as b,Jn as x,Kn as S,L as C,Lt as w,M as T,Mt as E,N as ee,Nn as D,Nt as O,O as k,Ot as A,P as j,Pt as M,R as N,Rt as P,S as F,T as I,U as L,Un as R,Ut as z,V as te,Vt as B,W as V,Wn as H,Yn as U,Yt as W,Zn as G,_ as K,_r as ne,a as re,b as q,br as J,cr as Y,fr as ie,g as ae,gr as oe,h as se,hr as ce,ir as le,j as ue,jn as de,jt as fe,k as pe,kt as X,nr as Z,ot as me,qn as he,v as ge,vr as _e,w as ve,x as ye,y as be,yr as xe,z as Se,zn as Ce,zt as we}from"./ui-EuR3jezP.js";import{_ as Te,a as Ee,b as De,c as Oe,d as ke,f as Ae,g as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,o as Le,p as Re,s as ze,u as Be,v as Ve,x as He,y as Ue}from"./RunDrawer-9nMGhbSm.js";import{t as We}from"./phone-3fG1okFs.js";import{n as Ge,r as Ke,t as qe}from"./ReadOnly-B9xaq_M3.js";import{t as Je}from"./upload-BsMUhEfX.js";import{Ct as Ye,G as Xe,Ht as Ze,Lt as Qe,Mt as $e,Ot as et,Rt as tt,Tt as nt,Wt as rt,Zt as it,_ as at,b as ot,bt as st,c as ct,ct as lt,et as ut,g as dt,h as ft,kt as pt,m as mt,ot as ht,p as gt,s as _t,st as vt,u as yt,v as bt,y as xt}from"./index-DQ9qAB4v.js";import{a as St,c as Ct,f as wt,i as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At,u as jt}from"./settings-menu-D9fbi1Z0.js";import{t as Mt}from"./RunnerView-NSSP3tc6.js";var Nt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Nt.node;var Pt=Y(Nt),Ft={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`}]]};Ft.node;var It=Y(Ft),Lt={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`}]]};Lt.node;var Rt=Y(Lt),zt={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`}]]};zt.node;var Bt=Y(zt),Vt={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`]};Vt.node;var Ht=Y(Vt),Ut={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`]};Ut.node;var Wt=Y(Ut),Gt={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`}]]};Gt.node;var Kt=Y(Gt),qt={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`}]]};qt.node;var Jt=Y(qt),Yt={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`}]]};Yt.node;var Xt=Y(Yt),Zt={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`}]]};Zt.node;var Qt=Y(Zt),$t=xe(),Q=e(t(),1),$=e(n(),1),en={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function tn({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 o=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:W(o?`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 nn(e,t){confirm(W(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function rn({projectId:e,file:t,small:n}){let r=Se(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:z(`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)(an,{src:r,small:n});let a=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)(Qt,{className:a}):t.mime===`application/pdf`?(0,$.jsx)(he,{className:a}):t.mime===`application/json`?(0,$.jsx)(i,{className:a}):t.mime.startsWith(`model/`)?(0,$.jsx)(It,{className:a}):(0,$.jsx)(S,{className:a}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function an({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:z(`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 on=`application/x-wizards-logo`;function sn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:d,onRemove:f}){let p=e=>f?f(e):nn(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(on,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===c?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(X,{tone:`ember`,children:W(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?en:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${W(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(rn,{projectId:e,file:n})}):(0,$.jsx)(rn,{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:[s?(0,$.jsx)(E,{label:W(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(rt,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(E,{label:W(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(nt,{className:`size-4`})}):null,d&&!r.readOnly?(0,$.jsx)(q,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(u,{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)(tn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(ge,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(P,{className:`size-5`}):(0,$.jsx)(m,{className:`size-5`}),a]}):null]})}function cn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),g=async()=>{c(!0),u(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])):u(W(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){u(e.message)}c(!1)},_=async()=>{c(!0),u(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){u(e.message)}c(!1),e.length&&n(e),e.length===m.length&&r()};return(0,$.jsx)(a,{open:!0,onClose:r,wide:f?!0:void 0,title:W(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:W(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:z(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:en,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:z(`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)(Z,{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)(d,{variant:`ghost`,onClick:()=>p(null),children:W(`run.back`)}),(0,$.jsx)(d,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?W(`project.addMany`,{n:m.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(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)(d,{variant:`ghost`,onClick:r,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:s,disabled:!i.trim(),children:W(`run.next`)})]})]})})}function ln(e,t,n){return J({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>V.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function un(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var dn=e=>[un(e),e.pages?W(`project.pages`,{n:e.pages}):null,N(e.size)].filter(Boolean).join(` · `),fn=2e5;function pn({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=h(),a=L(e),o=Fe(e),s=te(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[d,f]=(0,Q.useState)(null);if(!c)return a.isLoading?(0,$.jsx)(P,{className:`mx-auto text-ink-3`}):null;let p=d??(l?`original`:`text`),m=o.data?.items.find(e=>e.key===`f:${c.id}`),g=Se(e,c.id),_=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:z(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===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:c.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:dn(c)}),(0,$.jsx)(`a`,{href:g,target:`_blank`,rel:`noreferrer`,"aria-label":W(`project.openOriginal`),title:W(`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)(x,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{label:W(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(D,{className:`size-4`})}),(0,$.jsx)(E,{label:W(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(W(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Ae,{projectId:e,itemKey:`f:${c.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(tn,{file:c,actions:s})}),c.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,$.jsxs)(A,{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:[l?_(`original`,W(`project.original`)):null,_(`text`,W(`project.readText`))]}),p===`original`?c.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:g,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:g,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(mn,{projectId:e,file:c})]})]})}function mn({projectId:e,file:t}){let n=ln(e,t,fn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(P,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{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:W(`project.textCut`,{shown:n.data.text.length.toLocaleString(g),total:n.data.chars.toLocaleString(g)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:W(`project.noText`)})}var hn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,gn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),N(e.size)].filter(Boolean).join(` · `);function _n({projectId:e,file:t,actions:n,onClose:r}){let i=Se(e,t.id);return(0,$.jsxs)(a,{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:gn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":W(`project.openOriginal`),title:W(`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)(x,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:en,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)(tn,{file:t,actions:n})})]})}function vn({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":`${W(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(rn,{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:gn(t)})]}),(0,$.jsx)(tn,{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)(E,{label:W(`project.preview`),onClick:i,children:(0,$.jsx)(rt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(q,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]})]})}function yn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,o]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(a,{open:!0,onClose:r,title:W(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)(M,{children:W(`project.assetSectionName`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,maxLength:80,placeholder:W(`project.assetSectionTitle`),onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(d,{variant:`danger`,onClick:n,children:W(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(d,{variant:`ghost`,onClick:r,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,disabled:!i.trim(),children:W(e?`settings.save`:`project.add`)})]})]})})}function bn({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=te(e,n),[s,l]=_(`assets`,`cards`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(r),[g,v]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),w=(0,Q.useRef)(null),ee=o({assetSections:m},i),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(m.flatMap(e=>e.assets)),A=m.find(e=>e.id===g)??null,j=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),M=D.find(e=>e.id===f),N=u.trim().toLowerCase(),L=N?j.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(N)):j,R=(e,t)=>h(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),z=async e=>{let t=A?.id??null;for(let n of await a.upload(`asset`,e))R(n.id,t)},V=e=>{confirm(W(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),R(e.id,null))},H=m.length?{options:[{value:``,label:W(`project.assetsGeneral`)},...m.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],current:e=>m.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>R(e.id,t||null)}:void 0,U=[{label:W(`project.assetUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>w.current?.click()},{label:W(`project.assetFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>C(!0)},...m.length<T.logoSections?[{label:W(`project.assetSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>x(`new`)}]:[]],G=m.length||D.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)(B,{value:g,onChange:e=>{v(e),d(``)},label:W(`project.assets`),options:[{id:``,label:W(`project.assetsGeneral`)},...m.map(e=>({id:e.id,label:e.title||W(`project.sectionUntitled`)}))]}):null,A&&!n?(0,$.jsx)(E,{label:W(`project.assetSectionRename`),onClick:()=>x(`current`),children:(0,$.jsx)(b,{className:`size-4`})}):null]}),j.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(F,{value:u,onChange:d,placeholder:W(`project.assetSearch`)})}),(0,$.jsx)(E,{label:W(s===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:s===`list`?(0,$.jsx)(Kt,{className:`size-4`}):(0,$.jsx)(Xt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(c,{title:W(`project.assets`),hint:W(`project.assetsHint`),save:ee,tabs:G,action:n?null:(0,$.jsx)(se,{entries:U}),children:[(0,$.jsx)(`input`,{ref:w,type:`file`,multiple:!0,accept:hn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&z(t)}}),L.length?s===`cards`?(0,$.jsx)(sn,{projectId:e,kind:`asset`,files:L,actions:a,moveTo:H,onRemove:V,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:L.map(t=>(0,$.jsx)(vn,{projectId:e,file:t,actions:a,moveTo:H,onPreview:()=>p(t.id),onRemove:()=>V(t)},t.id))}):j.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.staysLocal`)}):(0,$.jsxs)(ge,{accept:hn,onFiles:e=>void z(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(P,{className:`size-4`}):(0,$.jsx)(Je,{className:`size-4`}),W(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:W(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,M?(0,$.jsx)(_n,{projectId:e,file:M,actions:a,onClose:()=>p(null)}):null,y?(0,$.jsx)(yn,{section:y===`current`?A:null,onClose:()=>x(null),onSave:e=>{if(y===`current`&&A)h(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=I();h(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&A?()=>{(!A.assets.length||confirm(W(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(h(e=>e.filter(e=>e.id!==A.id)),v(``),x(null))}:void 0}):null,S?(0,$.jsx)(cn,{kind:`asset`,onClose:()=>C(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)R(t.id,A?.id??null)}}):null]})}var xn=/^#[0-9a-fA-F]{6}$/;async function Sn(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 Cn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function wn({projectId:e,gradient:t,isNew:n,brand:r,onSave:o,onClose:s}){let[c,l]=(0,Q.useState)(t),[f,h]=(0,Q.useState)(p(t)),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(null),[T,ee]=(0,Q.useState)(!n),D=e=>{l(e),h(p(e)),_(!1)},k=(e,t)=>D({...c,stops:c.stops.map((n,r)=>r===e?{...n,...t}:n)}),A=e=>{let t=[...c.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));D({...c,stops:[...c.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},j=async()=>{x(!0),w(null);try{let{gradient:t}=await V.post(`/api/studio/projects/${e}/gradients/describe`,{text:v.trim(),...T?{gradient:{name:c.name,type:c.type,angle:c.angle,stops:c.stops}}:{}});D({...c,...t,name:c.name.trim()?c.name:t.name}),y(``),ee(!0)}catch(e){w(e.message)}x(!1)};return(0,$.jsx)(a,{open:!0,onClose:s,wide:!0,title:W(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v.trim()&&!b&&j()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(O,{"data-autofocus":n||void 0,value:v,maxLength:1e3,"aria-label":W(`project.gradientDescribe`),placeholder:W(T?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>y(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(d,{type:`submit`,variant:`secondary`,busy:b,disabled:!v.trim(),children:[(0,$.jsx)(i,{className:`size-4`}),W(T?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:z(`mt-1.5 text-[0.8125rem]`,S?`text-rose`:`text-ink-3`),children:S??W(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:p(c)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientName`)}),(0,$.jsx)(O,{value:c.name,maxLength:80,placeholder:W(`project.gradientNamePlaceholder`),onChange:e=>l({...c,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.fillUseLabel`)}),(0,$.jsx)(O,{value:c.description??``,maxLength:400,placeholder:W(`project.gradientUse`),onChange:e=>l({...c,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:ue.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":c.type===e,onClick:()=>D({...c,type:e}),className:z(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,c.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:W(Cn[e])},e))})]}),c.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(M,{children:W(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:c.angle,"aria-label":W(`project.gradientAngle`),onChange:e=>D({...c,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(c.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(we,{value:xn.test(e.color)?e.color:`#888888`,onChange:e=>k(t,{color:e.target.value})}),(0,$.jsx)(O,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();xn.test(n)&&k(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":W(`project.gradientAt`),onChange:e=>k(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)(E,{label:W(`project.remove`),disabled:c.stops.length<=2,onClick:()=>D({...c,stops:c.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[c.stops.length<12?(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>A(),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.gradientStopAdd`)]}):null,r.length&&c.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:W(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>A(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)(M,{children:`CSS`}),(0,$.jsx)(O,{value:f,spellCheck:!1,onChange:e=>{h(e.target.value);let t=C(e.target.value);_(!t),t&&l({...c,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:z(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:W(g?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:s,children:W(`common.cancel`)}),(0,$.jsx)(d,{onClick:()=>{o(c),s()},children:W(`settings.save`)})]})]})})}var Tn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,En=`size-8 bg-card shadow-soft hover:bg-card`;function Dn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(be,{value:e,label:W(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(be,{value:n??``,label:W(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function On({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=p(e),[o,s]=(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,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":W(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(E,{label:W(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:En,children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(E,{label:W(`project.download`),onClick:()=>void Sn(e,e.name),className:En,children:(0,$.jsx)(U,{className:`size-4`})}),t?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:i,className:z(En,`hover:text-rose`),children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:e.name,namePlaceholder:W(`project.gradientName`),description:e.description,usePlaceholder:W(`project.gradientUse`),readOnly:t,onChange:r})]})}function kn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function An({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=Se(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,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":W(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:kn(s,t.tile)}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":W(`project.download`),title:W(`project.download`),className:z(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,En),children:(0,$.jsx)(U,{className:`size-4`})}),r?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:o,className:z(En,`hover:text-rose`),children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:W(`project.patternUse`),readOnly:r,onChange:a})]})}function jn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:o,upload:s,removeFile:c,onSave:l,onClose:u}){let[f,p]=(0,Q.useState)(t),[m,h]=(0,Q.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)c(e);u()};return(0,$.jsx)(a,{open:!0,onClose:_,wide:!0,title:W(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:kn(Se(e,f.file),f.tile),children:(0,$.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(P,{className:`size-4`}):(0,$.jsx)(H,{className:`size-4`}),W(`project.patternReplace`)]})}):(0,$.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(P,{className:`size-5`}):(0,$.jsx)(H,{className:`size-5`}),W(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.patternName`)}),(0,$.jsx)(O,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):W(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.fillUseLabel`)}),(0,$.jsx)(O,{value:f.description??``,maxLength:400,placeholder:W(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.patternShow`)}),(0,$.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:z(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:W(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,$.jsx)(d,{variant:`ghost`,onClick:_,children:W(`common.cancel`)}),(0,$.jsx)(d,{disabled:!f.file||i,onClick:()=>{for(let e of m.filter(e=>e!==f.file))c(e);t.file&&t.file!==f.file&&c(t.file),l({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),u()},children:W(n?`project.add`:`settings.save`)})]})]})})}var Mn=/^#[0-9a-fA-F]{6}$/;function Nn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{colors:t}=await V.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):l(W(`project.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(a,{open:!0,onClose:n,wide:u?!0:void 0,title:W(u?`project.colorsFound`:`project.colorsFromUrl`),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:W(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:u.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:z(`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)(Z,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:()=>f(null),children:W(`run.back`)}),(0,$.jsx)(d,{disabled:!p.length,onClick:()=>{t(u.filter(e=>p.includes(e.value))),n()},children:p.length>1?W(`project.addMany`,{n:p.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{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:W(`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)(d,{variant:`ghost`,onClick:n,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:o,disabled:!r.trim(),children:W(`run.next`)})]})]})})}function Pn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:s,sectioned:l,ruled:d,save:p,readOnly:h}){let[g,_]=(0,Q.useState)(()=>n.map(e=>({...e,id:I()}))),[v,y]=(0,Q.useState)(r),[b,x]=(0,Q.useState)(i),[S,C]=(0,Q.useState)(a),[w,ee]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(null),A=te(e,h),j=f(s),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),z=o({colors:g.filter(e=>Mn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:v,gradients:b,patterns:S,colorRules:j.rules},p),B=l?v:[],V=B.filter(e=>(e.kind??`colors`)===`colors`),H=e=>V.some(t=>t.id===e.section),U=g.filter(e=>!H(e)),G=(U[0]??g[0])?.id,K=(e,t)=>_(n=>n.map(n=>n.id===e?{...n,...t}:n)),ne=e=>_(t=>[...t,...e.map(e=>({...e,id:I()}))].slice(0,T.colors)),re=[{value:``,label:W(`project.sectionStandard`)},...V.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],J=(e,t)=>{let n=I();N(n),y(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},Y=e=>({id:I(),name:``,section:e,type:`linear`,angle:90,stops:[{color:g[0]?.value&&Mn.test(g[0].value)?g[0].value:`#4b73ff`,at:0},{color:g[1]?.value&&Mn.test(g[1].value)?g[1].value:`#ff6d1b`,at:100}]}),ie=e=>t.files.find(t=>t.id===e)?.name??`pattern`,oe=[...g.length<T.colors?[{label:W(`project.colorNew`),icon:(0,$.jsx)(m,{className:`size-4 shrink-0`}),onPick:()=>ue()},{label:W(`project.colorsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>R(!0)}]:[],...l&&v.length<T.logoSections?[{label:W(`project.colorSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>J(`colors`,``)},{label:W(`project.gradientSectionAdd`),icon:(0,$.jsx)(Pt,{className:`size-4 shrink-0`}),onPick:()=>J(`gradients`,W(`project.gradientSectionTitle`))},{label:W(`project.patternSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>J(`patterns`,W(`project.patternSectionTitle`))}]:[],...!d||j.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>j.add()}]],ce=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(we,{value:Mn.test(e.value)?e.value:`#888888`,onChange:t=>K(e.id,{value:t.target.value})}),(0,$.jsx)(O,{value:e.name,autoFocus:e.id===P,placeholder:W(`project.colorName`),maxLength:120,onChange:t=>K(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(O,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>K(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===G?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(X,{tone:`ember`,children:W(`project.colorAccent`)})}):h?null:(0,$.jsx)(E,{label:W(`project.colorFirst`),onClick:()=>_(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)(le,{className:`size-4`})}),h||!V.length?null:(0,$.jsx)(q,{options:re,value:H(e)?e.section??``:``,onChange:t=>K(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),h?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>_(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)(u,{className:`size-4`})})]})]},e.id),ue=e=>{let t=I();F(t),_(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(c,{title:W(`project.colors`),hint:W(`project.colorsHint`),save:z,locked:h,action:h?null:(0,$.jsx)(se,{entries:oe}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[U.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:U.map(ce)}),h?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.colorUse`)})]}):g.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.colorsEmpty`)}),B.map(t=>{let n=t.kind??`colors`,r=g.filter(e=>e.section===t.id),i=b.filter(e=>e.section===t.id),a=S.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(ve,{title:t.title,titlePlaceholder:W(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Pt,{}),label:W(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Ht,{}),label:W(`project.kindPatterns`)}:{icon:(0,$.jsx)($e,{}),label:W(`project.kindColors`)},autoFocus:M===t.id,readOnly:h,onChange:e=>y(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(W(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||W(`project.sectionUntitled`)}))){y(e=>e.filter(e=>e.id!==t.id)),_(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),x(e=>e.filter(e=>e.section!==t.id));for(let e of a)A.remove(e.file);C(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(On,{gradient:e,readOnly:h,onEdit:()=>ee(e),onChange:t=>x(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>x(t=>t.filter(t=>t.id!==e.id))},e.id)),h||b.length>=T.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(Y(t.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)(m,{className:`size-5`}),W(`project.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(An,{projectId:e,pattern:t,fileName:ie(t.file),readOnly:h,onEdit:()=>k(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{A.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),h||S.length>=T.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k({id:I(),name:``,section:t.id,file:``}),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)(m,{className:`size-5`}),W(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ce),h||g.length>=T.colors?null:(0,$.jsx)(ae,{label:W(`project.colorAdd`),onClick:()=>ue(t.id)})]})]},t.id)}),d?(0,$.jsx)(ye,{rules:j,placeholder:W(`project.colorRulePlaceholder`),readOnly:h}):null]}),A.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:A.error}):null,w?(0,$.jsx)(wn,{projectId:e,gradient:w,isNew:!b.some(e=>e.id===w.id),brand:g.filter(e=>Mn.test(e.value)),onClose:()=>ee(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,D?(0,$.jsx)(jn,{projectId:e,pattern:D,isNew:!S.some(e=>e.id===D.id),fileName:ie,busy:A.busy,error:A.error,upload:async e=>(await A.upload(`pattern`,[e]))[0]??null,removeFile:e=>void A.remove(e),onClose:()=>k(null),onSave:e=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,L?(0,$.jsx)(Nn,{projectId:e,onClose:()=>R(!1),onAdd:ne}):null]})}var Fn=e=>/^(ja|yes|true)$/i.test(e.trim()),In={text:Ye,longtext:Ke,number:De,date:He,url:R,email:Qe,phone:We,boolean:Ue};function Ln({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.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 c=In[e??t],l=`${W(`project.factType`)}: ${W(`project.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:z(`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)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:z(`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:u,onClick:()=>d(void 0),children:[(0,$.jsx)(st,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:W(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:W(`project.type.${t}`)}),(0,$.jsx)(Z,{className:z(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),k.map(t=>{let n=In[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:W(`project.type.${t}`)}),(0,$.jsx)(Z,{className:z(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Rn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,f]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),p=o(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),h=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),g=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};f(e=>n?[o,...e]:[...e,o])},_=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},y=l.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(c,{title:W(`project.facts`),hint:W(`project.factsHint`),save:p,locked:n,action:a.length<T.facts&&!n?(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>g({},`label`,!0),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=ee(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)(O,{ref:_(`${e.id}:label`),value:e.label,placeholder:W(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>h(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&h(e.id,{key:j(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)(s,{checked:Fn(e.value),label:e.label,onChange:t=>h(e.id,{value:W(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Fn(e.value)?W(`project.yes`):W(`project.no`)})]}):(0,$.jsx)(v,{ref:_(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:W(`project.factValue`),onChange:t=>h(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Ln,{type:e.type,detected:t,onChange:t=>h(e.id,{type:t})}),n?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>f(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]},e.id)})}),a.length<T.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>g({},`label`),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.factAdd`)]}),y.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g({key:e,label:W(`fact.${e}`)},`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)(m,{className:`size-3.5`}),` `,W(`fact.${e}`)]},e))]}):null]})}function zn({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(on);i(!1),n&&(t.preventDefault(),e(n))},className:z(`-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 Bn({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:s,save:l}){let u=te(e,n),[d,p]=(0,Q.useState)(r),m=f(i),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=o({logoSections:d,logoRules:m.rules},l),S=t.files.filter(e=>e.kind===`logo`),C=new Map(S.map(e=>[e.id,e])),w=a?d:[],E=new Set(w.flatMap(e=>e.logos)),ee=S.filter(e=>!E.has(e.id)),D=y(S,d)?.id,O=(e,t)=>p(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),k=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),A=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)O(e.id,t)},j=w.length?{options:[{value:``,label:W(`project.sectionStandard`)},...w.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],current:e=>w.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>O(e.id,t||null)}:void 0,M=(t,n,r)=>(0,$.jsx)(sn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?W(`project.logoAdd`):void 0,onUpload:e=>void A(e,n),mainId:D,onMakeMain:e=>{O(e.id,null),u.order(`logo`,[e.id,...S.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:j,onRemove:e=>{confirm(W(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),O(e.id,null))}}),N=n?void 0:e=>t=>O(t,e),P=[{label:W(`project.logoUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>b.current?.click()},{label:W(`project.logoFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...a&&d.length<T.logoSections?[{label:W(`project.logoSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>{let e=I();g(e),p(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!s||m.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,$.jsxs)(c,{title:W(`project.logos`),hint:W(`project.logosHint`),save:x,action:n?null:(0,$.jsx)(se,{entries:P}),children:[(0,$.jsx)(`input`,{ref:b,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&&A(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(zn,{onLogo:N?.(null),children:M(ee,null,!0)}),w.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(zn,{onLogo:N?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(ve,{title:e.title,description:e.description,titlePlaceholder:W(`project.logoSectionTitle`),descriptionPlaceholder:W(`project.logoSectionUse`),autoFocus:h===e.id,readOnly:n,onChange:t=>k(e.id,t),onRemove:()=>{(!e.logos.length||confirm(W(`project.logoSectionRemoveConfirm`,{name:e.title||W(`project.sectionUntitled`)})))&&p(t=>t.filter(t=>t.id!==e.id))}}),M(e.logos.map(e=>C.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),s?(0,$.jsx)(ye,{rules:m,placeholder:W(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,$.jsx)(cn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)O(t.id,null)}}):null]})}var Vn=new Set;function Hn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Vn.has(t))return;Vn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${r.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Un=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Wn({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 Gn=`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`,Kn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function qn({font:e,first:t,readOnly:n,autoFocus:i,onChange:a,onRemove:o}){return Hn(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:Un(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)(be,{value:e.family,label:W(`project.fontFamily`),placeholder:W(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(be,{value:e.role,label:W(`project.fontRole`),placeholder:W(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>a({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:Un(e.family),fontWeight:t},className:z(`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)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(be,{value:e.license??``,label:W(`project.fontLicense`),placeholder:W(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:W(`project.fontUses`)}),pe.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):pe.filter(n=>n===t||e.uses?.includes(n));a({uses:n.length?n:void 0})},className:z(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(Z,{className:`size-3.5`}):null,W(Kn[t])]},t)})]})]}),n?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:o,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)(u,{className:`size-4`})})]})}function Jn({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:Un(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:[i?(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)(be,{value:e.name,label:W(`project.styleName`),placeholder:W(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":W(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:z(Gn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||W(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":W(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:Gn,children:[...new Set([...r,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Wn,{unit:`px`,label:W(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,$.jsx)(Wn,{unit:W(`project.styleLine`),label:W(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Wn,{unit:W(`project.styleTracking`),label:W(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:W(`project.styleUpper`),"aria-label":W(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:z(`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)(Rt,{className:`size-4`})})]}),i?null:(0,$.jsx)(E,{label:W(`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)(u,{className:`size-4`})})]})]})}function Yn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{fonts:t}=await V.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(f(t),m(t.slice(0,2).map(e=>e.family))):l(W(`project.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(a,{open:!0,onClose:n,wide:u?!0:void 0,title:W(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:W(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(Xn,{font:e,on:p.includes(e.family),onToggle:()=>m(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)(d,{variant:`ghost`,onClick:()=>f(null),children:W(`run.back`)}),(0,$.jsx)(d,{disabled:!p.length,onClick:()=>{t(u.filter(e=>p.includes(e.family))),n()},children:p.length>1?W(`project.addMany`,{n:p.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{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:W(`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)(d,{variant:`ghost`,onClick:n,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:o,disabled:!r.trim(),children:W(`run.next`)})]})]})})}function Xn({font:e,on:t,onToggle:n}){return Hn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:z(`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:Un(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(` · `):W(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(Z,{className:`size-3.5`})}):null]})}function Zn({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:s,readOnly:l}){let[u,d]=(0,Q.useState)(t),[p,h]=(0,Q.useState)(n),g=f(r),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=o({fonts:u,textStyles:p,typeRules:g.rules},s),S=(e,t=!1)=>{let n=e.map(e=>({id:I(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&v(n[0].id),d(e=>[...e,...n].slice(0,T.fonts))},C=()=>{let e=I();v(e),h(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},w=[...u.length<T.fonts?[{label:W(`project.fontNew`),icon:(0,$.jsx)(m,{className:`size-4 shrink-0`}),onPick:()=>S([{family:``,weights:[400,700]}],!0)},{label:W(`project.fontsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>b(!0)}]:[],...p.length<T.textStyles?[{label:W(`project.styleNew`),icon:(0,$.jsx)(et,{className:`size-4 shrink-0`}),onPick:C}]:[],...!i||g.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>g.add()}]];return(0,$.jsxs)(c,{title:W(`project.typography`),hint:W(`project.typographyHint`),save:x,action:l?null:(0,$.jsx)(se,{entries:w}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((e,t)=>(0,$.jsx)(qn,{font:e,first:t===0,readOnly:l,autoFocus:_===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))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.fontsEmpty`)}),p.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:W(`project.styles`)}),l?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:W(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:p.map(e=>(0,$.jsx)(Jn,{style:e,fonts:u,sample:a,readOnly:l,autoFocus:_===e.id,onChange:t=>h(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>h(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(ye,{rules:g,placeholder:W(`project.typeRulePlaceholder`),readOnly:l}):null]}),y?(0,$.jsx)(Yn,{projectId:e,onClose:()=>b(!1),onAdd:e=>S(e)}):null]})}function Qn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),s=o({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(c,{title:W(`project.base`),hint:W(`project.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.title`)}),(0,$.jsx)(O,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.about`)}),(0,$.jsx)(v,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.aboutHint`)})]})]})})}function $n({project:e,group:t,children:n}){let r=h(),i=L(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await V.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},f=it({mutationFn:()=>V.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),p=lt(),m=vt(),g=i.data??{files:[],embeddings:!0},_=`${e.id}:${o}`,v=e.readOnly,y=t===`knowledge`,b=ut(`brandSections`),x=ut(`brandRules`),S=ut(`typography`);return Xe(v?{}:{title:W(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:W(y?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:W(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:W(`assistant.suggest.knowledgeHow`)},{label:W(`assistant.suggest.knowledgeSite`),fill:!0},{label:W(`assistant.suggest.knowledgeCategories`)}]:[{label:W(`assistant.suggest.readSite`),fill:!0},{label:W(`assistant.suggest.missing`)},{label:W(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,$.jsx)(qe,{children:Ge(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{id:`base`,children:(0,$.jsx)(Qn,{project:e,save:u},`base:${_}`)}),(0,$.jsx)(K,{id:`facts`,children:(0,$.jsx)(Rn,{facts:e.facts,save:e=>u({facts:e}),readOnly:v},`facts:${_}`)}),(0,$.jsx)(K,{id:`logos`,children:(0,$.jsx)(Bn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>u({brand:e})},`logos:${_}`)}),(0,$.jsx)(K,{id:`colors`,children:(0,$.jsx)(Pn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>u({brand:e}),readOnly:v},`colors:${_}`)}),S?(0,$.jsx)(K,{id:`typography`,children:(0,$.jsx)(Zn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||W(`project.typeSample`),save:e=>u({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,$.jsx)(K,{id:`assets`,children:(0,$.jsx)(bn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${_}`)})]}):null,n,t===`info`&&p&&!v&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(d,{variant:`danger`,onClick:()=>l(!0),children:W(`settings.delete`)}),(0,$.jsxs)(a,{open:c,onClose:()=>l(!1),title:W(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:W(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:()=>l(!1),children:W(`common.cancel`)}),(0,$.jsx)(d,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:W(`common.delete`)})]})]})]}):null]})}var er={q:``,mode:``,days:0};function tr(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 i=r.toString();return J({queryKey:[`results`,e,i],queryFn:()=>V.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function nr({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)(de,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(O,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:W(`space.resultsSearch`),"aria-label":W(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(w,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:W(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(w,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:W(`space.resultsAnyTime`)},{value:`1`,label:W(`space.resultsDay`)},{value:`7`,label:W(`space.resultsDays`,{n:7})},{value:`30`,label:W(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function rr({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(g,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(c,{title:t?o(t):W(`space.resultsAll`),hint:W(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(nr,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(A,{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?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,W(`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:W(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(Ce,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(X,{children:W(`run.testChip`)}):(0,$.jsxs)(X,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(A,{children:(0,$.jsx)(fe,{children:n.q.trim()||n.mode||n.days?W(`space.resultsNone`):W(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(Ie,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(X,{children:W(`run.testChip`)}):(0,$.jsxs)(X,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(Mt,{runId:i.id,compact:!0},i.id)}):null]})}function ir({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(e.name),s=it({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{label:W(`project.rename`),onClick:()=>{o(e.name),r(!0)},children:(0,$.jsx)(b,{className:`size-4`})}),(0,$.jsx)(a,{open:n,onClose:()=>r(!1),title:W(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&s.mutate()},children:[(0,$.jsx)(O,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>o(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)(d,{variant:`ghost`,onClick:()=>r(!1),children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:s.isPending,disabled:!i.trim(),children:W(`settings.save`)})]})]})})]})}function ar({project:e}){let t=h();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ot,{}),e.readOnly?null:(0,$.jsx)(ir,{project:e,save:async n=>{await V.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function or(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=gt(),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 sr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function cr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(St,{icon:e.icon??pt,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Tt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function lr(){let{group:e}=ne(),[t,n]=_e(),r=oe(),i=ce(),{hash:a}=i,{project:o,loading:s}=ht(),l=lt(),u=yt(),d=jt(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=dt(e)?e:void 0,y=v?void 0:u.spaceParts.find(t=>t.id===e),b=v??y?.id,x=i.state?.parts===!0,S=xt(bt(),u).map(e=>({...e,to:`/space/${e.id}`})),C=S.find(e=>e.id===b),w=t.get(`show`),T=b?w?2:1:0,E=d?Math.min(T,1):b&&g!==b&&!x?1:0,ee=wt(E),D=wt(T),O=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),k=o?o.brand.name?.trim()||o.name:W(`nav.project`),A=re(),j=!!A&&!d,M=ut(`typography`)?[]:[`typography`],N=y?u.spaceMenus[y.id]??[]:[],P=y?[{plugin:null,label:null,sections:N}]:v&&v!==`results`?at(v,u,M):[],F=v?at(v,u).filter(e=>e.plugin):[],I=or([...P,...v===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),L=v===`results`&&w&&w!==`all`?w:null,[R,te]=(0,Q.useState)(er),B=tr(v===`results`?o?.id:void 0,L,R),V=B.data?.wizards.find(e=>e.id===L)?.title,H=v===`data`&&w&&w!==`all`||v===`knowledge`&&w&&/^[ptfcvs]:/.test(w)?w:null,U=H?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===H.slice(2)):void 0,G=v===`knowledge`&&H&&/^[ptf]:/.test(H)?H:null,q=Oe(v===`data`?o?.id:void 0),J=Fe(v===`knowledge`?o?.id:void 0),Y=Ve(H?.startsWith(`v:`)?H.slice(2):``),ae=J.data?.categories.find(e=>e.id===(H?.startsWith(`c:`)?H.slice(2):Y.data?.category.id)),se=v===`knowledge`?U?U.label():H?.startsWith(`v:`)?Y.data&&`${Y.data.category.name}: ${Y.data.value}`:H?.startsWith(`c:`)?ae?.name:J.data?.items.find(e=>e.key===H)?.title:q.data?ze(q.data).flatMap(e=>e.items).find(e=>e.key===H)?.title:void 0;mt([{label:W(`nav.project`),to:`/space`},...C?[{label:C.label,to:`/space/${C.id}`}]:[],...C&&(m??V??se)?[{label:m??V??se}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Xe({...v===`data`||v===`results`?{compact:!0}:{},...v===`data`?{suggestions:[{label:W(`assistant.suggest.dataWhat`)},{label:W(`assistant.suggest.dataWho`)},{label:W(`assistant.suggest.dataEdit`)}]}:v===`results`?{suggestions:[{label:W(`assistant.suggest.resultsFailed`)},{label:W(`assistant.suggest.resultsCost`)},{label:W(`assistant.suggest.resultsShare`)}]}:{},...H&&se?{open:{kind:le[H[0]]??`item`,id:H.slice(2),label:se}}:L&&V?{open:{kind:`wizard`,id:L,label:V}}:{}});let ue=v===`results`||v===`data`||H?a.slice(1):w||a.slice(1),de=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${b}#${ue}`;ue&&de.current!==e&&document.getElementById(ue)&&(de.current=e,requestAnimationFrame(()=>sr(ue,!1)))},[b,ue,o?.id,u.spaceSections,N.length]),!b){let t=a.slice(1),n=t?ft(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(ie,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(ie,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(ie,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(v===`knowledge`&&!w&&u.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(ie,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let pe=e=>{if(d){r({search:`?show=${e}`});return}de.current=`${b}#${e}`,sr(e,!0),r({search:``,hash:e},{replace:!0})},X=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Z=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(K,{id:e.id,children:(0,$.jsx)(c,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(_t,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),me=d?void 0:I,he=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{title:k,open:E===1?C??null:null,onBack:()=>d?r(`/space`):_(b??null),root:{icon:Ze,label:W(`nav.project`),backLabel:W(`nav.wizards`),onBack:()=>r(`/`)}}),(0,$.jsx)(`div`,{className:z(Ct(ee)),children:E===0?(0,$.jsx)(Ot,{entries:S,current:d?void 0:C,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},E)]});return(0,$.jsxs)(Dt.Provider,{value:O,children:[j&&A?(0,$t.createPortal)(he,A):null,(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:z(`grid gap-6`,!j&&`md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[j?null:(0,$.jsx)(`aside`,{className:z(`min-w-0 md:sticky md:top-6 md:self-start`,d&&T===2&&`hidden`,d&&D===`back`&&Ct(`back`)),children:he}),b?(0,$.jsxs)(`div`,{className:z(`min-w-0`,d&&T<2&&`hidden`,d&&D===`deeper`&&Ct(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(At,{label:C?.label??k,onBack:()=>r(`/space/${b}`)})}):null,l&&o?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(ar,{project:o})}):null,v===`results`?(0,$.jsxs)(kt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(St,{icon:Wt,label:W(`space.resultsAll`),selected:!d&&!L,onPick:()=>X(`all`)}),B.data?.wizards.filter(e=>e.results||e.id===L).map(e=>(0,$.jsx)(St,{icon:st,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===L,onPick:()=>X(e.id)},e.id))]}),(0,$.jsx)(cr,{groups:F,current:me,onPick:pe})]}):v===`data`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:W(`data.all`),selected:!d&&!H,onPick:()=>X(`all`)})}),q.data?ze(q.data).map(e=>(0,$.jsx)(Tt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(St,{icon:Ee[e.kind],label:e.title,selected:!d&&e.key===H,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(cr,{groups:F,current:me,onPick:pe})]}):v===`knowledge`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:W(`know.all`),selected:!(d||H),onPick:()=>X(`all`)})}),J.data?.categories.length?(0,$.jsx)(Tt,{label:W(`know.categories`),children:J.data.categories.map(e=>(0,$.jsx)(St,{icon:Me[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(H===`c:${e.id}`||Y.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(cr,{groups:F,current:d?void 0:U?.id,onPick:e=>X(`s:${e}`)})]}):(0,$.jsx)(kt,{children:(0,$.jsx)(cr,{groups:P,current:me,onPick:pe})}),o&&(v===`info`||v===`knowledge`)?(0,$.jsxs)($n,{project:o,group:v,children:[v===`knowledge`?G?G.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:G.slice(2),onGone:()=>X(`all`),onOpen:X},G):G.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:G.slice(2),onGone:()=>X(`all`)},G):(0,$.jsx)(pn,{projectId:o.id,fileId:G.slice(2),readOnly:o.readOnly,onGone:()=>X(`all`)},G):J.data?U?(0,$.jsx)(c,{title:U.label(),hint:U.hint?.(),plain:!0,children:(0,$.jsx)(_t,{of:U,children:(0,$.jsx)(U.component,{})})},H):H?.startsWith(`c:`)?ae?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(je,{projectId:o.id,category:ae,readOnly:o.readOnly,onOpen:X,onGone:()=>X(`all`)}),ae.type===`choice`?null:(0,$.jsx)(Be,{projectId:o.id,category:ae,categories:J.data.categories,onOpen:X})]},H):null:H?.startsWith(`v:`)?Y.data?(0,$.jsx)(Te,{value:Y.data,readOnly:o.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Y.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:Y.data.items.map(e=>(0,$.jsx)(ke,{item:e,categories:J.data.categories.filter(e=>e.id!==Y.data?.category.id),onOpen:X},e.key))}):null,Y.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:W(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},H):null:(0,$.jsx)(K,{id:`documents`,children:(0,$.jsx)(Re,{projectId:o.id,data:J.data,readOnly:o.readOnly,onOpen:X})}):null:null,v===`info`?Z(F):null]},o.id):null,o&&y?(0,$.jsx)(_t,{of:y,children:(0,$.jsx)(ct,{part:y.id,children:(0,$.jsx)(y.component,{})},o.id)}):null,o&&v===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:H?.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:H.slice(2),onGone:()=>X(`all`)},H):H?.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:H.slice(2),onGone:()=>X(`all`)},H):(0,$.jsxs)($.Fragment,{children:[q.data?(0,$.jsx)(Le,{projectId:o.id,data:q.data,readOnly:o.readOnly,onOpen:X}):null,Z(F)]})}):null,o&&v===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[B.data?(0,$.jsx)(rr,{data:B.data,wizardId:L,filter:R,onFilter:te}):null,B.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:B.error.message}):null,Z(F)]}):null,o||s?null:(0,$.jsx)(fe,{children:W(`settings.noProject`)})]}):null]})})]})}export{lr 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{A as r,An as i,At as a,B as o,Bt as s,C as c,D as l,Dn as u,Dt as d,E as f,F as p,Fn as m,Gr as h,Gt as g,H as _,Ht as v,I as y,In as b,Jn as x,Kn as S,L as C,Lt as w,M as T,Mt as E,N as ee,Nn as D,Nt as O,O as k,Ot as A,P as j,Pt as M,R as N,Rt as P,S as F,T as I,U as L,Un as R,Ut as z,V as te,Vt as B,W as V,Wn as H,Yn as U,Yt as W,Zn as G,_ as K,_r as ne,a as re,b as q,br as J,cr as Y,fr as ie,g as ae,gr as oe,h as se,hr as ce,ir as le,j as ue,jn as de,jt as fe,k as pe,kt as X,nr as Z,ot as me,qn as he,v as ge,vr as _e,w as ve,x as ye,y as be,yr as xe,z as Se,zn as Ce,zt as we}from"./ui-EuR3jezP.js";import{_ as Te,a as Ee,b as De,c as Oe,d as ke,f as Ae,g as je,h as Me,i as Ne,l as Pe,m as Fe,n as Ie,o as Le,p as Re,s as ze,u as Be,v as Ve,x as He,y as Ue}from"./RunDrawer-4yvfW_2c.js";import{t as We}from"./phone-3fG1okFs.js";import{n as Ge,r as Ke,t as qe}from"./ReadOnly-i-6WBMSE.js";import{t as Je}from"./upload-BsMUhEfX.js";import{Ct as Ye,G as Xe,Ht as Ze,Lt as Qe,Mt as $e,Ot as et,Rt as tt,Tt as nt,Wt as rt,Zt as it,_ as at,b as ot,bt as st,c as ct,ct as lt,et as ut,g as dt,h as ft,kt as pt,m as mt,ot as ht,p as gt,s as _t,st as vt,u as yt,v as bt,y as xt}from"./index-C74LSJ-W.js";import{a as St,c as Ct,f as wt,i as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At,u as jt}from"./settings-menu-D9fbi1Z0.js";import{t as Mt}from"./RunnerView-BkWQBa_M.js";var Nt={name:`blend`,size:24,node:[[`circle`,{cx:`15`,cy:`9`,r:`7`,key:`1i12rt`}],[`circle`,{cx:`9`,cy:`15`,r:`7`,key:`19bs8k`}]]};Nt.node;var Pt=Y(Nt),Ft={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`}]]};Ft.node;var It=Y(Ft),Lt={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`}]]};Lt.node;var Rt=Y(Lt),zt={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`}]]};zt.node;var Bt=Y(zt),Vt={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`]};Vt.node;var Ht=Y(Vt),Ut={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`]};Ut.node;var Wt=Y(Ut),Gt={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`}]]};Gt.node;var Kt=Y(Gt),qt={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`}]]};qt.node;var Jt=Y(qt),Yt={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`}]]};Yt.node;var Xt=Y(Yt),Zt={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`}]]};Zt.node;var Qt=Y(Zt),$t=xe(),Q=e(t(),1),$=e(n(),1),en={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function tn({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 o=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:W(o?`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 nn(e,t){confirm(W(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function rn({projectId:e,file:t,small:n}){let r=Se(e,t.id);if(t.mime.startsWith(`image/`))return(0,$.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:z(`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)(an,{src:r,small:n});let a=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)(Qt,{className:a}):t.mime===`application/pdf`?(0,$.jsx)(he,{className:a}):t.mime===`application/json`?(0,$.jsx)(i,{className:a}):t.mime.startsWith(`model/`)?(0,$.jsx)(It,{className:a}):(0,$.jsx)(S,{className:a}),n?null:(0,$.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wide`,children:t.mime===`application/json`?`Lottie / JSON`:t.mime.split(`/`).pop()})]})}function an({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:z(`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 on=`application/x-wizards-logo`;function sn({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onUpload:o,onPreview:s,mainId:c,onMakeMain:l,moveTo:d,onRemove:f}){let p=e=>f?f(e):nn(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(on,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===c?(0,$.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,$.jsx)(X,{tone:`ember`,children:W(`project.logoMain`)})}):null,(0,$.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?en:void 0,children:[s&&n.mime.startsWith(`image/`)?(0,$.jsx)(`button`,{type:`button`,"aria-label":`${W(`project.preview`)}: ${n.name}`,onClick:()=>s(n),className:`block size-full cursor-zoom-in`,children:(0,$.jsx)(rn,{projectId:e,file:n})}):(0,$.jsx)(rn,{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:[s?(0,$.jsx)(E,{label:W(`project.preview`),onClick:()=>s(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(rt,{className:`size-4`})}):null,l&&n.id!==c&&!r.readOnly?(0,$.jsx)(E,{label:W(`project.logoMakeMain`),onClick:()=>l(n),className:`size-8 bg-card shadow-soft`,children:(0,$.jsx)(nt,{className:`size-4`})}):null,d&&!r.readOnly?(0,$.jsx)(q,{options:d.options,value:d.current(n),onChange:e=>d.onMove(n,e),className:`bg-card shadow-soft`}):null,r.readOnly?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>p(n),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,$.jsx)(u,{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)(tn,{file:n,actions:r})]},n.id)),a&&!r.readOnly?(0,$.jsxs)(ge,{accept:i,multiple:!1,onFiles:e=>o?o(e):r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,$.jsx)(P,{className:`size-5`}):(0,$.jsx)(m,{className:`size-5`}),a]}):null]})}function cn({kind:e,fetchUrl:t,onAdded:n,onClose:r}){let[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),g=async()=>{c(!0),u(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])):u(W(e===`logo`?`project.logoNoneFound`:`project.assetNoneFound`))}catch(e){u(e.message)}c(!1)},_=async()=>{c(!0),u(null);let e=[];try{for(let n of m){let r=await t(n);r.file&&e.push(r.file)}}catch(e){u(e.message)}c(!1),e.length&&n(e),e.length===m.length&&r()};return(0,$.jsx)(a,{open:!0,onClose:r,wide:f?!0:void 0,title:W(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:W(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:z(`relative h-28 overflow-hidden rounded-lg ring-1 transition`,n?`ring-2 ring-ember`:`ring-border-soft hover:ring-ink-4`),style:en,children:[(0,$.jsx)(`img`,{src:t.url,alt:``,className:z(`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)(Z,{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)(d,{variant:`ghost`,onClick:()=>p(null),children:W(`run.back`)}),(0,$.jsx)(d,{busy:s,disabled:!m.length,onClick:()=>void _(),children:m.length>1?W(`project.addMany`,{n:m.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,inputMode:`url`,placeholder:`https://example.com`,onChange:e=>o(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(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)(d,{variant:`ghost`,onClick:r,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:s,disabled:!i.trim(),children:W(`run.next`)})]})]})})}function ln(e,t,n){return J({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>V.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function un(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var dn=e=>[un(e),e.pages?W(`project.pages`,{n:e.pages}):null,N(e.size)].filter(Boolean).join(` · `),fn=2e5;function pn({projectId:e,fileId:t,readOnly:n,onGone:r}){let i=h(),a=L(e),o=Fe(e),s=te(e,n),c=a.data?.files.find(e=>e.id===t),l=c?c.mime===`application/pdf`||c.mime.startsWith(`image/`):!1,[d,f]=(0,Q.useState)(null);if(!c)return a.isLoading?(0,$.jsx)(P,{className:`mx-auto text-ink-3`}):null;let p=d??(l?`original`:`text`),m=o.data?.items.find(e=>e.key===`f:${c.id}`),g=Se(e,c.id),_=(e,t)=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>f(e),className:z(`rounded-full px-3 py-1 text-[0.8125rem] transition`,p===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:c.name}),(0,$.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 max-sm:hidden`,children:dn(c)}),(0,$.jsx)(`a`,{href:g,target:`_blank`,rel:`noreferrer`,"aria-label":W(`project.openOriginal`),title:W(`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)(x,{className:`size-4`})}),n?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{label:W(`project.reindex`),onClick:async()=>{await s.reindex(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]})},children:(0,$.jsx)(D,{className:`size-4`})}),(0,$.jsx)(E,{label:W(`know.deleteFile`),className:`hover:text-rose`,onClick:async()=>{confirm(W(`data.confirmDelete`,{title:c.name}))&&(await s.remove(c.id),await i.invalidateQueries({queryKey:[`knowledge`,e]}),r())},children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Ae,{projectId:e,itemKey:`f:${c.id}`,has:m?.categories??[],originLabel:m?.originLabel??null,kept:!1,review:null,file:null,readOnly:n,onReviewed:()=>void 0}),(0,$.jsx)(`div`,{className:`px-1`,children:(0,$.jsx)(tn,{file:c,actions:s})}),c.status===`failed`?(0,$.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:c.error}):null,(0,$.jsxs)(A,{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:[l?_(`original`,W(`project.original`)):null,_(`text`,W(`project.readText`))]}),p===`original`?c.mime===`application/pdf`?(0,$.jsx)(`iframe`,{src:g,title:c.name,className:`h-[70dvh] w-full rounded-b-xl bg-paper-2`}):(0,$.jsx)(`img`,{src:g,alt:``,className:`mx-auto max-h-[70dvh] object-contain p-4`}):(0,$.jsx)(mn,{projectId:e,file:c})]})]})}function mn({projectId:e,file:t}){let n=ln(e,t,fn);return n.isLoading||t.status===`pending`?(0,$.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,$.jsx)(P,{})}):n.data?.text?(0,$.jsxs)(`div`,{className:`overflow-x-auto p-4 sm:p-5`,children:[(0,$.jsx)(me,{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:W(`project.textCut`,{shown:n.data.text.length.toLocaleString(g),total:n.data.chars.toLocaleString(g)})}):null]}):(0,$.jsx)(`p`,{className:`py-8 text-center text-[0.875rem] text-ink-3`,children:W(`project.noText`)})}var hn=`image/*,video/*,audio/*,application/pdf,.pdf,.woff2,.woff,.ttf,.otf,.json,.glb,.gltf`,gn=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),N(e.size)].filter(Boolean).join(` · `);function _n({projectId:e,file:t,actions:n,onClose:r}){let i=Se(e,t.id);return(0,$.jsxs)(a,{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:gn(t)}),(0,$.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":W(`project.openOriginal`),title:W(`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)(x,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:en,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)(tn,{file:t,actions:n})})]})}function vn({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":`${W(`project.preview`)}: ${t.name}`,onClick:i,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,$.jsx)(rn,{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:gn(t)})]}),(0,$.jsx)(tn,{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)(E,{label:W(`project.preview`),onClick:i,children:(0,$.jsx)(rt,{className:`size-4`})}),r&&!n.readOnly?(0,$.jsx)(q,{options:r.options,value:r.current(t),onChange:e=>r.onMove(t,e),className:`size-9`}):null,n.readOnly?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:a,className:`hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]})]})}function yn({section:e,onSave:t,onRemove:n,onClose:r}){let[i,o]=(0,Q.useState)(e?.title??``);return(0,$.jsx)(a,{open:!0,onClose:r,title:W(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)(M,{children:W(`project.assetSectionName`)}),(0,$.jsx)(O,{autoFocus:!0,value:i,maxLength:80,placeholder:W(`project.assetSectionTitle`),onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n?(0,$.jsx)(d,{variant:`danger`,onClick:n,children:W(`project.sectionRemove`)}):null,(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(d,{variant:`ghost`,onClick:r,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,disabled:!i.trim(),children:W(e?`settings.save`:`project.add`)})]})]})})}function bn({projectId:e,data:t,readOnly:n,sections:r,save:i}){let a=te(e,n),[s,l]=_(`assets`,`cards`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(r),[g,v]=(0,Q.useState)(``),[y,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),w=(0,Q.useRef)(null),ee=o({assetSections:m},i),D=t.files.filter(e=>e.kind===`asset`),O=new Map(D.map(e=>[e.id,e])),k=new Set(m.flatMap(e=>e.assets)),A=m.find(e=>e.id===g)??null,j=A?A.assets.map(e=>O.get(e)).filter(e=>!!e):D.filter(e=>!k.has(e.id)),M=D.find(e=>e.id===f),N=u.trim().toLowerCase(),L=N?j.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(N)):j,R=(e,t)=>h(n=>n.map(n=>{let r=n.assets.filter(t=>t!==e);return{...n,assets:n.id===t?[...r,e]:r}})),z=async e=>{let t=A?.id??null;for(let n of await a.upload(`asset`,e))R(n.id,t)},V=e=>{confirm(W(`project.removeConfirm`,{name:e.name}))&&(a.remove(e.id),R(e.id,null))},H=m.length?{options:[{value:``,label:W(`project.assetsGeneral`)},...m.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],current:e=>m.find(t=>t.assets.includes(e.id))?.id??``,onMove:(e,t)=>R(e.id,t||null)}:void 0,U=[{label:W(`project.assetUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>w.current?.click()},{label:W(`project.assetFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>C(!0)},...m.length<T.logoSections?[{label:W(`project.assetSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>x(`new`)}]:[]],G=m.length||D.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)(B,{value:g,onChange:e=>{v(e),d(``)},label:W(`project.assets`),options:[{id:``,label:W(`project.assetsGeneral`)},...m.map(e=>({id:e.id,label:e.title||W(`project.sectionUntitled`)}))]}):null,A&&!n?(0,$.jsx)(E,{label:W(`project.assetSectionRename`),onClick:()=>x(`current`),children:(0,$.jsx)(b,{className:`size-4`})}):null]}),j.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-56 max-w-[45%] shrink`,children:(0,$.jsx)(F,{value:u,onChange:d,placeholder:W(`project.assetSearch`)})}),(0,$.jsx)(E,{label:W(s===`list`?`project.viewCards`:`project.viewList`),onClick:l,children:s===`list`?(0,$.jsx)(Kt,{className:`size-4`}):(0,$.jsx)(Xt,{className:`size-4`})})]}):null]}):null;return(0,$.jsxs)(c,{title:W(`project.assets`),hint:W(`project.assetsHint`),save:ee,tabs:G,action:n?null:(0,$.jsx)(se,{entries:U}),children:[(0,$.jsx)(`input`,{ref:w,type:`file`,multiple:!0,accept:hn,className:`sr-only`,tabIndex:-1,"aria-hidden":!0,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&z(t)}}),L.length?s===`cards`?(0,$.jsx)(sn,{projectId:e,kind:`asset`,files:L,actions:a,moveTo:H,onRemove:V,onPreview:e=>p(e.id)}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:L.map(t=>(0,$.jsx)(vn,{projectId:e,file:t,actions:a,moveTo:H,onPreview:()=>p(t.id),onRemove:()=>V(t)},t.id))}):j.length?null:n?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.staysLocal`)}):(0,$.jsxs)(ge,{accept:hn,onFiles:e=>void z(e),className:`h-16 w-full`,children:[a.busy?(0,$.jsx)(P,{className:`size-4`}):(0,$.jsx)(Je,{className:`size-4`}),W(`project.drop`),` `,(0,$.jsx)(`span`,{className:`underline`,children:W(`project.assetAdd`)})]}),a.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:a.error}):null,M?(0,$.jsx)(_n,{projectId:e,file:M,actions:a,onClose:()=>p(null)}):null,y?(0,$.jsx)(yn,{section:y===`current`?A:null,onClose:()=>x(null),onSave:e=>{if(y===`current`&&A)h(t=>t.map(t=>t.id===A.id?{...t,title:e}:t));else{let t=I();h(n=>[...n,{id:t,title:e,assets:[]}]),v(t)}},onRemove:y===`current`&&A?()=>{(!A.assets.length||confirm(W(`project.assetSectionRemoveConfirm`,{name:A.title})))&&(h(e=>e.filter(e=>e.id!==A.id)),v(``),x(null))}:void 0}):null,S?(0,$.jsx)(cn,{kind:`asset`,onClose:()=>C(!1),fetchUrl:e=>a.fromUrl(`asset`,e),onAdded:e=>{for(let t of e)R(t.id,A?.id??null)}}):null]})}var xn=/^#[0-9a-fA-F]{6}$/;async function Sn(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 Cn={linear:`project.gradientLinear`,radial:`project.gradientRadial`,conic:`project.gradientConic`};function wn({projectId:e,gradient:t,isNew:n,brand:r,onSave:o,onClose:s}){let[c,l]=(0,Q.useState)(t),[f,h]=(0,Q.useState)(p(t)),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(null),[T,ee]=(0,Q.useState)(!n),D=e=>{l(e),h(p(e)),_(!1)},k=(e,t)=>D({...c,stops:c.stops.map((n,r)=>r===e?{...n,...t}:n)}),A=e=>{let t=[...c.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));D({...c,stops:[...c.stops,{color:e??t[0]?.color??`#888888`,at:n}]})},j=async()=>{x(!0),w(null);try{let{gradient:t}=await V.post(`/api/studio/projects/${e}/gradients/describe`,{text:v.trim(),...T?{gradient:{name:c.name,type:c.type,angle:c.angle,stops:c.stops}}:{}});D({...c,...t,name:c.name.trim()?c.name:t.name}),y(``),ee(!0)}catch(e){w(e.message)}x(!1)};return(0,$.jsx)(a,{open:!0,onClose:s,wide:!0,title:W(n?`project.gradientNew`:`project.gradientEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v.trim()&&!b&&j()},children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(O,{"data-autofocus":n||void 0,value:v,maxLength:1e3,"aria-label":W(`project.gradientDescribe`),placeholder:W(T?`project.gradientDescribeChange`:`project.gradientDescribeNew`),onChange:e=>y(e.target.value),className:`min-w-0 flex-1`}),(0,$.jsxs)(d,{type:`submit`,variant:`secondary`,busy:b,disabled:!v.trim(),children:[(0,$.jsx)(i,{className:`size-4`}),W(T?`project.gradientDescribeApply`:`project.gradientDescribeMake`)]})]}),(0,$.jsx)(`p`,{className:z(`mt-1.5 text-[0.8125rem]`,S?`text-rose`:`text-ink-3`),children:S??W(`project.gradientDescribeHint`)})]}),(0,$.jsx)(`div`,{className:`h-40 rounded-lg ring-1 ring-border-soft`,style:{background:p(c)}}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientName`)}),(0,$.jsx)(O,{value:c.name,maxLength:80,placeholder:W(`project.gradientNamePlaceholder`),onChange:e=>l({...c,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.fillUseLabel`)}),(0,$.jsx)(O,{value:c.description??``,maxLength:400,placeholder:W(`project.gradientUse`),onChange:e=>l({...c,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-6 gap-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientType`)}),(0,$.jsx)(`div`,{className:`flex gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:ue.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":c.type===e,onClick:()=>D({...c,type:e}),className:z(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,c.type===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:W(Cn[e])},e))})]}),c.type===`radial`?null:(0,$.jsxs)(`div`,{className:`min-w-56`,children:[(0,$.jsx)(M,{children:W(`project.gradientAngle`)}),(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:360,value:c.angle,"aria-label":W(`project.gradientAngle`),onChange:e=>D({...c,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(c.angle),`°`]})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.gradientStops`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.stops.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(we,{value:xn.test(e.color)?e.color:`#888888`,onChange:e=>k(t,{color:e.target.value})}),(0,$.jsx)(O,{value:e.color,spellCheck:!1,onChange:e=>{let n=e.target.value.trim();xn.test(n)&&k(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":W(`project.gradientAt`),onChange:e=>k(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)(E,{label:W(`project.remove`),disabled:c.stops.length<=2,onClick:()=>D({...c,stops:c.stops.filter((e,n)=>n!==t)}),className:`hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]},t))}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[c.stops.length<12?(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>A(),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.gradientStopAdd`)]}):null,r.length&&c.stops.length<12?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`ml-2 text-[0.8125rem] text-ink-3`,children:W(`project.gradientFromBrand`)}),r.slice(0,10).map(e=>(0,$.jsx)(`button`,{type:`button`,title:e.name||e.value,"aria-label":e.name||e.value,onClick:()=>A(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)(M,{children:`CSS`}),(0,$.jsx)(O,{value:f,spellCheck:!1,onChange:e=>{h(e.target.value);let t=C(e.target.value);_(!t),t&&l({...c,...t})},className:`font-mono text-[0.8125rem]`}),(0,$.jsx)(`p`,{className:z(`mt-1.5 text-[0.8125rem]`,g?`text-rose`:`text-ink-3`),children:W(g?`project.gradientCssError`:`project.gradientCssHint`)})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:s,children:W(`common.cancel`)}),(0,$.jsx)(d,{onClick:()=>{o(c),s()},children:W(`settings.save`)})]})]})})}var Tn=`absolute top-1.5 right-1.5 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover/card:opacity-100 coarse:opacity-100`,En=`size-8 bg-card shadow-soft hover:bg-card`;function Dn({name:e,namePlaceholder:t,description:n,usePlaceholder:r,readOnly:i,onChange:a}){return i?(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(`p`,{className:`truncate text-[0.875rem]`,children:e||t}),n?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3 leading-snug`,children:n}):null]}):(0,$.jsxs)(`div`,{className:`min-w-0 px-0.5`,children:[(0,$.jsx)(be,{value:e,label:W(`project.gradientName`),placeholder:t,maxLength:80,onChange:e=>a({name:e}),className:`font-medium text-[0.875rem]`}),(0,$.jsx)(be,{value:n??``,label:W(`project.fillUseLabel`),placeholder:r,maxLength:400,onChange:e=>a({description:e}),className:`text-[0.8125rem] text-ink-3`})]})}function On({gradient:e,readOnly:t,onEdit:n,onChange:r,onRemove:i}){let a=p(e),[o,s]=(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,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:t,"aria-label":W(`project.gradientEdit`),onClick:n,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:{background:a}}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(E,{label:W(o?`project.gradientCopied`:`project.gradientCopy`),onClick:()=>{navigator.clipboard.writeText(`background: ${a};`),s(!0),setTimeout(()=>s(!1),1500)},className:En,children:(0,$.jsx)(G,{className:`size-4`})}),(0,$.jsx)(E,{label:W(`project.download`),onClick:()=>void Sn(e,e.name),className:En,children:(0,$.jsx)(U,{className:`size-4`})}),t?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:i,className:z(En,`hover:text-rose`),children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:e.name,namePlaceholder:W(`project.gradientName`),description:e.description,usePlaceholder:W(`project.gradientUse`),readOnly:t,onChange:r})]})}function kn(e,t){return{backgroundImage:`url("${e}")`,backgroundSize:t?`64px`:`cover`,backgroundRepeat:t?`repeat`:`no-repeat`,backgroundPosition:`center`}}function An({projectId:e,pattern:t,fileName:n,readOnly:r,onEdit:i,onChange:a,onRemove:o}){let s=Se(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,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r,"aria-label":W(`project.patternEdit`),onClick:i,className:`block h-28 w-full rounded-md ring-1 ring-border-soft transition enabled:hover:brightness-105`,style:kn(s,t.tile)}),(0,$.jsxs)(`div`,{className:Tn,children:[(0,$.jsx)(`a`,{href:s,download:n,"aria-label":W(`project.download`),title:W(`project.download`),className:z(`inline-flex items-center justify-center rounded-full text-ink-3 transition hover:text-ink`,En),children:(0,$.jsx)(U,{className:`size-4`})}),r?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:o,className:z(En,`hover:text-rose`),children:(0,$.jsx)(u,{className:`size-4`})})]})]}),(0,$.jsx)(Dn,{name:t.name,namePlaceholder:n,description:t.description,usePlaceholder:W(`project.patternUse`),readOnly:r,onChange:a})]})}function jn({projectId:e,pattern:t,isNew:n,fileName:r,busy:i,error:o,upload:s,removeFile:c,onSave:l,onClose:u}){let[f,p]=(0,Q.useState)(t),[m,h]=(0,Q.useState)([]),g=async e=>{let t=e[0];if(!t)return;let n=await s(t);n&&(h(e=>[...e,n.id]),p(e=>({...e,file:n.id,name:e.name||n.name.replace(/\.[^.]+$/,``)})))},_=()=>{for(let e of m)c(e);u()};return(0,$.jsx)(a,{open:!0,onClose:_,wide:!0,title:W(n?`project.patternNew`:`project.patternEdit`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f.file?(0,$.jsx)(`div`,{className:`relative h-40 rounded-lg ring-1 ring-border-soft`,style:kn(Se(e,f.file),f.tile),children:(0,$.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`absolute right-2 bottom-2 h-9 border-solid bg-card px-3.5 text-ink-2 shadow-soft`,children:[i?(0,$.jsx)(P,{className:`size-4`}):(0,$.jsx)(H,{className:`size-4`}),W(`project.patternReplace`)]})}):(0,$.jsxs)(ge,{accept:`image/*`,multiple:!1,onFiles:e=>void g(e),className:`h-40 flex-col`,children:[i?(0,$.jsx)(P,{className:`size-5`}):(0,$.jsx)(H,{className:`size-5`}),W(`project.patternPick`)]}),(0,$.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.patternName`)}),(0,$.jsx)(O,{value:f.name,maxLength:80,placeholder:f.file?r(f.file):W(`project.patternNamePlaceholder`),onChange:e=>p({...f,name:e.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.fillUseLabel`)}),(0,$.jsx)(O,{value:f.description??``,maxLength:400,placeholder:W(`project.patternUse`),onChange:e=>p({...f,description:e.target.value})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.patternShow`)}),(0,$.jsx)(`div`,{className:`flex w-fit gap-1 rounded-full bg-paper-2 p-0.5 ring-1 ring-border-soft`,children:[!1,!0].map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!f.tile===e,onClick:()=>p({...f,tile:e||void 0}),className:z(`h-9 rounded-full px-4 font-medium text-[0.875rem] transition`,!!f.tile===e?`bg-card text-ink shadow-sm`:`text-ink-3 hover:text-ink-2`),children:W(e?`project.patternTile`:`project.patternFill`)},String(e)))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[o?(0,$.jsx)(`p`,{className:`mr-auto text-[0.8125rem] text-rose`,children:o}):null,(0,$.jsx)(d,{variant:`ghost`,onClick:_,children:W(`common.cancel`)}),(0,$.jsx)(d,{disabled:!f.file||i,onClick:()=>{for(let e of m.filter(e=>e!==f.file))c(e);t.file&&t.file!==f.file&&c(t.file),l({...f,name:f.name.trim(),description:f.description?.trim()||void 0}),u()},children:W(n?`project.add`:`settings.save`)})]})]})})}var Mn=/^#[0-9a-fA-F]{6}$/;function Nn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{colors:t}=await V.post(`/api/studio/projects/${e}/colors/scan`,{url:r.trim()});t.length?(f(t),m([])):l(W(`project.colorsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(a,{open:!0,onClose:n,wide:u?!0:void 0,title:W(u?`project.colorsFound`:`project.colorsFromUrl`),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:W(`project.colorsFoundHint`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3`,children:u.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:z(`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)(Z,{className:`size-3.5`})}):null]},e.value)})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:()=>f(null),children:W(`run.back`)}),(0,$.jsx)(d,{disabled:!p.length,onClick:()=>{t(u.filter(e=>p.includes(e.value))),n()},children:p.length>1?W(`project.addMany`,{n:p.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{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:W(`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)(d,{variant:`ghost`,onClick:n,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:o,disabled:!r.trim(),children:W(`run.next`)})]})]})})}function Pn({projectId:e,data:t,colors:n,sections:r,gradients:i,patterns:a,rules:s,sectioned:l,ruled:d,save:p,readOnly:h}){let[g,_]=(0,Q.useState)(()=>n.map(e=>({...e,id:I()}))),[v,y]=(0,Q.useState)(r),[b,x]=(0,Q.useState)(i),[S,C]=(0,Q.useState)(a),[w,ee]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(null),A=te(e,h),j=f(s),[M,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),z=o({colors:g.filter(e=>Mn.test(e.value)).map(({name:e,value:t,section:n})=>({name:e.trim(),value:t,...n?{section:n}:{}})),colorSections:v,gradients:b,patterns:S,colorRules:j.rules},p),B=l?v:[],V=B.filter(e=>(e.kind??`colors`)===`colors`),H=e=>V.some(t=>t.id===e.section),U=g.filter(e=>!H(e)),G=(U[0]??g[0])?.id,K=(e,t)=>_(n=>n.map(n=>n.id===e?{...n,...t}:n)),ne=e=>_(t=>[...t,...e.map(e=>({...e,id:I()}))].slice(0,T.colors)),re=[{value:``,label:W(`project.sectionStandard`)},...V.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],J=(e,t)=>{let n=I();N(n),y(r=>[...r,{id:n,title:t,...e===`colors`?{}:{kind:e}}])},Y=e=>({id:I(),name:``,section:e,type:`linear`,angle:90,stops:[{color:g[0]?.value&&Mn.test(g[0].value)?g[0].value:`#4b73ff`,at:0},{color:g[1]?.value&&Mn.test(g[1].value)?g[1].value:`#ff6d1b`,at:100}]}),ie=e=>t.files.find(t=>t.id===e)?.name??`pattern`,oe=[...g.length<T.colors?[{label:W(`project.colorNew`),icon:(0,$.jsx)(m,{className:`size-4 shrink-0`}),onPick:()=>ue()},{label:W(`project.colorsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>R(!0)}]:[],...l&&v.length<T.logoSections?[{label:W(`project.colorSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>J(`colors`,``)},{label:W(`project.gradientSectionAdd`),icon:(0,$.jsx)(Pt,{className:`size-4 shrink-0`}),onPick:()=>J(`gradients`,W(`project.gradientSectionTitle`))},{label:W(`project.patternSectionAdd`),icon:(0,$.jsx)(Ht,{className:`size-4 shrink-0`}),onPick:()=>J(`patterns`,W(`project.patternSectionTitle`))}]:[],...!d||j.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>j.add()}]],ce=e=>(0,$.jsxs)(`div`,{className:`group/row flex items-center gap-2`,children:[(0,$.jsx)(we,{value:Mn.test(e.value)?e.value:`#888888`,onChange:t=>K(e.id,{value:t.target.value})}),(0,$.jsx)(O,{value:e.name,autoFocus:e.id===P,placeholder:W(`project.colorName`),maxLength:120,onChange:t=>K(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,$.jsx)(O,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>K(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===G?(0,$.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,$.jsx)(X,{tone:`ember`,children:W(`project.colorAccent`)})}):h?null:(0,$.jsx)(E,{label:W(`project.colorFirst`),onClick:()=>_(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)(le,{className:`size-4`})}),h||!V.length?null:(0,$.jsx)(q,{options:re,value:H(e)?e.section??``:``,onChange:t=>K(e.id,{section:t||void 0}),className:`opacity-0 focus-within:opacity-100 group-hover/row:opacity-100 coarse:opacity-100`}),h?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>_(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)(u,{className:`size-4`})})]})]},e.id),ue=e=>{let t=I();F(t),_(n=>[...n,{id:t,name:``,value:`#888888`,...e?{section:e}:{}}])};return(0,$.jsxs)(c,{title:W(`project.colors`),hint:W(`project.colorsHint`),save:z,locked:h,action:h?null:(0,$.jsx)(se,{entries:oe}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[U.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:U.map(ce)}),h?null:(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.colorUse`)})]}):g.length?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.colorsEmpty`)}),B.map(t=>{let n=t.kind??`colors`,r=g.filter(e=>e.section===t.id),i=b.filter(e=>e.section===t.id),a=S.filter(e=>e.section===t.id),o=n===`gradients`?i.length:n===`patterns`?a.length:r.length;return(0,$.jsxs)(`div`,{className:`group/section flex flex-col gap-3`,children:[(0,$.jsx)(ve,{title:t.title,titlePlaceholder:W(n===`gradients`?`project.gradientSectionTitlePlaceholder`:n===`patterns`?`project.patternSectionTitlePlaceholder`:`project.colorSectionTitle`),kind:n===`gradients`?{icon:(0,$.jsx)(Pt,{}),label:W(`project.kindGradients`)}:n===`patterns`?{icon:(0,$.jsx)(Ht,{}),label:W(`project.kindPatterns`)}:{icon:(0,$.jsx)($e,{}),label:W(`project.kindColors`)},autoFocus:M===t.id,readOnly:h,onChange:e=>y(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{if(!o||confirm(W(n===`colors`?`project.colorSectionRemoveConfirm`:`project.fillSectionRemoveConfirm`,{name:t.title||W(`project.sectionUntitled`)}))){y(e=>e.filter(e=>e.id!==t.id)),_(e=>e.map(e=>e.section===t.id?{...e,section:void 0}:e)),x(e=>e.filter(e=>e.section!==t.id));for(let e of a)A.remove(e.file);C(e=>e.filter(e=>e.section!==t.id))}}}),n===`gradients`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[i.map(e=>(0,$.jsx)(On,{gradient:e,readOnly:h,onEdit:()=>ee(e),onChange:t=>x(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>x(t=>t.filter(t=>t.id!==e.id))},e.id)),h||b.length>=T.gradients?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(Y(t.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)(m,{className:`size-5`}),W(`project.gradientAdd`)]})]}):n===`patterns`?(0,$.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3`,children:[a.map(t=>(0,$.jsx)(An,{projectId:e,pattern:t,fileName:ie(t.file),readOnly:h,onEdit:()=>k(t),onChange:e=>C(n=>n.map(n=>n.id===t.id?{...n,...e}:n)),onRemove:()=>{A.remove(t.file),C(e=>e.filter(e=>e.id!==t.id))}},t.id)),h||S.length>=T.files.pattern?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>k({id:I(),name:``,section:t.id,file:``}),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)(m,{className:`size-5`}),W(`project.patternAdd`)]})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r.map(ce),h||g.length>=T.colors?null:(0,$.jsx)(ae,{label:W(`project.colorAdd`),onClick:()=>ue(t.id)})]})]},t.id)}),d?(0,$.jsx)(ye,{rules:j,placeholder:W(`project.colorRulePlaceholder`),readOnly:h}):null]}),A.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:A.error}):null,w?(0,$.jsx)(wn,{projectId:e,gradient:w,isNew:!b.some(e=>e.id===w.id),brand:g.filter(e=>Mn.test(e.value)),onClose:()=>ee(null),onSave:e=>x(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,D?(0,$.jsx)(jn,{projectId:e,pattern:D,isNew:!S.some(e=>e.id===D.id),fileName:ie,busy:A.busy,error:A.error,upload:async e=>(await A.upload(`pattern`,[e]))[0]??null,removeFile:e=>void A.remove(e),onClose:()=>k(null),onSave:e=>C(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])}):null,L?(0,$.jsx)(Nn,{projectId:e,onClose:()=>R(!1),onAdd:ne}):null]})}var Fn=e=>/^(ja|yes|true)$/i.test(e.trim()),In={text:Ye,longtext:Ke,number:De,date:He,url:R,email:Qe,phone:We,boolean:Ue};function Ln({type:e,detected:t,onChange:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(!r)return;let e=e=>{s.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 c=In[e??t],l=`${W(`project.factType`)}: ${W(`project.type.${e??t}`)}`,u=`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`,d=e=>{n(e),i(!1)};return(0,$.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:z(`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)(c,{className:`size-4`})}),r?(0,$.jsxs)(`div`,{role:`menu`,className:z(`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:u,onClick:()=>d(void 0),children:[(0,$.jsx)(st,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:W(`project.factAuto`)}),(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-4`,children:W(`project.type.${t}`)}),(0,$.jsx)(Z,{className:z(`size-4 shrink-0`,e&&`invisible`)})]}),(0,$.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),k.map(t=>{let n=In[t];return(0,$.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,$.jsx)(n,{className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1`,children:W(`project.type.${t}`)}),(0,$.jsx)(Z,{className:z(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function Rn({facts:e,save:t,readOnly:n}){let r=(0,Q.useRef)(0),i=(0,Q.useRef)(null),[a,f]=(0,Q.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),p=o(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),h=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,...t}:n)),g=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let o={id:a,key:``,label:``,value:``,...e};f(e=>n?[o,...e]:[...e,o])},_=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},y=l.filter(e=>!a.some(t=>t.key===e));return(0,$.jsxs)(c,{title:W(`project.facts`),hint:W(`project.factsHint`),save:p,locked:n,action:a.length<T.facts&&!n?(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>g({},`label`,!0),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.factAdd`)]}):null,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=ee(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)(O,{ref:_(`${e.id}:label`),value:e.label,placeholder:W(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>h(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&h(e.id,{key:j(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)(s,{checked:Fn(e.value),label:e.label,onChange:t=>h(e.id,{value:W(t?`project.yes`:`project.no`)})}),(0,$.jsx)(`span`,{className:`text-[0.875rem] text-ink-2`,children:Fn(e.value)?W(`project.yes`):W(`project.no`)})]}):(0,$.jsx)(v,{ref:_(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:W(`project.factValue`),onChange:t=>h(e.id,{value:t.target.value}),className:`min-h-11`}),(0,$.jsx)(Ln,{type:e.type,detected:t,onChange:t=>h(e.id,{type:t})}),n?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:()=>f(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,$.jsx)(u,{className:`size-4`})})]},e.id)})}),a.length<T.facts&&!n?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,$.jsxs)(d,{variant:`secondary`,size:`sm`,onClick:()=>g({},`label`),children:[(0,$.jsx)(m,{className:`size-4`}),` `,W(`project.factAdd`)]}),y.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>g({key:e,label:W(`fact.${e}`)},`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)(m,{className:`size-3.5`}),` `,W(`fact.${e}`)]},e))]}):null]})}function zn({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(on);i(!1),n&&(t.preventDefault(),e(n))},className:z(`-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 Bn({projectId:e,data:t,readOnly:n,sections:r,rules:i,sectioned:a,ruled:s,save:l}){let u=te(e,n),[d,p]=(0,Q.useState)(r),m=f(i),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),b=(0,Q.useRef)(null),x=o({logoSections:d,logoRules:m.rules},l),S=t.files.filter(e=>e.kind===`logo`),C=new Map(S.map(e=>[e.id,e])),w=a?d:[],E=new Set(w.flatMap(e=>e.logos)),ee=S.filter(e=>!E.has(e.id)),D=y(S,d)?.id,O=(e,t)=>p(n=>n.map(n=>{let r=n.logos.filter(t=>t!==e);return{...n,logos:n.id===t?[...r,e]:r}})),k=(e,t)=>p(n=>n.map(n=>n.id===e?{...n,...t}:n)),A=async(e,t)=>{let n=await u.upload(`logo`,e);for(let e of n)O(e.id,t)},j=w.length?{options:[{value:``,label:W(`project.sectionStandard`)},...w.map(e=>({value:e.id,label:e.title||W(`project.sectionUntitled`)}))],current:e=>w.find(t=>t.logos.includes(e.id))?.id??``,onMove:(e,t)=>O(e.id,t||null)}:void 0,M=(t,n,r)=>(0,$.jsx)(sn,{projectId:e,kind:`logo`,files:t,actions:u,accept:`image/*`,addLabel:r?W(`project.logoAdd`):void 0,onUpload:e=>void A(e,n),mainId:D,onMakeMain:e=>{O(e.id,null),u.order(`logo`,[e.id,...S.filter(t=>t.id!==e.id).map(e=>e.id)])},moveTo:j,onRemove:e=>{confirm(W(`project.removeConfirm`,{name:e.name}))&&(u.remove(e.id),O(e.id,null))}}),N=n?void 0:e=>t=>O(t,e),P=[{label:W(`project.logoUpload`),icon:(0,$.jsx)(Je,{className:`size-4 shrink-0`}),onPick:()=>b.current?.click()},{label:W(`project.logoFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>v(!0)},...a&&d.length<T.logoSections?[{label:W(`project.logoSectionAdd`),icon:(0,$.jsx)(Bt,{className:`size-4 shrink-0`}),onPick:()=>{let e=I();g(e),p(t=>[...t,{id:e,title:``,description:``,logos:[]}])}}]:[],...!s||m.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>m.add()}]];return(0,$.jsxs)(c,{title:W(`project.logos`),hint:W(`project.logosHint`),save:x,action:n?null:(0,$.jsx)(se,{entries:P}),children:[(0,$.jsx)(`input`,{ref:b,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&&A(t,null)}}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,$.jsx)(zn,{onLogo:N?.(null),children:M(ee,null,!0)}),w.map(e=>(0,$.jsx)(`div`,{className:`group/section`,children:(0,$.jsxs)(zn,{onLogo:N?.(e.id),className:`flex flex-col gap-3`,children:[(0,$.jsx)(ve,{title:e.title,description:e.description,titlePlaceholder:W(`project.logoSectionTitle`),descriptionPlaceholder:W(`project.logoSectionUse`),autoFocus:h===e.id,readOnly:n,onChange:t=>k(e.id,t),onRemove:()=>{(!e.logos.length||confirm(W(`project.logoSectionRemoveConfirm`,{name:e.title||W(`project.sectionUntitled`)})))&&p(t=>t.filter(t=>t.id!==e.id))}}),M(e.logos.map(e=>C.get(e)).filter(e=>!!e),e.id,!0)]})},e.id)),s?(0,$.jsx)(ye,{rules:m,placeholder:W(`project.logoRulePlaceholder`),readOnly:n}):null]}),u.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.875rem] text-rose`,children:u.error}):null,_?(0,$.jsx)(cn,{kind:`logo`,onClose:()=>v(!1),fetchUrl:e=>u.fromUrl(`logo`,e),onAdded:e=>{for(let t of e)O(t.id,null)}}):null]})}var Vn=new Set;function Hn(e){(0,Q.useEffect)(()=>{let t=e.trim().toLowerCase().replace(/\s+/g,`-`);if(!t||Vn.has(t))return;Vn.add(t);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=`https://fonts.bunny.net/css?family=${encodeURIComponent(t)}:${r.join(`,`)}&display=swap`,document.head.append(n)},[e])}var Un=e=>e?`"${e}", system-ui, sans-serif`:`system-ui, sans-serif`;function Wn({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 Gn=`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`,Kn={web:`project.fontUseWeb`,documents:`project.fontUseDocuments`,print:`project.fontUsePrint`,images:`project.fontUseImages`,video:`project.fontUseVideo`};function qn({font:e,first:t,readOnly:n,autoFocus:i,onChange:a,onRemove:o}){return Hn(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:Un(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)(be,{value:e.family,label:W(`project.fontFamily`),placeholder:W(`project.fontFamily`),maxLength:80,autoFocus:i,onChange:e=>a({family:e}),className:`font-medium text-[0.9375rem]`}),(0,$.jsx)(be,{value:e.role,label:W(`project.fontRole`),placeholder:W(t?`project.fontRoleFirst`:`project.fontRole`),maxLength:200,onChange:e=>a({role:e}),className:`text-[0.875rem] text-ink-3`})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(t=>{let r=e.weights.includes(t);return(0,$.jsx)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>a({weights:r?e.weights.filter(e=>e!==t):[...e.weights,t].sort((e,t)=>e-t)}),style:{fontFamily:Un(e.family),fontWeight:t},className:z(`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)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n?e.license?(0,$.jsx)(`p`,{className:`text-[0.8125rem] text-ink-3`,children:e.license}):null:(0,$.jsx)(be,{value:e.license??``,label:W(`project.fontLicense`),placeholder:W(`project.fontLicensePlaceholder`),maxLength:200,onChange:e=>a({license:e}),className:`text-[0.8125rem] text-ink-3`}),n&&!e.uses?.length?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-1 text-[0.8125rem] text-ink-3`,children:W(`project.fontUses`)}),pe.map(t=>{let r=!!e.uses?.includes(t);return(0,$.jsxs)(`button`,{type:`button`,disabled:n,"aria-pressed":r,onClick:()=>{let n=r?(e.uses??[]).filter(e=>e!==t):pe.filter(n=>n===t||e.uses?.includes(n));a({uses:n.length?n:void 0})},className:z(`inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-[0.8125rem] transition`,r?`bg-card text-ink ring-1 ring-border`:`bg-paper-2 text-ink-3 hover:text-ink`,n&&!r&&`hidden`),children:[r?(0,$.jsx)(Z,{className:`size-3.5`}):null,W(Kn[t])]},t)})]})]}),n?null:(0,$.jsx)(E,{label:W(`project.remove`),onClick:o,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)(u,{className:`size-4`})})]})}function Jn({style:e,fonts:t,sample:n,readOnly:i,autoFocus:a,onChange:o,onRemove:s}){let c=t.find(t=>t.id===e.font)??t[0],l={fontFamily:Un(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:[i?(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)(be,{value:e.name,label:W(`project.styleName`),placeholder:W(`project.styleName`),maxLength:60,autoFocus:a,onChange:e=>o({name:e}),className:`font-medium text-[0.8125rem] text-ink-2 uppercase tracking-wide`})}),(0,$.jsxs)(`fieldset`,{disabled:i,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[t.length>1?(0,$.jsx)(`select`,{"aria-label":W(`project.styleFont`),value:c?.id??``,onChange:e=>o({font:e.target.value}),className:z(Gn,`max-w-40`),children:t.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.family||W(`project.fontFamily`)},e.id))}):null,(0,$.jsx)(`select`,{"aria-label":W(`project.styleWeight`),value:e.weight,onChange:e=>o({weight:Number(e.target.value)}),className:Gn,children:[...new Set([...r,e.weight])].sort().map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))}),(0,$.jsx)(Wn,{unit:`px`,label:W(`project.styleSize`),min:6,max:400,value:e.size,onChange:e=>o({size:Number(e.target.value)||16})}),(0,$.jsx)(Wn,{unit:W(`project.styleLine`),label:W(`project.styleLineLabel`),min:50,max:300,value:e.lineHeight,onChange:e=>o({lineHeight:Number(e.target.value)||100})}),(0,$.jsx)(Wn,{unit:W(`project.styleTracking`),label:W(`project.styleTrackingLabel`),min:-20,max:50,step:.5,value:e.tracking,onChange:e=>o({tracking:Number(e.target.value)||0})}),(0,$.jsx)(`button`,{type:`button`,"aria-pressed":!!e.uppercase,title:W(`project.styleUpper`),"aria-label":W(`project.styleUpper`),onClick:()=>o({uppercase:!e.uppercase}),className:z(`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)(Rt,{className:`size-4`})})]}),i?null:(0,$.jsx)(E,{label:W(`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)(u,{className:`size-4`})})]})]})}function Yn({projectId:e,onAdd:t,onClose:n}){let[r,i]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,f]=(0,Q.useState)(null),[p,m]=(0,Q.useState)([]),h=async()=>{s(!0),l(null);try{let{fonts:t}=await V.post(`/api/studio/projects/${e}/fonts/scan`,{url:r.trim()});t.length?(f(t),m(t.slice(0,2).map(e=>e.family))):l(W(`project.fontsNoneFound`))}catch(e){l(e.message)}s(!1)};return(0,$.jsx)(a,{open:!0,onClose:n,wide:u?!0:void 0,title:W(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:W(`project.fontsFoundHint`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map(e=>(0,$.jsx)(Xn,{font:e,on:p.includes(e.family),onToggle:()=>m(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)(d,{variant:`ghost`,onClick:()=>f(null),children:W(`run.back`)}),(0,$.jsx)(d,{disabled:!p.length,onClick:()=>{t(u.filter(e=>p.includes(e.family))),n()},children:p.length>1?W(`project.addMany`,{n:p.length}):W(`project.add`)})]})]}):(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.logoUrl`)}),(0,$.jsx)(O,{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:W(`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)(d,{variant:`ghost`,onClick:n,children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:o,disabled:!r.trim(),children:W(`run.next`)})]})]})})}function Xn({font:e,on:t,onToggle:n}){return Hn(e.family),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:n,className:z(`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:Un(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(` · `):W(`project.fontWeightsUnknown`)})]}),t?(0,$.jsx)(`span`,{className:`grid size-5 place-items-center rounded-full bg-ember text-white`,children:(0,$.jsx)(Z,{className:`size-3.5`})}):null]})}function Zn({projectId:e,fonts:t,styles:n,rules:r,ruled:i,sample:a,save:s,readOnly:l}){let[u,d]=(0,Q.useState)(t),[p,h]=(0,Q.useState)(n),g=f(r),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),x=o({fonts:u,textStyles:p,typeRules:g.rules},s),S=(e,t=!1)=>{let n=e.map(e=>({id:I(),family:e.family,role:``,weights:e.weights}));t&&n[0]&&v(n[0].id),d(e=>[...e,...n].slice(0,T.fonts))},C=()=>{let e=I();v(e),h(t=>[...t,{id:e,name:``,size:16,weight:400,lineHeight:150,tracking:0}])},w=[...u.length<T.fonts?[{label:W(`project.fontNew`),icon:(0,$.jsx)(m,{className:`size-4 shrink-0`}),onPick:()=>S([{family:``,weights:[400,700]}],!0)},{label:W(`project.fontsFromUrl`),icon:(0,$.jsx)(Jt,{className:`size-4 shrink-0`}),onPick:()=>b(!0)}]:[],...p.length<T.textStyles?[{label:W(`project.styleNew`),icon:(0,$.jsx)(et,{className:`size-4 shrink-0`}),onPick:C}]:[],...!i||g.full?[]:[{label:W(`project.ruleNew`),icon:(0,$.jsx)(tt,{className:`size-4 shrink-0`}),onPick:()=>g.add()}]];return(0,$.jsxs)(c,{title:W(`project.typography`),hint:W(`project.typographyHint`),save:x,action:l?null:(0,$.jsx)(se,{entries:w}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[u.length?(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3`,children:u.map((e,t)=>(0,$.jsx)(qn,{font:e,first:t===0,readOnly:l,autoFocus:_===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))}):(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:W(`project.fontsEmpty`)}),p.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium text-[0.9375rem]`,children:W(`project.styles`)}),l?null:(0,$.jsx)(`p`,{className:`text-[0.875rem] text-ink-3 leading-snug`,children:W(`project.stylesHint`)}),(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col`,children:p.map(e=>(0,$.jsx)(Jn,{style:e,fonts:u,sample:a,readOnly:l,autoFocus:_===e.id,onChange:t=>h(n=>n.map(n=>n.id===e.id?{...n,...t}:n)),onRemove:()=>h(t=>t.filter(t=>t.id!==e.id))},e.id))})]}):null,i?(0,$.jsx)(ye,{rules:g,placeholder:W(`project.typeRulePlaceholder`),readOnly:l}):null]}),y?(0,$.jsx)(Yn,{projectId:e,onClose:()=>b(!1),onAdd:e=>S(e)}):null]})}function Qn({project:e,save:t}){let[n,r]=(0,Q.useState)(e.brand.name??``),[i,a]=(0,Q.useState)(e.brand.about??``),s=o({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,$.jsx)(c,{title:W(`project.base`),hint:W(`project.baseHint`),save:s,locked:e.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.title`)}),(0,$.jsx)(O,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.titleHint`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(M,{children:W(`project.about`)}),(0,$.jsx)(v,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[0.8125rem] text-ink-3`,children:W(`project.aboutHint`)})]})]})})}function $n({project:e,group:t,children:n}){let r=h(),i=L(e.id),[o,s]=(0,Q.useState)(0),[c,l]=(0,Q.useState)(!1),u=async t=>{await V.patch(`/api/studio/projects/${e.id}`,t),await r.invalidateQueries({queryKey:[`projects`]})},f=it({mutationFn:()=>V.del(`/api/studio/projects/${e.id}`),onSuccess:()=>r.invalidateQueries({queryKey:[`projects`]})}),p=lt(),m=vt(),g=i.data??{files:[],embeddings:!0},_=`${e.id}:${o}`,v=e.readOnly,y=t===`knowledge`,b=ut(`brandSections`),x=ut(`brandRules`),S=ut(`typography`);return Xe(v?{}:{title:W(y?`project.assistantTitleKnowledge`:`project.assistantTitle`),hello:W(y?`project.assistantHelloKnowledge`:`project.assistantHello`),placeholder:W(y?`project.assistantComposerKnowledge`:`project.assistantComposer`),suggestions:y?[{label:W(`assistant.suggest.knowledgeHow`)},{label:W(`assistant.suggest.knowledgeSite`),fill:!0},{label:W(`assistant.suggest.knowledgeCategories`)}]:[{label:W(`assistant.suggest.readSite`),fill:!0},{label:W(`assistant.suggest.missing`)},{label:W(`assistant.suggest.facts`)}],summary:y?void 0:[e.brand.name?`title "${e.brand.name}"`:`no title`,`${e.facts.length} facts`,`${e.brand.colors?.length??0} colours`,`${g.files.filter(e=>e.kind===`logo`).length} logos`].join(` · `),onChanged:()=>s(e=>e+1)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[v?(0,$.jsx)(qe,{children:Ge(e)}):null,t===`info`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{id:`base`,children:(0,$.jsx)(Qn,{project:e,save:u},`base:${_}`)}),(0,$.jsx)(K,{id:`facts`,children:(0,$.jsx)(Rn,{facts:e.facts,save:e=>u({facts:e}),readOnly:v},`facts:${_}`)}),(0,$.jsx)(K,{id:`logos`,children:(0,$.jsx)(Bn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.logoSections??[],rules:e.brand.logoRules??[],sectioned:b,ruled:x,save:e=>u({brand:e})},`logos:${_}`)}),(0,$.jsx)(K,{id:`colors`,children:(0,$.jsx)(Pn,{projectId:e.id,data:g,colors:e.brand.colors??[],sections:e.brand.colorSections??[],gradients:e.brand.gradients??[],patterns:e.brand.patterns??[],rules:e.brand.colorRules??[],sectioned:b,ruled:x,save:e=>u({brand:e}),readOnly:v},`colors:${_}`)}),S?(0,$.jsx)(K,{id:`typography`,children:(0,$.jsx)(Zn,{projectId:e.id,fonts:e.brand.fonts??[],styles:e.brand.textStyles??[],rules:e.brand.typeRules??[],ruled:x,sample:e.brand.name||W(`project.typeSample`),save:e=>u({brand:e}),readOnly:v},`typography:${_}`)}):null,(0,$.jsx)(K,{id:`assets`,children:(0,$.jsx)(bn,{projectId:e.id,data:g,readOnly:v,sections:e.brand.assetSections??[],save:e=>u({brand:e})},`assets:${_}`)})]}):null,n,t===`info`&&p&&!v&&m?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(d,{variant:`danger`,onClick:()=>l(!0),children:W(`settings.delete`)}),(0,$.jsxs)(a,{open:c,onClose:()=>l(!1),title:W(`settings.deleteTitle`,{name:e.name}),children:[(0,$.jsx)(`p`,{className:`-mt-2 text-[0.875rem] text-ink-2`,children:W(`settings.deleteBody`)}),f.error?(0,$.jsx)(`p`,{className:`mt-3 text-[0.8125rem] text-rose`,children:f.error.message}):null,(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(d,{variant:`ghost`,onClick:()=>l(!1),children:W(`common.cancel`)}),(0,$.jsx)(d,{variant:`danger`,busy:f.isPending,onClick:()=>f.mutate(),children:W(`common.delete`)})]})]})]}):null]})}var er={q:``,mode:``,days:0};function tr(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 i=r.toString();return J({queryKey:[`results`,e,i],queryFn:()=>V.get(`/api/studio/projects/${e}/results${i&&`?${i}`}`),enabled:!!e,placeholderData:e=>e,refetchInterval:15e3})}function nr({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)(de,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-3`}),(0,$.jsx)(O,{type:`search`,value:n,onChange:e=>r(e.target.value),placeholder:W(`space.resultsSearch`),"aria-label":W(`space.resultsSearch`),className:`w-full pl-9`})]}),(0,$.jsx)(w,{value:e.mode,onChange:n=>t({...e,mode:n}),options:[{value:``,label:W(`space.resultsModeAll`)},{value:`live`,label:`Live`},{value:`test`,label:`Test`}],className:`w-32`}),(0,$.jsx)(w,{value:String(e.days),onChange:n=>t({...e,days:Number(n)}),options:[{value:`0`,label:W(`space.resultsAnyTime`)},{value:`1`,label:W(`space.resultsDay`)},{value:`7`,label:W(`space.resultsDays`,{n:7})},{value:`30`,label:W(`space.resultsDays`,{n:30})}],className:`w-44`})]})}function rr({data:e,wizardId:t,filter:n,onFilter:r}){let[i,a]=(0,Q.useState)(null),o=t=>e.wizards.find(e=>e.id===t)?.title??``,s=new Intl.DateTimeFormat(g,{dateStyle:`medium`,timeStyle:`short`});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(c,{title:t?o(t):W(`space.resultsAll`),hint:W(`space.resultsHint`),plain:!0,children:[(0,$.jsx)(nr,{filter:n,onFilter:r}),e.runs.length?(0,$.jsx)(A,{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?s.format(new Date(e.doneAt)):o(e.wizardId)}),(0,$.jsxs)(`div`,{className:`truncate text-[0.75rem] text-ink-3`,children:[t?null:`${s.format(new Date(e.doneAt))} · `,W(`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:W(`space.resultFiles`,{n:e.assets}),children:[(0,$.jsx)(Ce,{className:`size-3.5`}),e.assets]}):null,e.mode===`test`?(0,$.jsx)(X,{children:W(`run.testChip`)}):(0,$.jsxs)(X,{tone:`live`,children:[`Live v`,e.version]})]},e.id))}):(0,$.jsx)(A,{children:(0,$.jsx)(fe,{children:n.q.trim()||n.mode||n.days?W(`space.resultsNone`):W(`space.resultsEmpty`)})})]}),i?(0,$.jsx)(Ie,{header:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-[0.875rem]`,children:o(i.wizardId)}),i.mode===`test`?(0,$.jsx)(X,{children:W(`run.testChip`)}):(0,$.jsxs)(X,{tone:`live`,children:[`Live v`,i.version]})]}),onClose:()=>a(null),children:(0,$.jsx)(Mt,{runId:i.id,compact:!0},i.id)}):null]})}function ir({project:e,save:t}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(e.name),s=it({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{label:W(`project.rename`),onClick:()=>{o(e.name),r(!0)},children:(0,$.jsx)(b,{className:`size-4`})}),(0,$.jsx)(a,{open:n,onClose:()=>r(!1),title:W(`project.rename`),children:(0,$.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&s.mutate()},children:[(0,$.jsx)(O,{"data-autofocus":!0,value:i,maxLength:80,onChange:e=>o(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)(d,{variant:`ghost`,onClick:()=>r(!1),children:W(`common.cancel`)}),(0,$.jsx)(d,{type:`submit`,busy:s.isPending,disabled:!i.trim(),children:W(`settings.save`)})]})]})})]})}function ar({project:e}){let t=h();return(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ot,{}),e.readOnly?null:(0,$.jsx)(ir,{project:e,save:async n=>{await V.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})}})]})}function or(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=gt(),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 sr(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function cr({groups:e,current:t,onPick:n}){return e.map(e=>{let r=e.sections.map(e=>(0,$.jsx)(St,{icon:e.icon??pt,label:e.label,selected:e.id===t,onPick:()=>n(e.id)},e.id));return e.label?(0,$.jsx)(Tt,{label:e.label,children:r},e.plugin):(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:r},`own`)})}function lr(){let{group:e}=ne(),[t,n]=_e(),r=oe(),i=ce(),{hash:a}=i,{project:o,loading:s}=ht(),l=lt(),u=yt(),d=jt(),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),v=dt(e)?e:void 0,y=v?void 0:u.spaceParts.find(t=>t.id===e),b=v??y?.id,x=i.state?.parts===!0,S=xt(bt(),u).map(e=>({...e,to:`/space/${e.id}`})),C=S.find(e=>e.id===b),w=t.get(`show`),T=b?w?2:1:0,E=d?Math.min(T,1):b&&g!==b&&!x?1:0,ee=wt(E),D=wt(T),O=(0,Q.useMemo)(()=>({slot:f,narrow:d,setDetail:h}),[f,d]),k=o?o.brand.name?.trim()||o.name:W(`nav.project`),A=re(),j=!!A&&!d,M=ut(`typography`)?[]:[`typography`],N=y?u.spaceMenus[y.id]??[]:[],P=y?[{plugin:null,label:null,sections:N}]:v&&v!==`results`?at(v,u,M):[],F=v?at(v,u).filter(e=>e.plugin):[],I=or([...P,...v===`results`?F:[]].flatMap(e=>e.sections.map(e=>e.id))),L=v===`results`&&w&&w!==`all`?w:null,[R,te]=(0,Q.useState)(er),B=tr(v===`results`?o?.id:void 0,L,R),V=B.data?.wizards.find(e=>e.id===L)?.title,H=v===`data`&&w&&w!==`all`||v===`knowledge`&&w&&/^[ptfcvs]:/.test(w)?w:null,U=H?.startsWith(`s:`)?u.spaceSections.find(e=>e.id===H.slice(2)):void 0,G=v===`knowledge`&&H&&/^[ptf]:/.test(H)?H:null,q=Oe(v===`data`?o?.id:void 0),J=Fe(v===`knowledge`?o?.id:void 0),Y=Ve(H?.startsWith(`v:`)?H.slice(2):``),ae=J.data?.categories.find(e=>e.id===(H?.startsWith(`c:`)?H.slice(2):Y.data?.category.id)),se=v===`knowledge`?U?U.label():H?.startsWith(`v:`)?Y.data&&`${Y.data.category.name}: ${Y.data.value}`:H?.startsWith(`c:`)?ae?.name:J.data?.items.find(e=>e.key===H)?.title:q.data?ze(q.data).flatMap(e=>e.items).find(e=>e.key===H)?.title:void 0;mt([{label:W(`nav.project`),to:`/space`},...C?[{label:C.label,to:`/space/${C.id}`}]:[],...C&&(m??V??se)?[{label:m??V??se}]:[]]);let le={p:`page`,t:`table`,f:`file`,c:`category`,v:`category value`,s:`plugin section`};Xe({...v===`data`||v===`results`?{compact:!0}:{},...v===`data`?{suggestions:[{label:W(`assistant.suggest.dataWhat`)},{label:W(`assistant.suggest.dataWho`)},{label:W(`assistant.suggest.dataEdit`)}]}:v===`results`?{suggestions:[{label:W(`assistant.suggest.resultsFailed`)},{label:W(`assistant.suggest.resultsCost`)},{label:W(`assistant.suggest.resultsShare`)}]}:{},...H&&se?{open:{kind:le[H[0]]??`item`,id:H.slice(2),label:se}}:L&&V?{open:{kind:`wizard`,id:L,label:V}}:{}});let ue=v===`results`||v===`data`||H?a.slice(1):w||a.slice(1),de=(0,Q.useRef)(``);if((0,Q.useEffect)(()=>{let e=`${b}#${ue}`;ue&&de.current!==e&&document.getElementById(ue)&&(de.current=e,requestAnimationFrame(()=>sr(ue,!1)))},[b,ue,o?.id,u.spaceSections,N.length]),!b){let t=a.slice(1),n=t?ft(t,u):null;if(n===`knowledge`&&u.spaceSections.some(e=>e.id===t))return(0,$.jsx)(ie,{to:`/space/knowledge?show=s:${t}`,replace:!0});if(n)return(0,$.jsx)(ie,{to:d?`/space/${n}?show=${t}`:{pathname:`/space/${n}`,hash:t},replace:!0});if((t||e)&&u.status!==`ready`)return null;if(e!==void 0||!d)return(0,$.jsx)(ie,{to:`/space/info`,replace:!0,state:{parts:!0}})}if(v===`knowledge`&&!w&&u.spaceSections.some(e=>e.id===a.slice(1)))return(0,$.jsx)(ie,{to:`/space/knowledge?show=s:${a.slice(1)}`,replace:!0});let pe=e=>{if(d){r({search:`?show=${e}`});return}de.current=`${b}#${e}`,sr(e,!0),r({search:``,hash:e},{replace:!0})},X=e=>d?n({show:e}):n(e===`all`?{}:{show:e},{replace:!0}),Z=e=>e.flatMap(e=>e.sections).map(e=>u.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,$.jsx)(K,{id:e.id,children:(0,$.jsx)(c,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,$.jsx)(_t,{of:e,children:(0,$.jsx)(e.component,{})})})},e.serial)),me=d?void 0:I,he=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Et,{title:k,open:E===1?C??null:null,onBack:()=>d?r(`/space`):_(b??null),root:{icon:Ze,label:W(`nav.project`),backLabel:W(`nav.wizards`),onBack:()=>r(`/`)}}),(0,$.jsx)(`div`,{className:z(Ct(ee)),children:E===0?(0,$.jsx)(Ot,{entries:S,current:d?void 0:C,onPick:()=>_(null)}):(0,$.jsx)(`div`,{ref:p})},E)]});return(0,$.jsxs)(Dt.Provider,{value:O,children:[j&&A?(0,$t.createPortal)(he,A):null,(0,$.jsx)(`div`,{className:`animate-rise`,children:(0,$.jsxs)(`div`,{className:z(`grid gap-6`,!j&&`md:grid-cols-[13.5rem_minmax(0,1fr)] md:gap-8 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`),children:[j?null:(0,$.jsx)(`aside`,{className:z(`min-w-0 md:sticky md:top-6 md:self-start`,d&&T===2&&`hidden`,d&&D===`back`&&Ct(`back`)),children:he}),b?(0,$.jsxs)(`div`,{className:z(`min-w-0`,d&&T<2&&`hidden`,d&&D===`deeper`&&Ct(`deeper`)),children:[d?(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(At,{label:C?.label??k,onBack:()=>r(`/space/${b}`)})}):null,l&&o?(0,$.jsx)(`div`,{className:`mb-6`,children:(0,$.jsx)(ar,{project:o})}):null,v===`results`?(0,$.jsxs)(kt,{children:[(0,$.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(St,{icon:Wt,label:W(`space.resultsAll`),selected:!d&&!L,onPick:()=>X(`all`)}),B.data?.wizards.filter(e=>e.results||e.id===L).map(e=>(0,$.jsx)(St,{icon:st,label:e.title,badge:e.results?(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.results}):null,selected:!d&&e.id===L,onPick:()=>X(e.id)},e.id))]}),(0,$.jsx)(cr,{groups:F,current:me,onPick:pe})]}):v===`data`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:W(`data.all`),selected:!d&&!H,onPick:()=>X(`all`)})}),q.data?ze(q.data).map(e=>(0,$.jsx)(Tt,{label:e.label,children:e.items.map(e=>(0,$.jsx)(St,{icon:Ee[e.kind],label:e.title,selected:!d&&e.key===H,onPick:()=>X(e.key)},e.key))},e.key)):null,(0,$.jsx)(cr,{groups:F,current:me,onPick:pe})]}):v===`knowledge`?(0,$.jsxs)(kt,{children:[(0,$.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:(0,$.jsx)(St,{icon:Kt,label:W(`know.all`),selected:!(d||H),onPick:()=>X(`all`)})}),J.data?.categories.length?(0,$.jsx)(Tt,{label:W(`know.categories`),children:J.data.categories.map(e=>(0,$.jsx)(St,{icon:Me[e.type],label:e.name,badge:(0,$.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:e.proposed?`·`:e.count}),selected:!d&&(H===`c:${e.id}`||Y.data?.category.id===e.id),onPick:()=>X(`c:${e.id}`)},e.id))}):null,(0,$.jsx)(cr,{groups:F,current:d?void 0:U?.id,onPick:e=>X(`s:${e}`)})]}):(0,$.jsx)(kt,{children:(0,$.jsx)(cr,{groups:P,current:me,onPick:pe})}),o&&(v===`info`||v===`knowledge`)?(0,$.jsxs)($n,{project:o,group:v,children:[v===`knowledge`?G?G.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:G.slice(2),onGone:()=>X(`all`),onOpen:X},G):G.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:G.slice(2),onGone:()=>X(`all`)},G):(0,$.jsx)(pn,{projectId:o.id,fileId:G.slice(2),readOnly:o.readOnly,onGone:()=>X(`all`)},G):J.data?U?(0,$.jsx)(c,{title:U.label(),hint:U.hint?.(),plain:!0,children:(0,$.jsx)(_t,{of:U,children:(0,$.jsx)(U.component,{})})},H):H?.startsWith(`c:`)?ae?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(je,{projectId:o.id,category:ae,readOnly:o.readOnly,onOpen:X,onGone:()=>X(`all`)}),ae.type===`choice`?null:(0,$.jsx)(Be,{projectId:o.id,category:ae,categories:J.data.categories,onOpen:X})]},H):null:H?.startsWith(`v:`)?Y.data?(0,$.jsx)(Te,{value:Y.data,readOnly:o.readOnly,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Y.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:Y.data.items.map(e=>(0,$.jsx)(ke,{item:e,categories:J.data.categories.filter(e=>e.id!==Y.data?.category.id),onOpen:X},e.key))}):null,Y.data.rows.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>X(`t:${e.tableId}`),className:`px-1 text-left text-[0.8125rem] text-ink-3 hover:text-ink`,children:W(`know.tocRows`,{n:e.count,table:e.title})},e.tableId))]})},H):null:(0,$.jsx)(K,{id:`documents`,children:(0,$.jsx)(Re,{projectId:o.id,data:J.data,readOnly:o.readOnly,onOpen:X})}):null:null,v===`info`?Z(F):null]},o.id):null,o&&y?(0,$.jsx)(_t,{of:y,children:(0,$.jsx)(ct,{part:y.id,children:(0,$.jsx)(y.component,{})},o.id)}):null,o&&v===`data`?(0,$.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:H?.startsWith(`t:`)?(0,$.jsx)(Ne,{tableId:H.slice(2),onGone:()=>X(`all`)},H):H?.startsWith(`p:`)?(0,$.jsx)(Pe,{pageId:H.slice(2),onGone:()=>X(`all`)},H):(0,$.jsxs)($.Fragment,{children:[q.data?(0,$.jsx)(Le,{projectId:o.id,data:q.data,readOnly:o.readOnly,onOpen:X}):null,Z(F)]})}):null,o&&v===`results`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[B.data?(0,$.jsx)(rr,{data:B.data,wizardId:L,filter:R,onFilter:te}):null,B.isError?(0,$.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:B.error.message}):null,Z(F)]}):null,o||s?null:(0,$.jsx)(fe,{children:W(`settings.noProject`)})]}):null]})})]})}export{lr as ProjectPage};