UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 10.2 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{AN as t,EN as n,GN as r,JN as i,Js as a,Ys as o,_x as s,dT as c,fN as l,fT as u,mx as d,pN as f,qN as p}from"./_2_____________________________.js";import{B as m,C as h,F as g,I as _,J as v,O as y,Rt as b,S as ee,T as x,U as S,d as C,f as w,g as T,gt as te,j as E,k as D,l as O,m as k,s as ne,u as A,x as j,yt as re}from"./_6____________________.js";import{f as ie,p as ae}from"./_5_________________________.js";import{A as oe}from"./route-controls-runtime-LXiVRSj4.js";import{n as se,t as ce}from"./en-settings-DEvavpke.js";import{c as le,s as ue}from"./state-C_Hf0dVB.js";import{n as de,t as fe}from"./wizard-runner-4KF7fzfY.js";import{a as M,i as N,n as pe,r as me}from"./wizard-step-controls-Cub-DAGP.js";var P;function F(){return(F=e((()=>{P={auth:{dialog:`modelSetup.wizard.dialogLabel`,titleKey:`modelSetup.wizard.title`,starting:`modelSetup.wizard.starting`},prepare:{dialog:`modelSetup.wizard.prepareDialogLabel`,titleKey:`modelSetup.wizard.prepareTitle`,starting:`modelSetup.wizard.prepareStarting`},activate:{dialog:`modelSetup.heading`,titleKey:`modelSetup.heading`,starting:`modelSetup.wizard.checking`}}})))()}function I(e){let t=new Set,n=e=>{t.add(e)},r=()=>[...t].filter(e=>e.isConnected&&e.autofocus).toSorted((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)[0]??null,o=()=>e.admissionPending&&e.state.phase===`idle`?`starting`:e.state.phase;ie(()=>e.state.phase===`step`?`${e.state.step.id}:${e.busy||e.state.busy?`busy`:`ready`}:${e.state.validationError??``}`:`${o()}:${!!e.doneAction}`,{requested:()=>!0,focus:()=>{t=new Set([...t].filter(e=>e.isConnected)),r()?.focus({preventScroll:!0})}});let s=()=>P[e.mode],u=()=>o()===`starting`||o()===`step`,f=()=>e.state.phase===`step`?e.state:void 0,p=()=>{let e=f();if(!e)return!1;let{type:t,options:n}=e.step;return t===`confirm`||t===`multiselect`||t===`note`||t===`action`||t===`text`&&!e.externalAuthInput||t===`select`&&(n?.length??0)<=2},m=g(e=>f()??e),_=()=>{let e=f()?.step;return!!(e&&(e.externalUrl||e.deviceCode))},v=()=>e.state.phase===`error`||e.state.phase===`cancelled`?e.state:void 0;return E(y,{get when(){return o()!==`idle`},get children(){var t=W(),g=t.firstChild;return t.addEventListener(`modal-cancel`,()=>u()?e.onCancel():e.onClose()),t.initialFocus=r,k(()=>t=>e.onDialogRef?.(t),t),t._$owner=b(),C(g,E(y,{get when(){return o()===`done`?`done`:`active`},keyed:!0,get children(){return[E(y,{get when(){return _()},get children(){var t=L();return t._$$click=()=>e.onCancel(),C(t,E(l,{name:`x`})),O(()=>({e:i(`modelSetup.wizard.cancelSignIn`),t:i(`modelSetup.wizard.cancelSignIn`)}),({e,t:n},r)=>{e!==r?.e&&T(t,`aria-label`,e),n!==r?.t&&T(t,`title`,n)}),t}}),E(y,{get when(){return w(()=>o()!==`done`)()&&!_()},get children(){var t=R(),r=t.firstChild;return C(r,()=>e.state.authLabel||f()?.step.title||i(s().titleKey)),C(t,E(d,{size:28,class:`oc-dialog__close`,icon:`x`,get label(){return i(u()?`common.cancel`:`common.close`)},tooltip:!1,ref:n,get autofocus(){return o()!==`step`},onClick:()=>u()?e.onCancel():e.onClose()}),null),t}}),(()=>{var t=H(),r=t.firstChild,u=r.nextSibling,d=u.nextSibling;return C(t,E(h,{get each(){return[e.refreshWarning,e.cancellationNotice,e.state.phase===`starting`?e.state.notice:void 0]},keyed:!1,children:e=>E(y,{get when(){return e()},get children(){return E(c,{tone:`warning`,role:`alert`,get children(){return e()}})}})}),r),C(t,()=>e.cancellationFeedback,u),C(t,E(D,{get children(){return[E(x,{get when(){return o()===`starting`},get children(){var e=z();return e.firstChild,C(e,()=>i(s().starting),null),e}}),E(x,{get when(){return o()===`done`},get children(){var t=V(),n=t.firstChild,r=n.nextSibling;return C(n,E(l,{name:`check`})),C(r,()=>e.doneMessage??i(e.mode===`auth`?`modelSetup.wizard.connected`:`modelSetup.wizard.checking`)),C(t,E(y,{get when(){return e.doneDescription},get children(){var t=B();return C(t,()=>e.doneDescription),t}}),null),t}}),E(x,{get when(){return v()},children:t=>E(y,{get when(){return w(()=>e.mode===`auth`)()&&t().phase===`error`},get fallback(){return E(c,{tone:`danger`,role:`alert`,get children(){return t().message}})},get children(){return E(c,{tone:`danger`,class:`model-setup-wizard__error`,role:`alert`,get children(){return[(()=>{var e=G();return C(e,()=>t().message),e})(),(()=>{var e=K();return C(e,E(a,{get text(){return t().message},get idleLabel(){return i(`modelSetup.wizard.copy`)}})),e})()]}})}})}),E(x,{get when(){return o()===`step`},get children(){return E(y,{get when(){return m()},children:t=>[E(y,{get when(){return t().validationError},get children(){return E(c,{tone:`danger`,id:`model-setup-wizard-validation-error`,role:`alert`,get children(){return t().validationError}})}}),E(pe,{presentation:`model-setup`,get step(){return t().step},get externalAuthInput(){return t().externalAuthInput},get signInIcon(){return e.signInIcon},get brandId(){return e.state.authBrandId},get providerLabel(){return e.state.authLabel},get value(){return e.value},get busy(){return e.busy||t().busy},inputId:`model-setup-wizard-text-input`,get validationErrorId(){return t().validationError?`model-setup-wizard-validation-error`:void 0},get confirmAffirmativeLabel(){return w(()=>e.mode===`prepare`&&t().step.type===`confirm`)()?i(`modelSetup.wizard.continue`):void 0},get leadingAction(){return w(()=>!(!_()&&p()))()?void 0:(()=>{var t=q();return t._$$click=()=>e.onCancel(),C(t,()=>i(`common.cancel`)),t})()},onValueChange:t=>e.onValueChange(t),onAnswer:t=>e.onAnswer(t),onAutofocusRef:n}),E(y,{get when(){return w(()=>!(!e.busy&&!t().busy||t().step.type===`progress`||t().step.externalUrl))()?!t().step.deviceCode:(e.busy||t().busy)&&t().step.type!==`progress`&&!t().step.externalUrl},get children(){var e=z();return e.firstChild,C(e,()=>i(`modelSetup.wizard.working`),null),e}})]})}})]}}),d),t})(),E(y,{get when(){return o()===`done`},get children(){var t=U(),r=t.firstChild;return t._$owner=b(),r._$$click=()=>e.onClose(),k(()=>n,r),C(r,()=>i(`common.close`)),C(t,E(y,{get when(){return w(()=>o()===`done`)()&&e.doneAction},children:e=>(()=>{var t=Y(),r=t.firstChild,i=r.nextSibling;return t._$$click=()=>e().onClick(),k(()=>n,t),C(t,E(y,{get when(){return e().disabled},get children(){return J()}}),r),C(t,()=>e().label,i),O(()=>({e:e().disabled,t:e().disabled?`true`:`false`}),({e,t:n},r)=>{e!==r?.e&&T(t,`disabled`,e),n!==r?.t&&T(t,`aria-busy`,n)}),t})()}),null),O(()=>!e.doneAction,e=>{T(r,`autofocus`,e)}),t}})]}})),O(()=>({e:i(s().dialog),t:e.mode===`auth`,a:o()===`done`,o:!!_()}),({e,t:n,a:r,o:i},a)=>{e!==a?.e&&T(t,`label`,e),n!==a?.t&&g.classList.toggle(`model-setup-wizard--auth`,n),r!==a?.a&&g.classList.toggle(`model-setup-wizard--done`,r),i!==a?.o&&g.classList.toggle(`model-setup-wizard--sign-in`,i)}),t}})}var L,R,z,B,V,H,U,W,G,K,q,J,Y;function X(){return(X=e((()=>{A(),S(),o(),s(),f(),u(),me(),oe(),N(),r(),ae(),F(),L=j(`<button type=button class=model-setup-wizard__close>`),R=j(`<div class=oc-dialog__header><h2 class=oc-dialog__title>`),z=j(`<div class=wizard-step__progress role=status aria-busy=true><span class=wizard-step__spinner aria-hidden=true>`),B=j(`<p class=model-setup-wizard__success-description>`),V=j(`<div class=model-setup-wizard__success role=status><span class=model-setup-wizard__success-icon aria-hidden=true></span><h2 class=model-setup-wizard__success-title>`),H=j(`<div class="oc-dialog__body model-setup-wizard__body"><!><!><!>`),U=j(`<openclaw-modal-actions class="oc-dialog__footer model-setup-wizard__footer"><button type=button class=btn>`,1),W=j(`<openclaw-modal-dialog><div class="oc-dialog model-setup-wizard">`,1),G=j(`<p class=model-setup-wizard__error-text>`),K=j(`<div class=model-setup-wizard__error-copy>`),q=j(`<button type=button class=btn>`),J=j(`<span class=btn__spinner aria-hidden=true>`),Y=j(`<button type=button class="btn primary"data-login-start-chat autofocus><!><!>`),M(),ne([`click`])})))()}function Z(){return(Z=e((()=>{})))()}function he(e){let[t,r]=m({phase:`idle`}),[a,o]=m(),[s,l]=_(!1),[u,d]=m(),f=g(()=>u(),{loadingValue:void 0}),p=null,h=0,v,b,x=!1,S=new fe({...e,onChange:t=>{x||(t.phase===`starting`&&(h+=1),t.phase!==`step`&&(v=void 0,b?.(),b=void 0,d(void 0)),t.phase===`step`&&t.step.id!==p?o(()=>le(t.step)):t.phase!==`step`&&o(void 0),p=t.phase===`step`?t.step.id:null,r(t),(t.phase===`starting`||t.phase===`step`)&&e.onPresentationChange?.())},cancelledMessage:()=>i(`modelSetup.wizard.cancelled`),gatewayNotRespondingMessage:()=>i(`modelSetup.wizard.gatewayNotResponding`)});te(()=>()=>{x=!0,h+=1,v=void 0,b?.(),S.cancel()});function C(){h+=1,v=void 0,S.cancel()}function w(n={}){let r=t();return{mode:n.mode??`auth`,state:r.phase===`step`?{...r,busy:r.busy||!!n.busy}:r,refreshWarning:n.refreshWarning??null,doneMessage:n.doneMessage,doneDescription:n.doneDescription,doneAction:n.doneAction,cancellationFeedback:k,value:a(),onValueChange:e=>{o(()=>e)},onAnswer:e.onAnswer??((e,t)=>void S.answer(e,t)),onCancel:D,onClose:e.onClose}}let T=re(function*(e,t){return l(!0),yield Promise.race([e,t])});function D(){if(v!==void 0||S.state.phase===`done`)return;let t=h;v=t;let n=Promise.withResolvers();b=n.resolve;let r=S.requestCancellation().then(n=>(t===h&&n===`cancelled`&&e.onClose(),n)).finally(()=>{t===h&&(v=void 0,b=void 0)}),i=T(r,n.promise);d(i),i.catch(()=>{})}function O(){return E(y,{get when(){return!s()},get children(){return E(ee,{fallback:t=>E(c,{tone:`warning`,role:`alert`,get children(){return i(`modelSetup.wizard.cancelFailed`,{error:n(t(),e.requestFailedMessage())})}}),get children(){return E(y,{get when(){return f()===`running`},get children(){return E(c,{tone:`warning`,role:`alert`,get children(){return e.finishingMessage?.()??i(`modelProviders.login.finishing`)}})}})}})}})}let k=E(O,{});return{runner:S,state:()=>(t(),S.state),get cancelling(){return s(),v!==void 0},reset:C,viewProps:w}}function ge(e){let t=g(()=>e.controller.viewProps(e.options));var n=Q();return n.addEventListener(`modal-cancel`,e=>e.preventDefault()),C(n,E(I,v(t,{get busy(){return e.busy},get signInIcon(){return e.signInIcon}}))),n}var Q;function $(){return($=e((()=>{A(),S(),N(),ce(),t(),r(),ue(),de(),X(),u(),Q=j(`<div>`),M(),p(se)})))()}export{I as a,Z as i,he as n,X as o,$ as r,ge as t};