@gisce/react-ooui 1.2.0-rc.41 → 1.2.0-rc.42

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.
@@ -307,6 +307,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
307
307
  border-width: 1px;
308
308
  border-style: solid;
309
309
  flex: 1;
310
- `,Tn=e=>{const{targetKeys:r=[],dataSource:a,onLoadData:o,locale:s,onChange:l}=e,[u,c]=React$n.useState(r),[d,f]=React$n.useState([]),[p,m]=React$n.useState([]);React$n.useEffect(()=>{l(u)},[u]);const h=React$n.useCallback(()=>{const y=[...u,...d.filter(w=>!u.includes(w))];c(y),f([])},[d,u]),g=React$n.useCallback(()=>{const y=u.filter(w=>!p.includes(w));c(y),m([])},[p,u]),v=React$n.useCallback(({selectedKeys:y})=>{f(y)},[u]),C=React$n.useCallback(({selectedKeys:y,targetKeys:w})=>{m(y),c(w)},[]),S=React$n.useCallback(y=>{f(y.filter(w=>!u.includes(w)))},[u]),x=React$n.useCallback(y=>{m(y)},[u]);return jsxRuntime.jsxs(antd.Row,{children:[jsxRuntime.jsx(nt,{children:jsxRuntime.jsx(rt,{mode:"left",locale:s,targetKeys:u,dataSource:a,onLoadData:o,onChange:v,selectedKeys:d,setSelectedKeys:S,setTargetKeys:c})}),jsxRuntime.jsx(antd.Col,{flex:.05,children:jsxRuntime.jsx(kn,{toLeftDisabled:p.length===0,toRightDisabled:d.length===0,onToRight:h,onToLeft:g})}),jsxRuntime.jsx(nt,{children:jsxRuntime.jsx(rt,{mode:"right",locale:s,targetKeys:u,dataSource:a,onLoadData:o,onChange:C,selectedKeys:p,setSelectedKeys:x,setTargetKeys:c})})]})},{error:at}=antd.Modal,An=({targetKeys:e,locale:r,onGetFields:a,onGetFieldChilds:o,onChange:s})=>{const[l,u]=React$n.useState(),[c,d]=React$n.useState(!0);React$n.useEffect(()=>{f()},[]);const f=React$n.useCallback(async()=>{d(!0);try{const m=await a();u(m)}catch(m){console.error(m),at({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(m,null,2)})})}d(!1)},[]),p=React$n.useCallback(async({key:m})=>{try{const h=ee(l).find(C=>C.key===m),g=await o({key:m,title:h.title}),v=Wt(l,m,g);u(v)}catch(h){console.error(h),at({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(h,null,2)})})}},[l]);return c?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Tn,{locale:r,dataSource:l,onLoadData:p,targetKeys:e,onChange:s})},ot=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:Dn}=antd.Modal,sa=e=>{const{visible:r,locale:a,onCancel:o,onSucceed:s,totalRegisters:l,selectedRegistersToExport:u,selectedKeys:c,visibleRegisters:d}=e,{modalWidth:f}=Ut(),[p,m]=React$n.useState(!1),[h,g]=React$n.useState("xlsx"),[v,C]=React$n.useState("all"),[S,x]=React$n.useState(c);React$n.useEffect(()=>{r||(x(void 0),g("xlsx"),C(u?"selected":"all"))},[r]),React$n.useEffect(()=>{C(u?"selected":"all")},[u]),React$n.useEffect(()=>{c===void 0||S||x(c)},[c,S]);const y=React$n.useCallback(T=>{x(T)},[]),w=React$n.useCallback(async()=>{m(!0);try{await s({exportType:h,selectedKeys:S,registersAmount:v})}catch(T){console.error(T),Dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(T,null,2)})})}m(!1)},[h,S,v]);return jsxRuntime.jsxs(antd.Modal,{title:A("export",a),centered:!0,width:f,visible:r,closable:!p,onCancel:o,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(An,{targetKeys:S||[],onChange:y,locale:a,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(ot,{}),jsxRuntime.jsx(xn,{locale:a,value:h,onChange:g}),jsxRuntime.jsx(ot,{}),jsxRuntime.jsx(wn,{locale:a,totalRegisters:l,selectedRegistersToExport:u,visibleRegisters:d,value:v,onChange:C}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(Kt,{locale:a,onClose:o,onConfirm:w,loading:p})]})};function Group(e){const{ooui:r,showLabel:a=!0,responsiveBehaviour:o}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r.label&&a?jsxRuntime.jsx(Vt,{label:r.label,children:jsxRuntime.jsx(Container,{container:r.container,responsiveBehaviour:o})}):jsxRuntime.jsx(Container,{container:r.container,responsiveBehaviour:o})})}const{TabPane}=antd.Tabs;function Notebook(e){const{ooui:r,responsiveBehaviour:a}=e,o=r.pages;function s(l){if(l){const u=iconMapper(l);return u&&jsxRuntime.jsx(u,{})}}return jsxRuntime.jsx(antd.Tabs,{defaultActiveKey:"1",tabPosition:r.tabPosition,children:o.filter(l=>!l.invisible).map(l=>jsxRuntime.jsx(TabPane,{tab:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s(l.icon)," ",l.label]}),children:jsxRuntime.jsx(Group,{ooui:l,showLabel:!1,responsiveBehaviour:a})},l.label))})}const{TextArea}=antd.Input,Text$2=e=>{const{ooui:r}=e,{id:a,readOnly:o,required:s,height:l,translatable:u}=r,c=s&&!o?Config.requiredClass:void 0,d=React$n.useContext(FormContext$2),{elementHasLostFocus:f}=d||{};return jsxRuntime.jsx(Field$1,{required:s,...e,children:u?jsxRuntime.jsx(TranslatableText,{field:a,requiredClass:c,height:l}):jsxRuntime.jsx(TextArea,{disabled:o||u,className:c,style:{height:l?l+"px":"100%"},rows:4,onBlur:f})})},TranslatableText=({value:e,field:r,requiredClass:a,onChange:o,height:s})=>{const l=React$n.useContext(FormContext$2),{activeId:u,activeModel:c,fetchValues:d,formHasChanges:f,elementHasLostFocus:p}=l||{},[m,h]=React$n.useState(!1),{t:g}=React$n.useContext(LocaleContext);return u?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:()=>{if(f!=null&&f()){showDialog$7(g("saveBeforeTranslate"));return}m||h(!0)},children:jsxRuntime.jsx(TextArea,{value:e,onChange:v=>{o==null||o(v.target.value)},style:{height:s?s+"px":"100%",cursor:"pointer"},id:r,disabled:!0,className:a,rows:4,onBlur:p})}),jsxRuntime.jsx(TranslationModal,{id:u,model:c,field:r,visible:m,onCloseModal:()=>{h(!1)},onSubmitSucceed:()=>{h(!1),d==null||d()}})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Row,{gutter:8,wrap:!1,children:jsxRuntime.jsx(TextArea,{value:e,onChange:v=>{o==null||o(v.target.value)},style:{height:s?s+"px":"100%"},id:r,className:a,rows:4,onBlur:p})}),jsxRuntime.jsx(antd.Row,{justify:"end",style:{paddingTop:5},children:jsxRuntime.jsx(ButtonWithTooltip,{tooltip:g("translate"),icon:jsxRuntime.jsx(AntIcons.TranslationOutlined,{}),onClick:async()=>{f!=null&&f()?showDialog$7(g("saveBeforeTranslate")):showDialog$7(g("enterTextBeforeTranslate"))},children:g("translate")})})]})},Separator=e=>{const{ooui:r}=e,{label:a}=r;return jsxRuntime.jsx(antd.Divider,{orientation:"left",className:"text-sm",children:a})},ExportModal=e=>{const{visible:r,locale:a,onClose:o,model:s,context:l,selectedRegistersToExport:u,totalRegisters:c,domain:d,limit:f,visibleRegisters:p}=e,m=React$n.useRef({}),h=React$n.useCallback(async C=>{if(C.selectedKeys===void 0||C.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",a));return}let S=d;C.registersAmount==="selected"&&(u==null?void 0:u.length)!==0&&(S=[["id","in",u==null?void 0:u.map(w=>w.id)]]);const{datas:x}=await ConnectionProvider.getHandler().exportData({model:s,fields:C.selectedKeys,domain:S,limit:C.registersAmount==="all"?0:f,context:l,format:C.exportType});o(),await new Promise(w=>setTimeout(w,200));const y=await getMimeType(x);openBase64InNewTab(x,y.mime)},[a,s,d,f,l,o]),g=React$n.useCallback(async()=>{const C=await ConnectionProvider.getHandler().getFields({model:s,context:l,fields:[]});return m.current["/"]=C,convertToExportField({fields:C})},[s,l,m]),v=React$n.useCallback(async({key:C,title:S})=>{let x;const y=C.split("/")[C.split("/").length-1]==="id"?C.split("/").slice(0,-1).join("/"):C;y.indexOf("/")===-1?x=m.current["/"]:x=m.current[getParentKey(y)];const T=x[getChildKey(y)].relation,E=await ConnectionProvider.getHandler().getFields({model:T,context:l,fields:[]});return m.current[y]=E,convertToExportField({fields:E,parentTitle:S,parentKey:y})},[m,s,l]);return jsxRuntime.jsx(sa,{visible:r,locale:a,onSucceed:h,onCancel:o,selectedRegistersToExport:u&&u.length&&u.length>0?u.length:void 0,totalRegisters:c,onGetFieldChilds:v,onGetFields:g,visibleRegisters:p})},convertToExportField=({fields:e,parentKey:r,parentTitle:a})=>{const o=[];for(const s of Object.keys(e)){const l=e[s];if(l.relation&&l.is_function===!0)continue;const u=l.type==="many2one"||l.type==="one2many"||l.type==="many2many";let c=`${r?r+"/":""}${s}`;u&&(c+="/id"),o.push({key:c,title:`${a?a+" \u2192 ":""}${l.string}`,tooltip:l.help,required:l.required,isLeaf:!u})}return o},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const r=e.split("/");return r[r.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:r,showTime:a=!1}=e,{required:o}=r;return jsxRuntime.jsx(Field$1,{required:o,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:r,showTime:a})})},DatePickerInput=e=>{const{value:r,onChange:a,ooui:o,showTime:s}=e,{id:l,readOnly:u,required:c}=o,d=c&&!u?Config.requiredClass:void 0,f=s?"time":"date",p=v=>{a==null||a(v)},m=v=>{if(v===null){p(void 0);return}p(v.format(DatePickerConfig[f].dateInternalFormat))},h=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,g=r?hooks(r,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:u,id:l,showTime:h,className:d,format:DatePickerConfig[f].dateDisplayFormat,value:g,onChange:m})},Date$1=e=>{const{ooui:r}=e;return jsxRuntime.jsx(DatePicker,{ooui:r})},DateTime=e=>{const{ooui:r}=e;return jsxRuntime.jsx(DatePicker,{ooui:r,showTime:!0})},Reference=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:r})})},ReferenceInput=e=>{const{value:r,onChange:a,ooui:o}=e,{required:s,selectionValues:l,readOnly:u}=o,c=r==null?void 0:r.split(","),[d,f]=React$n.useState([]),[p,m]=React$n.useState();return React$n.useEffect(()=>{if(!r)return;const h=r&&c&&c[0],g=r&&c&&c[1]&&parseInt(c[1]);f([g,void 0]),m(h)},[r]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:l,readOnly:u,required:s}),onChange:h=>{m(h),f([]),a==null||a(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:u,required:s}),value:d,onChange:h=>{f(h);const g=`${p},${h[0]}`;g!==r&&(a==null||a(g))}})})]})},Binary=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:r})})},BinaryInput=e=>{const{ooui:r,value:a,onChange:o}=e,{readOnly:s,required:l,filenameField:u}=r,c=l&&!s?Config.requiredClass:void 0,d=React$n.useRef(null),{setFieldValue:f,getFieldValue:p}=React$n.useContext(FormContext$2)||{},{t:m}=React$n.useContext(LocaleContext),h=a?getFilesize(a):"",g=y=>{o==null||o(y)};async function v(){const y=await getMimeType(a),w=`data:${y==null?void 0:y.mime};base64,${a}`,T=document.createElement("a"),E=p(u),O=p("name");T.href=w,T.download=E||O,T.click()}async function C(){const y=await getMimeType(a);openBase64InNewTab(a,y.mime)}async function S(y){y.stopPropagation(),y.preventDefault();const w=y.target.files[0],T=await toBase64(w);g(T),u&&f(u,w.name)}function x(){f(u,void 0),g(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:d,style:{display:"none"},onChange:S}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:c,value:h})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.FolderOpenOutlined,{}),disabled:s,onClick:()=>{d.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.EyeOutlined,{}),disabled:!a,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!a,onClick:v,icon:jsxRuntime.jsx(AntIcons.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!a,onClick:x,icon:jsxRuntime.jsx(AntIcons.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(AntIcons.TableOutlined,{}),form:jsxRuntime.jsx(AntIcons.FormOutlined,{}),graph:jsxRuntime.jsx(AntIcons.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(AntIcons.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(AntIcons.FormOutlined,{}):jsxRuntime.jsx(AntIcons.FormOutlined,{})}function ChangeViewButton(e){const{currentView:r,availableViews:a,onChangeView:o,disabled:s=!1,formHasChanges:l=!1,previousView:u}=e,{t:c,lang:d}=React$n.useContext(LocaleContext);function f(){const h=a.map((g,v)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(g)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:g.type==="graph"?g.name:g.type.charAt(0).toUpperCase()+g.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(AntIcons.CheckOutlined,{style:{opacity:r.view_id===g.view_id?1:0}})})]})},g.view_id||v));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:c("viewAs"),children:h})})}function p(h){if(l){showDialog$6({lang:d,onOk:()=>{h()}});return}h()}function m(h){p(()=>{const g=a.find(v=>v.view_id===parseInt(h.key));o(g)})}return jsxRuntime.jsxs("div",{style:{display:"flex"},children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:u?c("viewAs")+" "+c(u.type):"",icon:getIconForView(u),style:{width:50},onClick:()=>{m({key:u==null?void 0:u.view_id})},disabled:s||a.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||a.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(AntIcons.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:h=>h.preventDefault()})})]})}function DropdownButton(e){const{icon:r,tooltip:a,items:o=[],onItemClick:s,label:l,disabled:u=!1}=e;function c(){const f=o==null?void 0:o.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:d,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:a,children:f})})}function d(f){const p=o.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:c(),disabled:u||!o||o.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[r," ",l," ",jsxRuntime.jsx(AntIcons.DownOutlined,{})]})})}function ActionButton(e){const{onClick:r,disabled:a=!1,loading:o=!1,tooltip:s,icon:l,label:u,type:c="default"}=e,d=o?jsxRuntime.jsx(AntIcons.LoadingOutlined,{}):l;return jsxRuntime.jsxs(ButtonWithTooltip,{type:c,tooltip:s,onClick:r,disabled:a,children:[d,u]})}function NewButton(e){const{disabled:r=!1}=e,{formHasChanges:a,onNewClicked:o}=React$n.useContext(ActionViewContext),{t:s,lang:l}=React$n.useContext(LocaleContext),u=()=>{if(a){showDialog$6({lang:l,onOk:()=>{o()}});return}o()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.FileAddOutlined,{}),tooltip:s("new"),onClick:u,disabled:r})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:r,lang:a})=>{confirm({title:tForLang("unsavedChanges",a),icon:jsxRuntime.jsx(AntIcons.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",a),okText:tForLang("discardAndRefresh",a),cancelText:tForLang("cancel",a),onOk:e,onCancel:r})};async function showLogInfo(e,r,a){const o=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[r]}))[0],{create_date:s,create_uid:l,id:u,write_date:c,write_uid:d}=o;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+u," ",jsxRuntime.jsx("br",{}),a("createdBy")+": "+l[1]," ",jsxRuntime.jsx("br",{}),a("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),a("lastUpdatedBy")+": "+d[1]," ",jsxRuntime.jsx("br",{}),a("lastUpdatedDate")+": "+c]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:r,disabled:a}=e,{t:o}=React$n.useContext(LocaleContext),[s,l]=React$n.useState(!1),u=jsxRuntime.jsxs(antd.Button,{disabled:a,children:[jsxRuntime.jsx(AntIcons.LinkOutlined,{}),`(${r})`,jsxRuntime.jsx(AntIcons.DownOutlined,{style:{fontSize:12}})]});return a?u:jsxRuntime.jsx(antd.Popover,{onVisibleChange:c=>l(c),visible:s,placement:"bottom",content:Content$1(e,l),title:o("attachments"),arrowContent:null,children:u})},Content$1=(e,r)=>{const{attachments:a=[],loading:o,onAddNewAttachment:s,onopenAttachmentLink:l,onOpenAttachmentDetail:u,onListAllAttachments:c}=e,{t:d}=React$n.useContext(LocaleContext);return o?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{r(!1),c()},children:[jsxRuntime.jsx(AntIcons.TableOutlined,{})," ",d("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{r(!1),s()},children:[jsxRuntime.jsx(AntIcons.FileAddOutlined,{})," ",d("addNewAttachment")]}),a.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),a.map(f=>{const p=f.link?AntIcons.LinkOutlined:AntIcons.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?d("openAttachmentLink"):d("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{r(!1),l(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:d("openAttachment"),children:jsxRuntime.jsx(AntIcons.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{r(!1),u(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:r,disabled:a=!1,onAddNewAttachment:o,onListAllAttachments:s,onViewAttachmentDetails:l}=e,{formRef:u}=React$n.useContext(ActionViewContext),[c,d]=React$n.useState(!1),[f,p]=React$n.useState([]),[m,h]=React$n.useState(!1),{t:g}=React$n.useContext(LocaleContext),v=React$n.useCallback(async()=>{d(!0);try{const x=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:r.map(y=>y.id),fieldsToRetrieve:["name","datas_fname","link"],context:u.current.getContext()});p(x.map(y=>({id:y.id,name:y.name,datas_fname:y.datas_fname,link:y.link})))}catch(x){showDialog$8(x)}d(!1)},r),C=React$n.useCallback(async x=>{if(x.link){window.open(x.link);return}h(!0);let y;try{y=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[x.id],context:u.current.getContext()}))[0]}catch(w){showDialog$8(w)}if(h(!1),!!y)if(y.datas){const w=await getMimeType(y.datas);openBase64InNewTab(y.datas,w.mime)}else l(y)},[]),S=React$n.useCallback(async x=>{l(x)},[]);return React$n.useEffect(()=>{v()},[v]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:r.length,attachments:f,disabled:a,loading:c,onAddNewAttachment:o,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:S}),jsxRuntime.jsx(antd.Modal,{title:g("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:r,currentView:a,setCurrentView:o,onFormSave:s,formHasChanges:l,formIsSaving:u,currentId:c,results:d,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:h,setRemovingItem:g,removingItem:v,duplicatingItem:C,setDuplicatingItem:S,setResults:x,formIsLoading:y,attachments:w,formRef:T,setFormHasChanges:E,previousView:O,setPreviousView:G,goToResourceId:P}=React$n.useContext(ActionViewContext),{t:M,lang:L}=React$n.useContext(LocaleContext),W=React$n.useContext(ContentRootContext),{processAction:B}=W||{},N=React$n.useContext(TabManagerContext),{openRelate:J,openDefaultActionForModel:U}=N||{},H=React$n.useRef(!1);React$n.useEffect(()=>{!u&&H.current&&antd.message.success(M("savedRegisters")),H.current=u||!1},[u]);function K(z){if(l){showDialog({lang:L,onOk:()=>{z()}});return}z()}function re(z){if(l){showDialog$6({lang:L,onOk:()=>{z()}});return}z()}function ie(){d&&d.length>p+1?(f==null||f(p+1),m==null||m(d[p+1].id)):d&&p+1===d.length&&(f==null||f(0),m==null||m(d[0].id))}function ne(){d&&p>0?(f==null||f(p-1),m==null||m(d[p-1].id)):d&&p===0&&(f==null||f(d.length-1),m==null||m(d[d.length-1].id))}function Q(){showDialog$9({confirmMessage:M("confirmRemoveItem"),lang:L,onOk:()=>{ae()}})}async function ae(){try{g==null||g(!0),await ConnectionProvider.getHandler().delete({model:h,ids:[c]});const z=d==null?void 0:d.filter(me=>me.id!==c);x==null||x(z);let te=0;p>0&&p<=d.length-1&&(te=p-1),z!=null&&z[te]?(m==null||m(z==null?void 0:z[te].id),f==null||f(te)):(m==null||m(void 0),f==null||f(void 0))}catch(z){showDialog$3(JSON.stringify(z))}finally{g==null||g(!1)}}async function oe(){try{S==null||S(!0);const z=await ConnectionProvider.getHandler().duplicate({id:c,model:h,context:T.current.getContext()});z&&await(P==null?void 0:P(z))}catch(z){showDialog$3(JSON.stringify(z))}finally{S==null||S(!1)}}const ce=u||v||y||C;function he(z){B==null||B({actionData:z,values:T.current.getValues(),fields:T.current.getFields(),context:T.current.getContext(),onRefreshParentValues:()=>{T.current.fetchValues()}})}return a?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[y&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:u||y||v||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.SaveOutlined,{}),tooltip:M("save"),disabled:!l||ce,loading:u,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.CopyOutlined,{}),tooltip:M("duplicate"),disabled:l||u||c===void 0||C||y,loading:C,onClick:oe}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.DeleteOutlined,{}),tooltip:M("delete"),disabled:u||c===void 0||v||C||y,loading:v,onClick:Q}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.InfoCircleOutlined,{}),tooltip:M("showLogs"),disabled:u||c===void 0||v||C||y,loading:!1,onClick:()=>{showLogInfo(h,c,M)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:M("refresh"),disabled:u||c===void 0||v||C||y,loading:!1,onClick:()=>{K(()=>{T.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:a,previousView:O,availableViews:r,onChangeView:z=>{G==null||G(a),E==null||E(!1),o==null||o(z)},disabled:ce,formHasChanges:l}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.LeftOutlined,{}),tooltip:M("previous"),disabled:ce,loading:!1,onClick:()=>{re(ne)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.RightOutlined,{}),tooltip:M("next"),disabled:ce,loading:!1,onClick:()=>{re(ie)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.ThunderboltOutlined,{}),disabled:ce,tooltip:M("actions"),items:e==null?void 0:e.action,onItemClick:async z=>{!z||!(await saveNewDocumentIfNeeded({onFormSave:s,currentId:c})).succeed||he(z)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.PrinterOutlined,{}),disabled:ce,tooltip:M("reports"),items:e==null?void 0:e.print,onItemClick:async z=>{if(!z)return;const te=await saveNewDocumentIfNeeded({onFormSave:s,currentId:c});!te.succeed||he({...z,datas:{...z.datas||{},ids:[te.currentId]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.EnterOutlined,{}),disabled:ce,tooltip:M("related"),items:e==null?void 0:e.relate,onItemClick:async z=>{!z||!(await saveNewDocumentIfNeeded({onFormSave:s,currentId:c})).succeed||J({relateData:z,values:T.current.getValues(),fields:T.current.getFields(),action_id:z.id,action_type:z.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:ce,attachments:w,onAddNewAttachment:async()=>{const z=await saveNewDocumentIfNeeded({onFormSave:s,currentId:c});if(!z.succeed)return;const te=z.currentId,me=h;U({model:"ir.attachment",values:{selection_associated_object:`${me},${te}`},forced_values:{res_model:me,res_id:te},initialViewType:"form"})},onListAllAttachments:async()=>{const z=await saveNewDocumentIfNeeded({onFormSave:s,currentId:c});if(!z.succeed)return;const te=z.currentId;U({model:"ir.attachment",domain:[["res_model","=",`${h}`],["res_id","=",`${te}`]],initialViewType:"tree"})},onViewAttachmentDetails:async z=>{!(await saveNewDocumentIfNeeded({onFormSave:s,currentId:c})).succeed||U({model:"ir.attachment",res_id:z.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}async function saveNewDocumentIfNeeded({onFormSave:e,currentId:r}){if(r!==void 0)return{succeed:!0,currentId:r};const a=await(e==null?void 0:e());return a!=null&&a.succeed?{succeed:!0,currentId:a.id}:{succeed:!1,currentId:void 0}}const LinkInput=e=>{const{ooui:r,value:a,onChange:o,valueValidator:s,linkPrefix:l=""}=e,{id:u,readOnly:c,required:d}=r,f=d&&!c?Config.requiredClass:void 0,p=React$n.useContext(FormContext$2),{elementHasLostFocus:m}=p||{},[h,g]=React$n.useState(!1),[v,C]=React$n.useState(!1);React$n.useEffect(()=>{c&&!h&&C(!1),!a&&!c&&(g(!0),C(!0))},[h,c]);const S=x=>{o==null||o(x.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[c?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:h?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.CheckOutlined,{}),onClick:()=>{s(a)&&(g(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.EditOutlined,{}),onClick:()=>{g(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:v?jsxRuntime.jsx(antd.Input,{id:u,onChange:S,className:f,value:a,onBlur:()=>{s(a)&&(g(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${l}${a}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:a})})]})},Url=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(LinkInput,{ooui:r,valueValidator:o=>o?isURL(o):!1})})},Email=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(LinkInput,{ooui:r,linkPrefix:"mailto:",valueValidator:o=>o?isEmail(o):!1})})},GoToResourceModal=e=>{const{visible:r,onIdSubmitted:a,onCancel:o,isSearching:s}=e,{t:l}=React$n.useContext(LocaleContext);function u(c){a(c.id)}return jsxRuntime.jsx(antd.Modal,{title:l("goToResourceId"),centered:!0,visible:r,footer:null,destroyOnClose:!0,onCancel:o,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:u,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:l("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.CloseOutlined,{}),htmlType:"button",onClick:o,disabled:s,children:l("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(AntIcons.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:l("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:r=0,...a}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[r>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:r})}),jsxRuntime.jsx(ButtonWithTooltip,{...a,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:r}=React$n.useContext(LocaleContext),{availableViews:a,currentView:o,setCurrentView:s,searchParams:l,searchVisible:u,setSearchVisible:c,graphIsLoading:d,previousView:f,setPreviousView:p}=React$n.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(AntIcons.FilterOutlined,{style:{color:u?"white":void 0}}),tooltip:r("advanced_search"),type:u?"primary":"default",onClick:()=>{c==null||c(!u)},disabled:d,badgeNumber:l==null?void 0:l.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:r("refresh"),disabled:d,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:o,availableViews:a,onChangeView:m=>{p==null||p(o),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:r,children:a}=e,{title:o,currentView:s,currentId:l,currentItemIndex:u,results:c,totalItems:d,selectedRowItems:f}=React$n.useContext(ActionViewContext),{t:p}=React$n.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return l?d===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:l}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",u===void 0?1:u+1," /"," ",c.length," ",p("of")," ",d," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:l}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(h=>h.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:r||o}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:a})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:r,visible:a,model:o,context:s,domain:l,formView:u,treeView:c}=e,d=React$n.useRef(),f=React$n.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:h=void 0,results:g=void 0,setSelectedRowItems:v=void 0,setSearchParams:C=void 0,searchVisible:S=!0,setSearchVisible:x=void 0,sorter:y=void 0,setSorter:w=void 0,setTotalItems:T=void 0,setSearchTreeNameSearch:E=void 0,setTreeIsLoading:O=void 0,limit:G,setLimit:P,searchParams:M,searchValues:L,setSearchValues:W,currentView:B}=f||{},[N,J]=React$n.useState(!0);React$n.useEffect(()=>{var ne;(ne=d.current)==null||ne.refresh()},[M]),React$n.useEffect(()=>{r.view_id!==B.view_id&&J(!0)},[B]);const{clear:U,searchFilterLoading:H,searchError:K,offset:re,tableRefreshing:ie}=useSearch({model:o,setSearchTreeNameSearch:E,setSelectedRowItems:v,searchParams:M,setSearchValues:W,setSearchParams:C,setSearchVisible:x,setTreeIsLoading:O,context:s,formView:u,treeView:c,sorter:y,setSorter:w,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:g,domain:l,currentId:h,setActionViewTotalItems:T,limit:G,setLimit:P});return!a||!r?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:r.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{d.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...c.fields,...u.fields},searchFields:mergeSearchFields([u.search_fields,c.search_fields]),limit:G,onClear:U,offset:re,isSearching:H,onSubmit:ne=>{J(!1),C==null||C(ne.params),x==null||x(!1)},searchError:K,searchVisible:S,searchValues:L,showLimitOptions:!1}),ie?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:d,view_id:r.view_id,model:o,context:s,domain:mergeParams(M||[],l),limit:N?G:void 0,manualIds:N?g==null?void 0:g.map(ne=>ne.id):void 0})]})},FormActionView=e=>{const{visible:r,formRef:a,model:o,currentId:s,domain:l,formView:u,context:c,defaultValues:d,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:h}=e;return r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:u==null?void 0:u.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:a,model:o,defaultValues:d,forcedValues:f,formView:u,actionDomain:l,id:s,parentContext:c,onSubmitSucceed:(g,v)=>{p.findIndex(S=>S.id===g)===-1&&(p.push(v),m(p),h(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:r,disabled:a=!1,searchText:o}=e,{t:s}=React$n.useContext(LocaleContext),[l]=antd.Form.useForm(),[u,c]=React$n.useState(!1);function d(p){r(p.search)}React$n.useEffect(()=>{l.setFieldsValue({search:o})},[o]);function f(){c(!1),l.setFieldsValue({search:void 0}),r(void 0)}return jsxRuntime.jsx(antd.Form,{form:l,onFinish:d,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:a,onChange:p=>{c(p.target.value.length>0)},suffix:(u||o&&o.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(AntIcons.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:a,children:s("search")})})]})})}function TreeActionBar(e){var ae;const{availableViews:r,currentView:a,setCurrentView:o,selectedRowItems:s,setRemovingItem:l,removingItem:u,duplicatingItem:c,setDuplicatingItem:d,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:h,searchParams:g,searchVisible:v,setSearchVisible:C,setSearchTreeNameSearch:S,searchTreeNameSearch:x,treeIsLoading:y,setPreviousView:w,previousView:T,results:E,limit:O,totalItems:G}=React$n.useContext(ActionViewContext),{parentContext:P={},treeExpandable:M,toolbar:L}=e,{t:W,lang:B}=React$n.useContext(LocaleContext),N=React$n.useContext(ContentRootContext),{processAction:J}=N||{},[U,H]=React$n.useState(!1),K=x!==void 0&&x.trim().length>0;function re(){showDialog$9({confirmMessage:W("confirmRemove"),lang:B,onOk:()=>{ie()}})}async function ie(){var oe;try{l==null||l(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(ce=>ce.id)}),m==null||m(void 0),h==null||h(void 0),(oe=p==null?void 0:p.current)==null||oe.refreshResults()}catch(ce){showDialog$8(ce)}finally{l==null||l(!1)}}async function ne(){var oe;try{d==null||d(!0);const ce=s[0].id;await ConnectionProvider.getHandler().duplicate({id:ce,model:f,context:{...P}})&&((oe=p==null?void 0:p.current)==null||oe.refreshResults())}catch(ce){showDialog$8(ce)}finally{d==null||d(!1)}}function Q(oe){J==null||J({actionData:oe,values:{active_id:s==null?void 0:s.map(ce=>ce.id)[0],active_ids:s==null?void 0:s.map(ce=>ce.id)},fields:{},context:{...P,active_id:s==null?void 0:s.map(ce=>ce.id)[0],active_ids:s==null?void 0:s.map(ce=>ce.id)},onRefreshParentValues:()=>{var ce;(ce=p==null?void 0:p.current)==null||ce.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[M?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:c||u||y,searchText:x,onSearch:oe=>{oe&&oe.trim().length>0?S==null||S(oe):S==null||S(void 0)}}),!M&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(AntIcons.FilterOutlined,{style:{color:v?"white":void 0}}),tooltip:W("advanced_search"),type:v?"primary":"default",onClick:()=>{C==null||C(!v)},disabled:c||u||y,badgeNumber:g==null?void 0:g.length}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:y}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.CopyOutlined,{}),tooltip:W("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||c||y,loading:c,onClick:ne}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.DeleteOutlined,{}),tooltip:W("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||y,loading:u,onClick:re}),separator$1()]}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.InfoCircleOutlined,{}),tooltip:W("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||y,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,W)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:W("refresh"),disabled:c||u||y,loading:!1,onClick:()=>{var oe;(oe=p==null?void 0:p.current)==null||oe.refreshResults()}}),!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:oe=>{w==null||w(a),o==null||o(oe)},previousView:T,disabled:y})]}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||y,tooltip:W("actions"),items:L==null?void 0:L.action,onItemClick:oe=>{!oe||Q(oe)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||y,tooltip:W("reports"),items:L==null?void 0:L.print,onItemClick:oe=>{!oe||Q({...oe,datas:{...oe.datas||{},ids:s.map(ce=>ce.id)}})}}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons__default.default,{component:()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24",strokeWidth:"1.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),jsxRuntime.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),jsxRuntime.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:W("export"),items:[{id:"print_screen",name:W("printScreen")},{id:"export",name:W("advancedExport")}],onItemClick:oe=>{if(oe.id==="print_screen"){let ce=(s==null?void 0:s.map(he=>he.id))||[];ce.length===0&&(ce=(E==null?void 0:E.map(he=>he.id))||[]),Q({id:-1,model:f,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:f,ids:ce}});return}H(!0)},disabled:c||u||y||K}),jsxRuntime.jsx(ExportModal,{visible:U,locale:B,onClose:()=>H(!1),model:f,domain:mergeParams(((ae=p==null?void 0:p.current)==null?void 0:ae.getDomain())||[],g||[]),limit:O,totalRegisters:G||0,selectedRegistersToExport:s,visibleRegisters:(E==null?void 0:E.length)||0,context:P})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:r,searchTreeRef:a,model:o,context:s,formView:l,treeView:u,domain:c,setCurrentItemIndex:d,results:f,setCurrentId:p,setCurrentView:m,availableViews:h,searchTreeNameSearch:g}=e,{currentView:v,setPreviousView:C}=React$n.useContext(ActionViewContext);return r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:u==null?void 0:u.toolbar,parentContext:s,treeExpandable:(u==null?void 0:u.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:a,rootTree:!0,model:o,parentContext:s,nameSearch:g,formView:l,treeView:u,domain:c,onRowClicked:S=>{const{id:x}=S;p(x);const y=f.findIndex(T=>T.id===x);C==null||C(v),d(y);const w=h.find(T=>T.type==="form");m(w)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[r,a]=React$n.useState(!1),[o,s]=React$n.useState(!1),{children:l,dashboardRef:u,openAction:c}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:r,setIsLoading:a,dashboardRef:u,openAction:c,moveItemsEnabled:o,setMoveItemsEnabled:s},children:l})};function DashboardActionBar(){const{isLoading:e,dashboardRef:r,moveItemsEnabled:a,setMoveItemsEnabled:o}=React$n.useContext(DashboardActionContext),{t:s}=React$n.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.BorderOuterOutlined,{style:{color:a?"white":void 0}}),type:a?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{o(!a)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{r==null||r.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{r==null||r.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:r}=e,a=React$n.useRef(),o=React$n.useContext(TabManagerContext),{openShortcut:s}=o||{};return r?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:a,openAction:l=>{s(l)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:a,model:r.model,id:r.id,context:r==null?void 0:r.context,configAction:r==null?void 0:r.configAction})]}):null};function ActionView(e,r){const{domain:a,model:o,context:s,views:l,title:u,setCanWeClose:c,tabKey:d,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:h=!1,action_id:g,action_type:v,treeExpandable:C=!1,limit:S}=e,[x,y]=React$n.useState(),[w,T]=React$n.useState([]),[E,O]=React$n.useState(!0),G=h||void 0,[P,M]=React$n.useState(G),[L,W]=React$n.useState([]),[B,N]=React$n.useState(),[J,U]=React$n.useState([]),[H,K]=React$n.useState(),[re,ie]=React$n.useState(0),[ne,Q]=React$n.useState(!1),[ae,oe]=React$n.useState(!1),[ce,he]=React$n.useState(),{t:z}=React$n.useContext(LocaleContext),te=React$n.useRef(),me=React$n.useRef(),ge=React$n.useContext(TabManagerContext),{setCurrentView:Te,setCurrentId:D,tabs:I,activeKey:pe,openAction:Re}=ge||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",qe=>{qe.preventDefault(),et()},[pe,I,x,B,J]);function Oe(qe){M(qe),D==null||D(qe)}function ve(qe){y(qe),Te==null||Te(qe)}React$n.useImperativeHandle(r,()=>({canWeClose:Ae}));const Pe=async()=>{O(!0);const qe=[];for(const _t of l){const[qt,Pt]=_t;let Ze;try{Pt!=="dashboard"&&(Ze=await ConnectionProvider.getHandler().getView({model:o,type:Pt,id:qt,context:s}))}catch(Yt){console.error(`${o} - ${Pt}\xA0- ${JSON.stringify(Yt,null,2)}`);continue}switch(Pt){case"dashboard":{const Yt=l.find(it=>{const[,xt]=it;return xt==="form"});let tr;Yt&&(tr={action_id:g,action_type:v,name:u,res_id:s.active_id,res_model:o,view_id:Yt[0],view_type:Yt[1]}),qe.push({type:"dashboard",id:s.active_id,model:o,context:s,configAction:tr});break}case"form":{qe.push({...Ze,type:Pt});break}case"tree":{qe.push({...Ze,isExpandable:C,type:Pt});break}case"graph":{qe.push({...Ze,type:Pt});break}}}let Ht;!f&&qe.find(_t=>_t.type==="tree")?Ht=qe.find(qt=>qt.type==="tree"):f?Ht=qe.find(qt=>f.id?qt.type===f.type&&qt.view_id===f.id:qt.type===f.type):Ht=qe.find(qt=>qt.type==="form"),Ht||showDialog$8(`Error determining the first view to show.
310
+ `,Tn=e=>{const{targetKeys:r=[],dataSource:a,onLoadData:o,locale:s,onChange:l}=e,[u,c]=React$n.useState(r),[d,f]=React$n.useState([]),[p,m]=React$n.useState([]);React$n.useEffect(()=>{l(u)},[u]);const h=React$n.useCallback(()=>{const y=[...u,...d.filter(w=>!u.includes(w))];c(y),f([])},[d,u]),g=React$n.useCallback(()=>{const y=u.filter(w=>!p.includes(w));c(y),m([])},[p,u]),v=React$n.useCallback(({selectedKeys:y})=>{f(y)},[u]),C=React$n.useCallback(({selectedKeys:y,targetKeys:w})=>{m(y),c(w)},[]),S=React$n.useCallback(y=>{f(y.filter(w=>!u.includes(w)))},[u]),x=React$n.useCallback(y=>{m(y)},[u]);return jsxRuntime.jsxs(antd.Row,{children:[jsxRuntime.jsx(nt,{children:jsxRuntime.jsx(rt,{mode:"left",locale:s,targetKeys:u,dataSource:a,onLoadData:o,onChange:v,selectedKeys:d,setSelectedKeys:S,setTargetKeys:c})}),jsxRuntime.jsx(antd.Col,{flex:.05,children:jsxRuntime.jsx(kn,{toLeftDisabled:p.length===0,toRightDisabled:d.length===0,onToRight:h,onToLeft:g})}),jsxRuntime.jsx(nt,{children:jsxRuntime.jsx(rt,{mode:"right",locale:s,targetKeys:u,dataSource:a,onLoadData:o,onChange:C,selectedKeys:p,setSelectedKeys:x,setTargetKeys:c})})]})},{error:at}=antd.Modal,An=({targetKeys:e,locale:r,onGetFields:a,onGetFieldChilds:o,onChange:s})=>{const[l,u]=React$n.useState(),[c,d]=React$n.useState(!0);React$n.useEffect(()=>{f()},[]);const f=React$n.useCallback(async()=>{d(!0);try{const m=await a();u(m)}catch(m){console.error(m),at({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(m,null,2)})})}d(!1)},[]),p=React$n.useCallback(async({key:m})=>{try{const h=ee(l).find(C=>C.key===m),g=await o({key:m,title:h.title}),v=Wt(l,m,g);u(v)}catch(h){console.error(h),at({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(h,null,2)})})}},[l]);return c?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Tn,{locale:r,dataSource:l,onLoadData:p,targetKeys:e,onChange:s})},ot=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:Dn}=antd.Modal,sa=e=>{const{visible:r,locale:a,onCancel:o,onSucceed:s,totalRegisters:l,selectedRegistersToExport:u,selectedKeys:c,visibleRegisters:d}=e,{modalWidth:f}=Ut(),[p,m]=React$n.useState(!1),[h,g]=React$n.useState("xlsx"),[v,C]=React$n.useState("all"),[S,x]=React$n.useState(c);React$n.useEffect(()=>{r||(x(void 0),g("xlsx"),C(u?"selected":"all"))},[r]),React$n.useEffect(()=>{C(u?"selected":"all")},[u]),React$n.useEffect(()=>{c===void 0||S||x(c)},[c,S]);const y=React$n.useCallback(T=>{x(T)},[]),w=React$n.useCallback(async()=>{m(!0);try{await s({exportType:h,selectedKeys:S,registersAmount:v})}catch(T){console.error(T),Dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(T,null,2)})})}m(!1)},[h,S,v]);return jsxRuntime.jsxs(antd.Modal,{title:A("export",a),centered:!0,width:f,visible:r,closable:!p,onCancel:o,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(An,{targetKeys:S||[],onChange:y,locale:a,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(ot,{}),jsxRuntime.jsx(xn,{locale:a,value:h,onChange:g}),jsxRuntime.jsx(ot,{}),jsxRuntime.jsx(wn,{locale:a,totalRegisters:l,selectedRegistersToExport:u,visibleRegisters:d,value:v,onChange:C}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(Kt,{locale:a,onClose:o,onConfirm:w,loading:p})]})};function Group(e){const{ooui:r,showLabel:a=!0,responsiveBehaviour:o}=e;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r.label&&a?jsxRuntime.jsx(Vt,{label:r.label,children:jsxRuntime.jsx(Container,{container:r.container,responsiveBehaviour:o})}):jsxRuntime.jsx(Container,{container:r.container,responsiveBehaviour:o})})}const{TabPane}=antd.Tabs;function Notebook(e){const{ooui:r,responsiveBehaviour:a}=e,o=r.pages;function s(l){if(l){const u=iconMapper(l);return u&&jsxRuntime.jsx(u,{})}}return jsxRuntime.jsx(antd.Tabs,{defaultActiveKey:"1",tabPosition:r.tabPosition,children:o.filter(l=>!l.invisible).map(l=>jsxRuntime.jsx(TabPane,{tab:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[s(l.icon)," ",l.label]}),children:jsxRuntime.jsx(Group,{ooui:l,showLabel:!1,responsiveBehaviour:a})},l.label))})}const{TextArea}=antd.Input,Text$2=e=>{const{ooui:r}=e,{id:a,readOnly:o,required:s,height:l,translatable:u}=r,c=s&&!o?Config.requiredClass:void 0,d=React$n.useContext(FormContext$2),{elementHasLostFocus:f}=d||{};return jsxRuntime.jsx(Field$1,{required:s,...e,children:u?jsxRuntime.jsx(TranslatableText,{field:a,requiredClass:c,height:l}):jsxRuntime.jsx(TextArea,{disabled:o||u,className:c,style:{height:l?l+"px":"100%"},rows:4,onBlur:f})})},TranslatableText=({value:e,field:r,requiredClass:a,onChange:o,height:s})=>{const l=React$n.useContext(FormContext$2),{activeId:u,activeModel:c,fetchValues:d,formHasChanges:f,elementHasLostFocus:p}=l||{},[m,h]=React$n.useState(!1),{t:g}=React$n.useContext(LocaleContext);return u?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{onClick:()=>{if(f!=null&&f()){showDialog$7(g("saveBeforeTranslate"));return}m||h(!0)},children:jsxRuntime.jsx(TextArea,{value:e,onChange:v=>{o==null||o(v.target.value)},style:{height:s?s+"px":"100%",cursor:"pointer"},id:r,disabled:!0,className:a,rows:4,onBlur:p})}),jsxRuntime.jsx(TranslationModal,{id:u,model:c,field:r,visible:m,onCloseModal:()=>{h(!1)},onSubmitSucceed:()=>{h(!1),d==null||d()}})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Row,{gutter:8,wrap:!1,children:jsxRuntime.jsx(TextArea,{value:e,onChange:v=>{o==null||o(v.target.value)},style:{height:s?s+"px":"100%"},id:r,className:a,rows:4,onBlur:p})}),jsxRuntime.jsx(antd.Row,{justify:"end",style:{paddingTop:5},children:jsxRuntime.jsx(ButtonWithTooltip,{tooltip:g("translate"),icon:jsxRuntime.jsx(AntIcons.TranslationOutlined,{}),onClick:async()=>{f!=null&&f()?showDialog$7(g("saveBeforeTranslate")):showDialog$7(g("enterTextBeforeTranslate"))},children:g("translate")})})]})},Separator=e=>{const{ooui:r}=e,{label:a}=r;return jsxRuntime.jsx(antd.Divider,{orientation:"left",className:"text-sm",children:a})},ExportModal=e=>{const{visible:r,locale:a,onClose:o,model:s,context:l,selectedRegistersToExport:u,totalRegisters:c,domain:d,limit:f,visibleRegisters:p}=e,m=React$n.useRef({}),h=React$n.useCallback(async C=>{if(C.selectedKeys===void 0||C.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",a));return}let S=d;C.registersAmount==="selected"&&(u==null?void 0:u.length)!==0&&(S=[["id","in",u==null?void 0:u.map(w=>w.id)]]);const{datas:x}=await ConnectionProvider.getHandler().exportData({model:s,fields:C.selectedKeys,domain:S,limit:C.registersAmount==="all"?0:f,context:l,format:C.exportType});o(),await new Promise(w=>setTimeout(w,200));const y=await getMimeType(x);openBase64InNewTab(x,y.mime)},[a,s,d,f,l,o]),g=React$n.useCallback(async()=>{const C=await ConnectionProvider.getHandler().getFields({model:s,context:l,fields:[]});return m.current["/"]=C,convertToExportField({fields:C})},[s,l,m]),v=React$n.useCallback(async({key:C,title:S})=>{let x;const y=C.split("/")[C.split("/").length-1]==="id"?C.split("/").slice(0,-1).join("/"):C;y.indexOf("/")===-1?x=m.current["/"]:x=m.current[getParentKey(y)];const T=x[getChildKey(y)].relation,E=await ConnectionProvider.getHandler().getFields({model:T,context:l,fields:[]});return m.current[y]=E,convertToExportField({fields:E,parentTitle:S,parentKey:y})},[m,s,l]);return jsxRuntime.jsx(sa,{visible:r,locale:a,onSucceed:h,onCancel:o,selectedRegistersToExport:u&&u.length&&u.length>0?u.length:void 0,totalRegisters:c,onGetFieldChilds:v,onGetFields:g,visibleRegisters:p})},convertToExportField=({fields:e,parentKey:r,parentTitle:a})=>{const o=[];for(const s of Object.keys(e)){const l=e[s];if(l.relation&&l.is_function===!0)continue;const u=l.type==="many2one"||l.type==="one2many"||l.type==="many2many";let c=`${r?r+"/":""}${s}`;u&&(c+="/id"),o.push({key:c,title:`${a?a+" \u2192 ":""}${l.string}`,tooltip:l.help,required:l.required,isLeaf:!u})}return o},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const r=e.split("/");return r[r.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:r,showTime:a=!1}=e,{required:o}=r;return jsxRuntime.jsx(Field$1,{required:o,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:r,showTime:a})})},DatePickerInput=e=>{const{value:r,onChange:a,ooui:o,showTime:s}=e,{id:l,readOnly:u,required:c}=o,d=c&&!u?Config.requiredClass:void 0,f=s?"time":"date",p=v=>{a==null||a(v)},m=v=>{if(v===null){p(void 0);return}p(v.format(DatePickerConfig[f].dateInternalFormat))},h=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,g=r?hooks(r,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:u,id:l,showTime:h,className:d,format:DatePickerConfig[f].dateDisplayFormat,value:g,onChange:m})},Date$1=e=>{const{ooui:r}=e;return jsxRuntime.jsx(DatePicker,{ooui:r})},DateTime=e=>{const{ooui:r}=e;return jsxRuntime.jsx(DatePicker,{ooui:r,showTime:!0})},Reference=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:r})})},ReferenceInput=e=>{const{value:r,onChange:a,ooui:o}=e,{required:s,selectionValues:l,readOnly:u}=o,c=r==null?void 0:r.split(","),[d,f]=React$n.useState([]),[p,m]=React$n.useState();return React$n.useEffect(()=>{if(!r)return;const h=r&&c&&c[0],g=r&&c&&c[1]&&parseInt(c[1]);f([g,void 0]),m(h)},[r]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:l,readOnly:u,required:s}),onChange:h=>{m(h),f([]),a==null||a(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:u,required:s}),value:d,onChange:h=>{f(h);const g=`${p},${h[0]}`;g!==r&&(a==null||a(g))}})})]})},Binary=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:r})})},BinaryInput=e=>{const{ooui:r,value:a,onChange:o}=e,{readOnly:s,required:l,filenameField:u}=r,c=l&&!s?Config.requiredClass:void 0,d=React$n.useRef(null),{setFieldValue:f,getFieldValue:p}=React$n.useContext(FormContext$2)||{},{t:m}=React$n.useContext(LocaleContext),h=a?getFilesize(a):"",g=y=>{o==null||o(y)};async function v(){const y=await getMimeType(a),w=`data:${y==null?void 0:y.mime};base64,${a}`,T=document.createElement("a"),E=p(u),O=p("name");T.href=w,T.download=E||O,T.click()}async function C(){const y=await getMimeType(a);openBase64InNewTab(a,y.mime)}async function S(y){y.stopPropagation(),y.preventDefault();const w=y.target.files[0],T=await toBase64(w);g(T),u&&f(u,w.name)}function x(){f(u,void 0),g(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:d,style:{display:"none"},onChange:S}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:c,value:h})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.FolderOpenOutlined,{}),disabled:s,onClick:()=>{d.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.EyeOutlined,{}),disabled:!a,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!a,onClick:v,icon:jsxRuntime.jsx(AntIcons.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!a,onClick:x,icon:jsxRuntime.jsx(AntIcons.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(AntIcons.TableOutlined,{}),form:jsxRuntime.jsx(AntIcons.FormOutlined,{}),graph:jsxRuntime.jsx(AntIcons.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(AntIcons.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(AntIcons.FormOutlined,{}):jsxRuntime.jsx(AntIcons.FormOutlined,{})}function ChangeViewButton(e){const{currentView:r,availableViews:a,onChangeView:o,disabled:s=!1,formHasChanges:l=!1,previousView:u}=e,{t:c,lang:d}=React$n.useContext(LocaleContext);function f(){const h=a.map((g,v)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(g)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:g.type==="graph"?g.name:g.type.charAt(0).toUpperCase()+g.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(AntIcons.CheckOutlined,{style:{opacity:r.view_id===g.view_id?1:0}})})]})},g.view_id||v));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:c("viewAs"),children:h})})}function p(h){if(l){showDialog$6({lang:d,onOk:()=>{h()}});return}h()}function m(h){p(()=>{const g=a.find(v=>v.view_id===parseInt(h.key));o(g)})}return jsxRuntime.jsxs("div",{style:{display:"flex"},children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:u?c("viewAs")+" "+c(u.type):"",icon:getIconForView(u),style:{width:50},onClick:()=>{m({key:u==null?void 0:u.view_id})},disabled:s||a.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||a.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(AntIcons.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:h=>h.preventDefault()})})]})}function DropdownButton(e){const{icon:r,tooltip:a,items:o=[],onItemClick:s,label:l,disabled:u=!1}=e;function c(){const f=o==null?void 0:o.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:d,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:a,children:f})})}function d(f){const p=o.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:c(),disabled:u||!o||o.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[r," ",l," ",jsxRuntime.jsx(AntIcons.DownOutlined,{})]})})}function ActionButton(e){const{onClick:r,disabled:a=!1,loading:o=!1,tooltip:s,icon:l,label:u,type:c="default"}=e,d=o?jsxRuntime.jsx(AntIcons.LoadingOutlined,{}):l;return jsxRuntime.jsxs(ButtonWithTooltip,{type:c,tooltip:s,onClick:r,disabled:a,children:[d,u]})}function NewButton(e){const{disabled:r=!1}=e,{formHasChanges:a,onNewClicked:o}=React$n.useContext(ActionViewContext),{t:s,lang:l}=React$n.useContext(LocaleContext),u=()=>{if(a){showDialog$6({lang:l,onOk:()=>{o()}});return}o()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.FileAddOutlined,{}),tooltip:s("new"),onClick:u,disabled:r})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:r,lang:a})=>{confirm({title:tForLang("unsavedChanges",a),icon:jsxRuntime.jsx(AntIcons.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",a),okText:tForLang("discardAndRefresh",a),cancelText:tForLang("cancel",a),onOk:e,onCancel:r})};async function showLogInfo(e,r,a){const o=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[r]}))[0],{create_date:s,create_uid:l,id:u,write_date:c,write_uid:d}=o;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+u," ",jsxRuntime.jsx("br",{}),a("createdBy")+": "+l[1]," ",jsxRuntime.jsx("br",{}),a("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),a("lastUpdatedBy")+": "+d[1]," ",jsxRuntime.jsx("br",{}),a("lastUpdatedDate")+": "+c]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:r,disabled:a}=e,{t:o}=React$n.useContext(LocaleContext),[s,l]=React$n.useState(!1),u=jsxRuntime.jsxs(antd.Button,{disabled:a,children:[jsxRuntime.jsx(AntIcons.LinkOutlined,{}),`(${r})`,jsxRuntime.jsx(AntIcons.DownOutlined,{style:{fontSize:12}})]});return a?u:jsxRuntime.jsx(antd.Popover,{onVisibleChange:c=>l(c),visible:s,placement:"bottom",content:Content$1(e,l),title:o("attachments"),arrowContent:null,children:u})},Content$1=(e,r)=>{const{attachments:a=[],loading:o,onAddNewAttachment:s,onopenAttachmentLink:l,onOpenAttachmentDetail:u,onListAllAttachments:c}=e,{t:d}=React$n.useContext(LocaleContext);return o?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{r(!1),c()},children:[jsxRuntime.jsx(AntIcons.TableOutlined,{})," ",d("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{r(!1),s()},children:[jsxRuntime.jsx(AntIcons.FileAddOutlined,{})," ",d("addNewAttachment")]}),a.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),a.map(f=>{const p=f.link?AntIcons.LinkOutlined:AntIcons.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?d("openAttachmentLink"):d("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{r(!1),l(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:d("openAttachment"),children:jsxRuntime.jsx(AntIcons.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{r(!1),u(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:r,disabled:a=!1,onAddNewAttachment:o,onListAllAttachments:s,onViewAttachmentDetails:l}=e,{formRef:u}=React$n.useContext(ActionViewContext),[c,d]=React$n.useState(!1),[f,p]=React$n.useState([]),[m,h]=React$n.useState(!1),{t:g}=React$n.useContext(LocaleContext),v=React$n.useCallback(async()=>{d(!0);try{const x=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:r.map(y=>y.id),fieldsToRetrieve:["name","datas_fname","link"],context:u.current.getContext()});p(x.map(y=>({id:y.id,name:y.name,datas_fname:y.datas_fname,link:y.link})))}catch(x){showDialog$8(x)}d(!1)},r),C=React$n.useCallback(async x=>{if(x.link){window.open(x.link);return}h(!0);let y;try{y=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[x.id],context:u.current.getContext()}))[0]}catch(w){showDialog$8(w)}if(h(!1),!!y)if(y.datas){const w=await getMimeType(y.datas);openBase64InNewTab(y.datas,w.mime)}else l(y)},[]),S=React$n.useCallback(async x=>{l(x)},[]);return React$n.useEffect(()=>{v()},[v]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:r.length,attachments:f,disabled:a,loading:c,onAddNewAttachment:o,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:S}),jsxRuntime.jsx(antd.Modal,{title:g("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:r,currentView:a,setCurrentView:o,onFormSave:s,formHasChanges:l,formIsSaving:u,currentId:c,results:d,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:h,setRemovingItem:g,removingItem:v,duplicatingItem:C,setDuplicatingItem:S,setResults:x,formIsLoading:y,attachments:w,formRef:T,setFormHasChanges:E,previousView:O,setPreviousView:G,goToResourceId:P}=React$n.useContext(ActionViewContext),{t:M,lang:L}=React$n.useContext(LocaleContext),W=React$n.useContext(ContentRootContext),{processAction:B}=W||{},N=React$n.useContext(TabManagerContext),{openRelate:J,openDefaultActionForModel:U}=N||{},H=React$n.useRef(!1);React$n.useEffect(()=>{!u&&H.current&&antd.message.success(M("savedRegisters")),H.current=u||!1},[u]);function K(z){if(l){showDialog({lang:L,onOk:()=>{z()}});return}z()}function re(z){if(l){showDialog$6({lang:L,onOk:()=>{z()}});return}z()}function ie(){d&&d.length>p+1?(f==null||f(p+1),m==null||m(d[p+1].id)):d&&p+1===d.length&&(f==null||f(0),m==null||m(d[0].id))}function ne(){d&&p>0?(f==null||f(p-1),m==null||m(d[p-1].id)):d&&p===0&&(f==null||f(d.length-1),m==null||m(d[d.length-1].id))}function Q(){showDialog$9({confirmMessage:M("confirmRemoveItem"),lang:L,onOk:()=>{ae()}})}async function ae(){try{g==null||g(!0),await ConnectionProvider.getHandler().delete({model:h,ids:[c]});const z=d==null?void 0:d.filter(me=>me.id!==c);x==null||x(z);let te=0;p>0&&p<=d.length-1&&(te=p-1),z!=null&&z[te]?(m==null||m(z==null?void 0:z[te].id),f==null||f(te)):(m==null||m(void 0),f==null||f(void 0))}catch(z){showDialog$3(JSON.stringify(z))}finally{g==null||g(!1)}}async function oe(){try{S==null||S(!0);const z=await ConnectionProvider.getHandler().duplicate({id:c,model:h,context:T.current.getContext()});z&&await(P==null?void 0:P(z))}catch(z){showDialog$3(JSON.stringify(z))}finally{S==null||S(!1)}}const ce=u||v||y||C;function he(z){B==null||B({actionData:z,values:T.current.getValues(),fields:T.current.getFields(),context:T.current.getContext(),onRefreshParentValues:()=>{T.current.fetchValues()}})}return a?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[y&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:u||y||v||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.SaveOutlined,{}),tooltip:M("save"),disabled:!l||ce,loading:u,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.CopyOutlined,{}),tooltip:M("duplicate"),disabled:l||u||c===void 0||C||y,loading:C,onClick:oe}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.DeleteOutlined,{}),tooltip:M("delete"),disabled:u||c===void 0||v||C||y,loading:v,onClick:Q}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.InfoCircleOutlined,{}),tooltip:M("showLogs"),disabled:u||c===void 0||v||C||y,loading:!1,onClick:()=>{showLogInfo(h,c,M)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:M("refresh"),disabled:u||c===void 0||v||C||y,loading:!1,onClick:()=>{K(()=>{T.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:a,previousView:O,availableViews:r,onChangeView:z=>{G==null||G(a),E==null||E(!1),o==null||o(z)},disabled:ce,formHasChanges:l}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.LeftOutlined,{}),tooltip:M("previous"),disabled:ce,loading:!1,onClick:()=>{re(ne)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.RightOutlined,{}),tooltip:M("next"),disabled:ce,loading:!1,onClick:()=>{re(ie)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.ThunderboltOutlined,{}),disabled:ce,tooltip:M("actions"),items:e==null?void 0:e.action,onItemClick:async z=>{!z||!(await saveDocument({onFormSave:s})).succeed||he(z)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.PrinterOutlined,{}),disabled:ce,tooltip:M("reports"),items:e==null?void 0:e.print,onItemClick:async z=>{if(!z)return;const te=await saveDocument({onFormSave:s});!te.succeed||he({...z,datas:{...z.datas||{},ids:[te.currentId]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.EnterOutlined,{}),disabled:ce,tooltip:M("related"),items:e==null?void 0:e.relate,onItemClick:async z=>{!z||!(await saveDocument({onFormSave:s})).succeed||J({relateData:z,values:T.current.getValues(),fields:T.current.getFields(),action_id:z.id,action_type:z.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:ce,attachments:w,onAddNewAttachment:async()=>{const z=await saveDocument({onFormSave:s});if(!z.succeed)return;const te=z.currentId,me=h;U({model:"ir.attachment",values:{selection_associated_object:`${me},${te}`},forced_values:{res_model:me,res_id:te},initialViewType:"form"})},onListAllAttachments:async()=>{const z=await saveDocument({onFormSave:s});if(!z.succeed)return;const te=z.currentId;U({model:"ir.attachment",domain:[["res_model","=",`${h}`],["res_id","=",`${te}`]],initialViewType:"tree"})},onViewAttachmentDetails:async z=>{!(await saveDocument({onFormSave:s})).succeed||U({model:"ir.attachment",res_id:z.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}async function saveDocument({onFormSave:e}){const r=await(e==null?void 0:e());return r!=null&&r.succeed?{succeed:!0,currentId:r.id}:{succeed:!1,currentId:void 0}}const LinkInput=e=>{const{ooui:r,value:a,onChange:o,valueValidator:s,linkPrefix:l=""}=e,{id:u,readOnly:c,required:d}=r,f=d&&!c?Config.requiredClass:void 0,p=React$n.useContext(FormContext$2),{elementHasLostFocus:m}=p||{},[h,g]=React$n.useState(!1),[v,C]=React$n.useState(!1);React$n.useEffect(()=>{c&&!h&&C(!1),!a&&!c&&(g(!0),C(!0))},[h,c]);const S=x=>{o==null||o(x.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[c?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:h?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.CheckOutlined,{}),onClick:()=>{s(a)&&(g(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.EditOutlined,{}),onClick:()=>{g(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:v?jsxRuntime.jsx(antd.Input,{id:u,onChange:S,className:f,value:a,onBlur:()=>{s(a)&&(g(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${l}${a}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:a})})]})},Url=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(LinkInput,{ooui:r,valueValidator:o=>o?isURL(o):!1})})},Email=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(LinkInput,{ooui:r,linkPrefix:"mailto:",valueValidator:o=>o?isEmail(o):!1})})},GoToResourceModal=e=>{const{visible:r,onIdSubmitted:a,onCancel:o,isSearching:s}=e,{t:l}=React$n.useContext(LocaleContext);function u(c){a(c.id)}return jsxRuntime.jsx(antd.Modal,{title:l("goToResourceId"),centered:!0,visible:r,footer:null,destroyOnClose:!0,onCancel:o,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:u,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:l("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(AntIcons.CloseOutlined,{}),htmlType:"button",onClick:o,disabled:s,children:l("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(AntIcons.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:l("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:r=0,...a}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[r>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:r})}),jsxRuntime.jsx(ButtonWithTooltip,{...a,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:r}=React$n.useContext(LocaleContext),{availableViews:a,currentView:o,setCurrentView:s,searchParams:l,searchVisible:u,setSearchVisible:c,graphIsLoading:d,previousView:f,setPreviousView:p}=React$n.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(AntIcons.FilterOutlined,{style:{color:u?"white":void 0}}),tooltip:r("advanced_search"),type:u?"primary":"default",onClick:()=>{c==null||c(!u)},disabled:d,badgeNumber:l==null?void 0:l.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:r("refresh"),disabled:d,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:o,availableViews:a,onChangeView:m=>{p==null||p(o),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:r,children:a}=e,{title:o,currentView:s,currentId:l,currentItemIndex:u,results:c,totalItems:d,selectedRowItems:f}=React$n.useContext(ActionViewContext),{t:p}=React$n.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return l?d===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:l}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",u===void 0?1:u+1," /"," ",c.length," ",p("of")," ",d," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:l}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(h=>h.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:r||o}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:a})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:r,visible:a,model:o,context:s,domain:l,formView:u,treeView:c}=e,d=React$n.useRef(),f=React$n.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:h=void 0,results:g=void 0,setSelectedRowItems:v=void 0,setSearchParams:C=void 0,searchVisible:S=!0,setSearchVisible:x=void 0,sorter:y=void 0,setSorter:w=void 0,setTotalItems:T=void 0,setSearchTreeNameSearch:E=void 0,setTreeIsLoading:O=void 0,limit:G,setLimit:P,searchParams:M,searchValues:L,setSearchValues:W,currentView:B}=f||{},[N,J]=React$n.useState(!0);React$n.useEffect(()=>{var ne;(ne=d.current)==null||ne.refresh()},[M]),React$n.useEffect(()=>{r.view_id!==B.view_id&&J(!0)},[B]);const{clear:U,searchFilterLoading:H,searchError:K,offset:re,tableRefreshing:ie}=useSearch({model:o,setSearchTreeNameSearch:E,setSelectedRowItems:v,searchParams:M,setSearchValues:W,setSearchParams:C,setSearchVisible:x,setTreeIsLoading:O,context:s,formView:u,treeView:c,sorter:y,setSorter:w,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:g,domain:l,currentId:h,setActionViewTotalItems:T,limit:G,setLimit:P});return!a||!r?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:r.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{d.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...c.fields,...u.fields},searchFields:mergeSearchFields([u.search_fields,c.search_fields]),limit:G,onClear:U,offset:re,isSearching:H,onSubmit:ne=>{J(!1),C==null||C(ne.params),x==null||x(!1)},searchError:K,searchVisible:S,searchValues:L,showLimitOptions:!1}),ie?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:d,view_id:r.view_id,model:o,context:s,domain:mergeParams(M||[],l),limit:N?G:void 0,manualIds:N?g==null?void 0:g.map(ne=>ne.id):void 0})]})},FormActionView=e=>{const{visible:r,formRef:a,model:o,currentId:s,domain:l,formView:u,context:c,defaultValues:d,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:h}=e;return r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:u==null?void 0:u.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:a,model:o,defaultValues:d,forcedValues:f,formView:u,actionDomain:l,id:s,parentContext:c,onSubmitSucceed:(g,v)=>{p.findIndex(S=>S.id===g)===-1&&(p.push(v),m(p),h(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:r,disabled:a=!1,searchText:o}=e,{t:s}=React$n.useContext(LocaleContext),[l]=antd.Form.useForm(),[u,c]=React$n.useState(!1);function d(p){r(p.search)}React$n.useEffect(()=>{l.setFieldsValue({search:o})},[o]);function f(){c(!1),l.setFieldsValue({search:void 0}),r(void 0)}return jsxRuntime.jsx(antd.Form,{form:l,onFinish:d,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:a,onChange:p=>{c(p.target.value.length>0)},suffix:(u||o&&o.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(AntIcons.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:a,children:s("search")})})]})})}function TreeActionBar(e){var ae;const{availableViews:r,currentView:a,setCurrentView:o,selectedRowItems:s,setRemovingItem:l,removingItem:u,duplicatingItem:c,setDuplicatingItem:d,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:h,searchParams:g,searchVisible:v,setSearchVisible:C,setSearchTreeNameSearch:S,searchTreeNameSearch:x,treeIsLoading:y,setPreviousView:w,previousView:T,results:E,limit:O,totalItems:G}=React$n.useContext(ActionViewContext),{parentContext:P={},treeExpandable:M,toolbar:L}=e,{t:W,lang:B}=React$n.useContext(LocaleContext),N=React$n.useContext(ContentRootContext),{processAction:J}=N||{},[U,H]=React$n.useState(!1),K=x!==void 0&&x.trim().length>0;function re(){showDialog$9({confirmMessage:W("confirmRemove"),lang:B,onOk:()=>{ie()}})}async function ie(){var oe;try{l==null||l(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(ce=>ce.id)}),m==null||m(void 0),h==null||h(void 0),(oe=p==null?void 0:p.current)==null||oe.refreshResults()}catch(ce){showDialog$8(ce)}finally{l==null||l(!1)}}async function ne(){var oe;try{d==null||d(!0);const ce=s[0].id;await ConnectionProvider.getHandler().duplicate({id:ce,model:f,context:{...P}})&&((oe=p==null?void 0:p.current)==null||oe.refreshResults())}catch(ce){showDialog$8(ce)}finally{d==null||d(!1)}}function Q(oe){J==null||J({actionData:oe,values:{active_id:s==null?void 0:s.map(ce=>ce.id)[0],active_ids:s==null?void 0:s.map(ce=>ce.id)},fields:{},context:{...P,active_id:s==null?void 0:s.map(ce=>ce.id)[0],active_ids:s==null?void 0:s.map(ce=>ce.id)},onRefreshParentValues:()=>{var ce;(ce=p==null?void 0:p.current)==null||ce.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[M?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:c||u||y,searchText:x,onSearch:oe=>{oe&&oe.trim().length>0?S==null||S(oe):S==null||S(void 0)}}),!M&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(AntIcons.FilterOutlined,{style:{color:v?"white":void 0}}),tooltip:W("advanced_search"),type:v?"primary":"default",onClick:()=>{C==null||C(!v)},disabled:c||u||y,badgeNumber:g==null?void 0:g.length}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:y}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.CopyOutlined,{}),tooltip:W("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||c||y,loading:c,onClick:ne}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.DeleteOutlined,{}),tooltip:W("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||y,loading:u,onClick:re}),separator$1()]}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.InfoCircleOutlined,{}),tooltip:W("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||y,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,W)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:W("refresh"),disabled:c||u||y,loading:!1,onClick:()=>{var oe;(oe=p==null?void 0:p.current)==null||oe.refreshResults()}}),!M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:oe=>{w==null||w(a),o==null||o(oe)},previousView:T,disabled:y})]}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||y,tooltip:W("actions"),items:L==null?void 0:L.action,onItemClick:oe=>{!oe||Q(oe)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||y,tooltip:W("reports"),items:L==null?void 0:L.print,onItemClick:oe=>{!oe||Q({...oe,datas:{...oe.datas||{},ids:s.map(ce=>ce.id)}})}}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(AntIcons__default.default,{component:()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24",strokeWidth:"1.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),jsxRuntime.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),jsxRuntime.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:W("export"),items:[{id:"print_screen",name:W("printScreen")},{id:"export",name:W("advancedExport")}],onItemClick:oe=>{if(oe.id==="print_screen"){let ce=(s==null?void 0:s.map(he=>he.id))||[];ce.length===0&&(ce=(E==null?void 0:E.map(he=>he.id))||[]),Q({id:-1,model:f,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:f,ids:ce}});return}H(!0)},disabled:c||u||y||K}),jsxRuntime.jsx(ExportModal,{visible:U,locale:B,onClose:()=>H(!1),model:f,domain:mergeParams(((ae=p==null?void 0:p.current)==null?void 0:ae.getDomain())||[],g||[]),limit:O,totalRegisters:G||0,selectedRegistersToExport:s,visibleRegisters:(E==null?void 0:E.length)||0,context:P})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:r,searchTreeRef:a,model:o,context:s,formView:l,treeView:u,domain:c,setCurrentItemIndex:d,results:f,setCurrentId:p,setCurrentView:m,availableViews:h,searchTreeNameSearch:g}=e,{currentView:v,setPreviousView:C}=React$n.useContext(ActionViewContext);return r?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:u==null?void 0:u.toolbar,parentContext:s,treeExpandable:(u==null?void 0:u.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:a,rootTree:!0,model:o,parentContext:s,nameSearch:g,formView:l,treeView:u,domain:c,onRowClicked:S=>{const{id:x}=S;p(x);const y=f.findIndex(T=>T.id===x);C==null||C(v),d(y);const w=h.find(T=>T.type==="form");m(w)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[r,a]=React$n.useState(!1),[o,s]=React$n.useState(!1),{children:l,dashboardRef:u,openAction:c}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:r,setIsLoading:a,dashboardRef:u,openAction:c,moveItemsEnabled:o,setMoveItemsEnabled:s},children:l})};function DashboardActionBar(){const{isLoading:e,dashboardRef:r,moveItemsEnabled:a,setMoveItemsEnabled:o}=React$n.useContext(DashboardActionContext),{t:s}=React$n.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.BorderOuterOutlined,{style:{color:a?"white":void 0}}),type:a?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{o(!a)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{r==null||r.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(AntIcons.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{r==null||r.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:r}=e,a=React$n.useRef(),o=React$n.useContext(TabManagerContext),{openShortcut:s}=o||{};return r?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:a,openAction:l=>{s(l)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:a,model:r.model,id:r.id,context:r==null?void 0:r.context,configAction:r==null?void 0:r.configAction})]}):null};function ActionView(e,r){const{domain:a,model:o,context:s,views:l,title:u,setCanWeClose:c,tabKey:d,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:h=!1,action_id:g,action_type:v,treeExpandable:C=!1,limit:S}=e,[x,y]=React$n.useState(),[w,T]=React$n.useState([]),[E,O]=React$n.useState(!0),G=h||void 0,[P,M]=React$n.useState(G),[L,W]=React$n.useState([]),[B,N]=React$n.useState(),[J,U]=React$n.useState([]),[H,K]=React$n.useState(),[re,ie]=React$n.useState(0),[ne,Q]=React$n.useState(!1),[ae,oe]=React$n.useState(!1),[ce,he]=React$n.useState(),{t:z}=React$n.useContext(LocaleContext),te=React$n.useRef(),me=React$n.useRef(),ge=React$n.useContext(TabManagerContext),{setCurrentView:Te,setCurrentId:D,tabs:I,activeKey:pe,openAction:Re}=ge||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",qe=>{qe.preventDefault(),et()},[pe,I,x,B,J]);function Oe(qe){M(qe),D==null||D(qe)}function ve(qe){y(qe),Te==null||Te(qe)}React$n.useImperativeHandle(r,()=>({canWeClose:Ae}));const Pe=async()=>{O(!0);const qe=[];for(const _t of l){const[qt,Pt]=_t;let Ze;try{Pt!=="dashboard"&&(Ze=await ConnectionProvider.getHandler().getView({model:o,type:Pt,id:qt,context:s}))}catch(Yt){console.error(`${o} - ${Pt}\xA0- ${JSON.stringify(Yt,null,2)}`);continue}switch(Pt){case"dashboard":{const Yt=l.find(it=>{const[,xt]=it;return xt==="form"});let tr;Yt&&(tr={action_id:g,action_type:v,name:u,res_id:s.active_id,res_model:o,view_id:Yt[0],view_type:Yt[1]}),qe.push({type:"dashboard",id:s.active_id,model:o,context:s,configAction:tr});break}case"form":{qe.push({...Ze,type:Pt});break}case"tree":{qe.push({...Ze,isExpandable:C,type:Pt});break}case"graph":{qe.push({...Ze,type:Pt});break}}}let Ht;!f&&qe.find(_t=>_t.type==="tree")?Ht=qe.find(qt=>qt.type==="tree"):f?Ht=qe.find(qt=>f.id?qt.type===f.type&&qt.view_id===f.id:qt.type===f.type):Ht=qe.find(qt=>qt.type==="form"),Ht||showDialog$8(`Error determining the first view to show.
311
311
  Please, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action`),ve(Ht),T(qe),O(!1)};c({tabKey:d,canWeClose:Ae}),React$n.useEffect(()=>{const qe=w.find(_t=>_t.type==="tree"),Ht=w.find(_t=>f.id?_t.type===f.type&&_t.view_id===f.id:_t.type===f.type);ve(Ht||qe),h?D==null||D(G):(Oe(void 0),N(void 0)),Pe()},[o,l,h]),React$n.useEffect(()=>{pe===d&&(D==null||D(P),Te==null||Te(x))},[I,pe]);async function Ae(){return x.type==="form"?await te.current.cancelUnsavedChanges():!0}async function et(){pe===d&&(x.type==="form"&&!await te.current.cancelUnsavedChanges()||Q(!0))}async function Xt(qe){var Pt;oe(!0);const Ht=J.findIndex(Ze=>Ze.id===qe);let _t;if(Ht===-1){try{_t=(Pt=await ConnectionProvider.getHandler().readObjects({model:o,ids:[qe],context:s}))==null?void 0:Pt[0]}catch{}if(!_t){oe(!1),Q(!1),showDialog$7(z("idNotFound"));return}}else _t=J[Ht];oe(!1),Q(!1);const qt=l.find(Ze=>Ze[1]==="form");Re({domain:[],context:s,model:o,views:l,title:u,target:"current",initialView:{id:qt==null?void 0:qt[0],type:"form"},action_id:g,action_type:v,res_id:qe})}function Zt(){return w.map(qe=>{switch(qe.type){case"form":return jsxRuntime.jsx(FormActionView,{formRef:te,currentId:P,visible:x.type===qe.type&&x.view_id===qe.view_id,formView:qe,model:o,context:s,domain:a,defaultValues:p,forcedValues:m,results:J,setResults:U,setCurrentItemIndex:N},`${qe.type}-${qe.view_id}`);case"tree":return jsxRuntime.jsx(TreeActionView,{visible:x.type===qe.type&&x.view_id===qe.view_id,limit:S,model:o,context:s,domain:a,formView:w.find(Ht=>Ht.type==="form"),treeView:qe,searchTreeRef:me,searchTreeNameSearch:ce,availableViews:w,results:J,setCurrentItemIndex:N,setCurrentId:Oe,setCurrentView:ve},`${qe.type}-${qe.view_id}`);case"graph":return jsxRuntime.jsx(GraphActionView,{visible:x.type===qe.type&&x.view_id===qe.view_id,viewData:qe,model:o,context:s,domain:a,treeView:w.find(Ht=>Ht.type==="tree"),formView:w.find(Ht=>Ht.type==="form")},`${qe.type}-${qe.view_id}`);case"dashboard":return jsxRuntime.jsx(DashboardActionView,{dashboardData:qe},`${qe.type}-${qe.view_id}`)}})}function er(){if(P===void 0&&x.type==="form")te.current.clearAndReload();else{Oe(void 0);const qe=w.find(Ht=>Ht.type==="form");ve(qe)}}return E?jsxRuntime.jsx(antd.Spin,{}):x?jsxRuntime.jsxs(ActionViewProvider,{title:u,currentView:x,setCurrentView:ve,availableViews:w,formRef:te,searchTreeRef:me,onNewClicked:er,currentId:P,setCurrentId:Oe,setCurrentItemIndex:N,currentItemIndex:B,results:J,setResults:U,currentModel:o,sorter:H,setSorter:K,totalItems:re,setTotalItems:ie,selectedRowItems:L,setSelectedRowItems:W,setSearchTreeNameSearch:he,searchTreeNameSearch:ce,goToResourceId:Xt,limit:S,children:[Zt(),jsxRuntime.jsx(GoToResourceModal,{visible:ne,onIdSubmitted:Xt,isSearching:ae,onCancel:()=>{Q(!1)}})]}):null}const ActionView$1=React$n.forwardRef(ActionView);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e=="string"&&REGEX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=(byteToHex[e[r+0]]+byteToHex[e[r+1]]+byteToHex[e[r+2]]+byteToHex[e[r+3]]+"-"+byteToHex[e[r+4]]+byteToHex[e[r+5]]+"-"+byteToHex[e[r+6]]+byteToHex[e[r+7]]+"-"+byteToHex[e[r+8]]+byteToHex[e[r+9]]+"-"+byteToHex[e[r+10]]+byteToHex[e[r+11]]+byteToHex[e[r+12]]+byteToHex[e[r+13]]+byteToHex[e[r+14]]+byteToHex[e[r+15]]).toLowerCase();if(!validate(a))throw TypeError("Stringified UUID is invalid");return a}function v4(e,r,a){e=e||{};var o=e.random||(e.rng||rng)();if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,r){a=a||0;for(var s=0;s<16;++s)r[a+s]=o[s];return r}return stringify(o)}async function fetchAction({actionId:e,rootContext:r={},globalValues:a={}}){const o="ir.actions.act_window",s=`${o},${e}`,l=await ConnectionProvider.getHandler().getActionData({action:s,context:r}),u=ooui.parseContext({context:l.context,values:a,fields:{}}),c=l.domain?await ConnectionProvider.getHandler().evalDomain({domain:l.domain,values:a,context:{...r,...u}}):[],{res_model:d,views:f,name:p,limit:m,view_type:h}=l,g=h==="tree",v=[];for(const y of f){const[w,T]=y;if(w)v.push(y);else{const{view_id:E}=await ConnectionProvider.getHandler().getView({model:d,type:T,id:w,context:{...r,...u}});v.push([E,T])}}const[C,S]=v[0],x={id:C,type:S};return{title:p,actionId:e,actionType:o,key:v4(),views:f,model:d,context:{...r,...u},domain:c,initialView:x,limit:m,treeExpandable:g}}const styles$1="",styles="",ResponsiveReactGridLayout=reactGridLayout.WidthProvider(reactGridLayout.Responsive),DashboardGrid=e=>{const{children:r=[],onPositionItemsChanged:a}=e,o=React__default.default.Children.map(r,s=>{const{parms:l,id:u}=s.props;return jsxRuntime.jsx("div",{"data-grid":l,children:s},u)});return jsxRuntime.jsx(ResponsiveReactGridLayout,{className:"layout",cols:{lg:12,md:10,sm:6,xs:4,xxs:2},draggableHandle:".draggable-head",rowHeight:30,onLayoutChange:s=>{a==null||a(s.map(l=>({id:parseInt(l.i.replace(".$",""),10),x:l.x,y:l.y,w:l.w,h:l.h})))},children:o})},{Text}=antd.Typography,DashboardGridItem=e=>{const{id:r,title:a,children:o,action:s,openAction:l}=e;return jsxRuntime.jsxs("div",{className:"shadow-md rounded",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #eee",backgroundColor:"white"},children:[jsxRuntime.jsxs(antd.Row,{className:"bg-blueGray-100",align:"middle",style:{borderBottom:"1px solid #ddd"},wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"auto",className:"draggable-head",style:{fontWeight:"bold",padding:"0.5rem",cursor:"grab",overflow:"hidden"},children:jsxRuntime.jsx(Text,{ellipsis:!0,children:a})}),s&&jsxRuntime.jsx(antd.Col,{flex:"25px",style:{padding:"0.5rem"},children:jsxRuntime.jsx(antd.Row,{justify:"end",align:"middle",children:jsxRuntime.jsx(AntIcons.ExportOutlined,{style:{cursor:"pointer"},onClick:()=>{l==null||l(s)}})})})]}),o]})},DEFAULT_SEARCH_LIMIT=80;function DashboardTree(e){const{action:r,model:a,view_id:o,onRowClicked:s,domain:l=[],visible:u=!0,parentContext:c={}}=e,[d,f]=React$n.useState(!1),[p,m]=React$n.useState(!1),[h,g]=React$n.useState(),[v,C]=React$n.useState(),[S,x]=React$n.useState(),[y,w]=React$n.useState(1),[T,E]=React$n.useState(0),O=React$n.useRef(DEFAULT_SEARCH_LIMIT),G=React$n.useRef([]),[P,M]=React$n.useState(0),[L,W]=React$n.useState([]),[B,N]=React$n.useState(void 0),[J,U]=React$n.useState(),[H,K]=React$n.useState(),[re,ie]=React$n.useState(),[ne,Q]=React$n.useState(!1),ae=React$n.useRef([]),oe=D=>{Q(!0),w(D),E((D-1)*O.current)},ce=async()=>{const D=ae.current.length>0?ae.current:l,I=mergeParams(G.current,D),{colors:pe}=getTree(v),{totalItems:Re,results:Oe,attrsEvaluated:ve}=await ConnectionProvider.getHandler().searchForTree({params:I,limit:O.current,offset:T,model:h,fields:v.fields,context:c,attrs:pe&&{colors:pe}}),Pe=await Re;M(Pe),N(getColorMap(ve));const Ae=sortResults({resultsToSort:Oe,sorter:J,fields:{...v.fields,...S.fields}});W(Ae)},he=async()=>{try{Q(!0),await ce()}catch(D){K(JSON.stringify(D))}finally{Q(!1)}};React$n.useEffect(()=>{!p||u&&he()},[y,T,p,u]);const z=async D=>{m(!1),f(!0),ie(void 0);try{D==="action"?await te():await me(),m(!0)}catch(I){ie(I)}finally{f(!1)}},te=async()=>{const D=await ConnectionProvider.getHandler().getViewsForAction({action:r,context:c});ae.current=D.domain,x(D.views.get("form")),C(D.views.get("tree")),g(D.model),O.current=D.limit},me=async()=>{g(a);const D=await ConnectionProvider.getHandler().getView({model:a,type:"form",context:c});x(D);const I=await ConnectionProvider.getHandler().getView({model:a,type:"tree",id:o,context:c});C(I)};React$n.useEffect(()=>{r?z("action"):a&&z("model")},[r,a]);const ge=D=>{const{id:I}=D;s({id:I,model:h,treeView:v})},Te=()=>!v||!S?null:jsxRuntime.jsxs("div",{style:{overflowY:"scroll"},children:[H&&jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:H,type:"error",banner:!0}),jsxRuntime.jsx(Tree,{showPagination:!1,total:P,limit:O.current,page:y,treeView:v,results:L,onRequestPageChange:oe,loading:ne,onRowClicked:ge,colorsForResults:B,sorter:J,onChangeSort:D=>{U==null||U(D);const I=sortResults({resultsToSort:L,sorter:D,fields:{...v.fields,...S.fields}});W(I)},context:c})]});return re?jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:re,type:"error",banner:!0}):d?jsxRuntime.jsx(antd.Spin,{style:{padding:"2rem"}}):Te()}const DashboardForm=e=>{const{model:r}=e,[a,o]=React$n.useState();React$n.useEffect(()=>{s()},[r]);async function s(){const l=await ConnectionProvider.getHandler().search({params:[],model:r,limit:1});l.length>0&&o(l[0].id)}return jsxRuntime.jsx("div",{style:{padding:"0.5rem",overflowY:"scroll"},children:jsxRuntime.jsx(Form$1,{...e,model:r,id:a,readOnly:!0})})},itemsField="line_ids";function Dashboard(e,r){const{model:a,context:o={},id:s,configAction:l}=e,[u,c]=React$n.useState([]),[d,f]=React$n.useState(!1),[p,m]=React$n.useState(),{setIsLoading:h,openAction:g,moveItemsEnabled:v}=React$n.useContext(DashboardActionContext),C=React$n.useRef(),S=React$n.useRef();React$n.useEffect(()=>{x()},[a,s,o]),React$n.useImperativeHandle(r,()=>({refresh:()=>{x()},configDashboard:G}));async function x(){f(!0),h(!0),m(void 0);try{const P=await y(),M=await T(P),L=P.fields[itemsField].relation,W=M[itemsField].items;S.current=P.fields;const B=await w({items:W,model:L,context:o}),N=await E(B);c(N),f(!1),h(!1)}catch(P){m(JSON.stringify(P))}}async function y(){return await ConnectionProvider.getHandler().getView({model:a,type:"form",context:o})}async function w({items:P,model:M,context:L}){return C.current=(await ConnectionProvider.getHandler().getView({model:M,type:"form",context:L})).fields,await readObjectValues({treeFields:C.current,formFields:C.current,model:M,items:P,context:L})}async function T(P){return(await ConnectionProvider.getHandler().readObjects({model:a,ids:[s],fields:P.fields,context:o}))[0]}async function E(P){const M=[];for(const L of P){const{values:W}=L;if(W.action_id&&W.action_id.length>0){const B=parseInt(W.action_id[0],10),N=await fetchAction({actionId:B,rootContext:o});M.push({...L,actionData:N})}}return M}async function O(P){if(!v)return;const M=P.filter(N=>{const J=u.find(H=>H.id===N.id);if(!J)return!1;if(!J.position)return!0;const U={...JSON.parse(J.position.replace(/'/g,'"')),id:J.id};return JSON.stringify(N)!==JSON.stringify(U)});if(M.length===0)return;const W=u.filter(N=>M.map(J=>J.id).includes(N.id)).map(N=>{const J={...M.find(U=>U.id===N.id)};return delete J.id,{...N},{...N,operation:"pendingUpdate",values:{...N.values,position:JSON.stringify(J).replace(/"/g,"'")}}}),B={fields:C.current,items:W};await ConnectionProvider.getHandler().update({model:a,id:s,values:{[itemsField]:B},fields:S.current,context:o})}async function G(){g(l)}return p?jsxRuntime.jsx(antd.Alert,{className:"mt-10 mb-20",message:p,type:"error",banner:!0}):d?jsxRuntime.jsx(AntIcons.LoadingOutlined,{}):jsxRuntime.jsx(DashboardGrid,{onPositionItemsChanged:O,children:u.map((P,M)=>{const{actionData:L,values:W}=P,{position:B,id:N}=W,{actionId:J,actionType:U,key:H,title:K,views:re,model:ie,context:ne,domain:Q,initialView:ae,limit:oe}=L;let ce={};try{ce=JSON.parse(B.replace(/'/g,'"'))}catch{ce={x:M*2,y:0,w:2,h:3}}let he=null;if((ae==null?void 0:ae.type)==="graph")he=jsxRuntime.jsx(Graph,{view_id:re.filter(me=>me[1]==="graph")[0][0],model:ie,context:ne,domain:Q,limit:oe});else if((ae==null?void 0:ae.type)==="form")he=jsxRuntime.jsx(DashboardForm,{model:ie,actionDomain:Q});else if((ae==null?void 0:ae.type)==="tree")he=jsxRuntime.jsx(DashboardTree,{model:ie,domain:Q,view_id:re.filter(me=>me[1]==="tree")[0][0],onRowClicked:me=>{const ge=re.find(Te=>{const[,D]=Te;return D==="form"});if(ge){const[Te,D]=ge,{actionId:I,actionType:pe,title:Re,model:Oe}=L,ve={action_id:I,action_type:pe,name:Re,res_id:me.id,res_model:Oe,view_id:Te,view_type:D};g(ve)}}});else if(ae!==void 0){const me=ae&&Array.isArray(ae.id)?{...ae,id:ae.id[0]}:ae;he=jsxRuntime.jsx(ActionView$1,{action_id:J,action_type:U,tabKey:H,title:K,views:re,model:ie,context:ne,domain:Q,setCanWeClose:()=>{},initialView:me,limit:oe})}let z;const te=re.find(me=>{const[,ge]=me;return ge==="tree"});if(te){const[me,ge]=te,{actionId:Te,actionType:D,title:I,model:pe}=L;z={action_id:Te,action_type:D,name:I,res_id:!1,res_model:pe,view_id:me,view_type:ge}}return jsxRuntime.jsx(DashboardGridItem,{id:N,title:K,parms:ce,action:z,openAction:g,children:he},N)})})}const Dashboard$1=React$n.forwardRef(Dashboard),Tag=e=>jsxRuntime.jsx(Field$1,{...e,children:jsxRuntime.jsx(TagInput,{...e})}),TagInput=e=>{const{ooui:r,value:a}=e;if(!a)return null;const o=r.colors==="auto"?colorFromString(a):r.colors[a];return jsxRuntime.jsx(antd.Tag,{color:o,children:r.selectionValues.get(a)})},MultiCheckbox=e=>{const{ooui:r}=e;return jsxRuntime.jsx(Field$1,{type:"array",...e,children:jsxRuntime.jsx(MultiCheckboxInput,{ooui:r})})},MultiCheckboxInput=e=>{const{value:r,ooui:a,onChange:o}=e,{items:s=[]}=r||{},l=s.filter(P=>P.operation!=="pendingRemove").map(P=>P.id),[u,c]=React$n.useState([]),[d,f]=React$n.useState(),[p,m]=React$n.useState(!1),{relation:h,context:g,readOnly:v,field:C,columns:S}=a,x=React$n.useContext(FormContext$2),{getContext:y}=x||{};useDeepCompareEffect__default.default(()=>{T()},[s]);const w=P=>{o==null||o({items:P})};async function T(){m(!0);let P=[];if(a.domain){const M=await ConnectionProvider.getHandler().evalDomain({domain:a.domain,values:transformPlainMany2Ones({fields:x==null?void 0:x.getFields(),values:x.getPlainValues()}),fields:x==null?void 0:x.getFields(),context:x.getContext()});P=[...P,...M]}try{const L=(await ConnectionProvider.getHandler().search({model:h,params:P,fields:[C],context:{...y==null?void 0:y(),...g}})).map(W=>{const B=W[C];let N=B;return Array.isArray(B)&&(N=B[1]),{label:N,value:W.id}});c(L)}catch(M){f(M)}finally{m(!1)}if(d)return jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:d,type:"error",banner:!0})}const E=()=>{G(u.map(P=>P.value))},O=()=>{G([])},G=P=>{const M=s.map(W=>P.includes(W.id)?W.operation=="pendingRemove"?{...W,operation:"original"}:W:{id:W.id,operation:"pendingRemove"}),L=M.map(W=>W.id);P.filter(W=>!L.includes(W)).map(W=>{M.push({id:W,operation:"pendingLink"})}),w(M)};return p&&u.length===0?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsx(antd.Checkbox.Group,{value:u.length?l:[],disabled:v,onChange:G,style:{width:"100%"},children:jsxRuntime.jsx(antd.Row,{children:u.map(P=>jsxRuntime.jsx(antd.Col,{span:Math.floor(24/S),children:jsxRuntime.jsx(antd.Checkbox,{value:P.value,children:P.label})}))})}),!v&&jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{onClick:E,disabled:l.length==u.length,children:"Check all"}),jsxRuntime.jsx(antd.Button,{onClick:O,disabled:l.length===0,children:"Uncheck all"})]})]})})},Radio=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,type:"any",...e,children:jsxRuntime.jsx(SelectionInput,{...e})})},SelectionInput=e=>{const{ooui:r,onChange:a,value:o}=e,{selectionValues:s,readOnly:l,direction:u}=r,c=Array.from(s.entries()),d=c&&c.length&&c.map(f=>{const[p,m]=f;return jsxRuntime.jsx(antd.Radio,{value:p,children:m},p)});return jsxRuntime.jsx(antd.Radio.Group,{disabled:l,onChange:a,value:o,children:jsxRuntime.jsx(antd.Space,{direction:u,children:d})})},Switch=e=>{const{ooui:r}=e,{id:a,readOnly:o,required:s}=r;return jsxRuntime.jsx(Field$1,{...e,valuePropName:"checked",children:jsxRuntime.jsx(SwitchInput,{id:a,readOnly:o,required:s})})},SwitchInput=e=>{const{required:r,readOnly:a,...o}=e;return jsxRuntime.jsx("div",{className:"flex flex-row",children:jsxRuntime.jsx(antd.Switch,{disabled:a,...o})})},Steps=e=>{const{ooui:r}=e,{required:a}=r;return jsxRuntime.jsx(Field$1,{required:a,type:"any",...e,children:jsxRuntime.jsx(StepsInput,{...e})})},StepsInput=e=>{const{ooui:r,value:a}=e,{selectionValues:o,errorField:s}=r,l=React$n.useContext(FormContext$2),u=Array.from(o.entries()),c=u.map(p=>p[0]).indexOf(a);let d="process",f="";return s&&(f=l.getFieldValue(s),f&&(d="error")),jsxRuntime.jsx(antd.Steps,{current:c,status:d,children:u.map((p,m)=>jsxRuntime.jsx(antd.Steps.Step,{title:p[1],description:m===c&&d==="error"?f:null}))})},CodeEditor=e=>{const{ooui:r}=e,{lang:a,height:o}=r,s=React$n.useContext(FormContext$2),{elementHasLostFocus:l}=s||{},u=c=>{c.onDidBlurEditorWidget(l)};return jsxRuntime.jsx(Field$1,{...e,children:jsxRuntime.jsx(Editor__default.default,{defaultLanguage:a||"",height:o||300,onMount:u})})},{Content}=antd.Layout,{Title}=antd.Typography;function Welcome(){const{t:e}=React$n.useContext(LocaleContext);return jsxRuntime.jsx(Content,{className:"m-5 select-none",children:jsxRuntime.jsx(Title,{level:5,children:e("welcome")})})}function RootView(e,r){const{children:a,globalValues:o={},rootContext:s={},lang:l}=e,[u,c]=React$n.useState("welcome"),[d,f]=React$n.useState([{title:tForLang("welcome",l),key:"welcome",closable:!0,content:jsxRuntime.jsx(Welcome,{})}]),p=React$n.useRef(new Map),m=React$n.useRef();React$n.useImperativeHandle(r,()=>({retrieveAndOpenAction:v,openShortcut:x}));function h(T){if(T===u){const E=d.findIndex(O=>O.key===T);d[E-1]&&c(d[E-1].key),d[E+1]&&c(d[E+1].key)}f(d.filter(E=>E.key!==T)),p.current.delete(T)}function g({tabKey:T,canWeClose:E}){p.current.set(T,E)}async function v({action:T,values:E,forced_values:O,initialViewType:G,res_id:P,domain:M=[]}){const L=await ConnectionProvider.getHandler().getActionData({action:T,context:s});if(L.type==="ir.actions.wizard"){showDialog$8("Action type not supported");return}const[W,B]=T.split(","),N=parseInt(B),J=ooui.parseContext({context:L.context,values:o,fields:{}}),U=L.domain?await ConnectionProvider.getHandler().evalDomain({domain:L.domain,values:o,context:{...s,...J}}):[],{res_model:H,views:K,name:re,target:ie,view_type:ne,limit:Q}=L,ae=ne==="tree",oe=[];for(const he of K){const[z,te]=he;if(z)oe.push(he);else if(te==="dashboard")oe.push([void 0,"dashboard"]);else{const{view_id:me}=await ConnectionProvider.getHandler().getView({model:H,type:te,id:z,context:{...s,...J}});oe.push([me,te])}}let ce;if(G){const[he,z]=oe.find(([te,me])=>me===G);ce={id:he,type:z}}else{const[he,z]=oe[0];ce={id:he,type:z}}w({domain:[...U,...M],context:{...s,...J},model:H,views:oe,title:re,target:ie,initialView:ce,action_type:W,action_id:N,values:E,forced_values:O,res_id:P,treeExpandable:ae,limit:Q})}function C({title:T,content:E,key:O,action:G}){let P=[...d];d.length===1&&d[0].key==="welcome"&&(P=[...d.filter(M=>M.key!=="welcome")]),f([...P,{title:T,key:O,closable:!0,content:E,action:G}]),c(O)}async function S({relateData:T,fields:E,values:O,action_id:G,action_type:P}){const{res_model:M,context:L,domain:W,views:B,target:N,string:J,limit:U}=T,[H,K]=B[0],re={id:H,type:K},ie=ooui.parseContext({context:L,values:{...O,...o},fields:E}),ne=W?await ConnectionProvider.getHandler().evalDomain({domain:W,values:transformPlainMany2Ones({fields:E,values:{...O,...o}}),fields:E,context:{...s,...ie}}):[];w({model:M,target:N,views:B,context:{...s,...ie},domain:ne,title:J,initialView:re,action_id:G,action_type:P,limit:U})}async function x(T){const{action_id:E,action_type:O,res_id:G,view_id:P}=T,M=`${O},${E}`,L=await ConnectionProvider.getHandler().getActionData({action:M,context:s}),W=ooui.parseContext({context:L.context,values:o,fields:{}}),B=L.domain?await ConnectionProvider.getHandler().evalDomain({domain:L.domain,values:o,context:{...s,...W}}):[],{res_model:N,views:J,name:U,target:H,view_type:K,limit:re}=L,ie=K==="tree",ne=[];for(const ce of J){const[he,z]=ce;if(he)ne.push(ce);else if(z==="dashboard")ne.push([void 0,"dashboard"]);else{const{view_id:te}=await ConnectionProvider.getHandler().getView({model:N,type:z,id:he,context:{...s,...W}});ne.push([te,z])}}let Q,ae;if(P==null){const ce=ne.find(he=>he[0]===void 0);Q=void 0,ae=ce[1]}else[Q,ae]=ne.find(ce=>ce[0]===void 0?!1:ce[0]===P);const oe={id:Q,type:ae};w({domain:B,context:{...s,...W},model:N,views:ne,title:U,target:H,initialView:oe,action_id:E,action_type:O,res_id:G,treeExpandable:ie,limit:re})}async function y({model:T,values:E,forced_values:O,initialViewType:G,res_id:P,domain:M}){const L=await ConnectionProvider.getHandler().getActionStringForModel(T);await v({action:L,values:E,forced_values:O,initialViewType:G,res_id:P,domain:M})}async function w({domain:T,context:E,model:O,views:G,title:P,target:M,initialView:L,action_id:W,action_type:B,res_id:N,values:J,forced_values:U,treeExpandable:H=!1,limit:K}){const re=v4();if(M!=="current"){const ie=await ConnectionProvider.getHandler().getView({model:O,type:"form",id:L.type==="form"?L.id:void 0,context:{...s,...E}});m.current.openActionModal({domain:T,model:O,formView:ie,context:{...s,...E},actionData:{action_id:W,action_type:B,res_id:N,view_id:ie.view_id}})}else{const ie=L&&Array.isArray(L.id)?{...L,id:L.id[0]}:L;C({title:P,action:{id:W,type:B},content:jsxRuntime.jsx(ActionView$1,{action_id:W,action_type:B,tabKey:re,title:P,views:G,model:O,context:{...s,...E},domain:T,setCanWeClose:g,initialView:ie,res_id:N,formDefaultValues:J,formForcedValues:U,treeExpandable:H,limit:K}),key:re})}}return jsxRuntime.jsx(LocaleContextProvider,{lang:l,children:jsxRuntime.jsx(TabManagerProvider,{openShortcut:x,openAction:w,openRelate:S,openDefaultActionForModel:y,tabs:d,activeKey:u,onRemoveTab:async T=>{const E=p.current.get(T);(await(E==null?void 0:E())||u==="welcome")&&h(T)},onChangeTab:T=>{c(T)},children:jsxRuntime.jsx(ContentRootProvider$1,{ref:m,globalValues:o,children:a})})})}const RootView$1=React$n.forwardRef(RootView);function Tab(e){const{label:r,onClose:a,tabKey:o,isActive:s,onSelected:l}=e,u=s?"#ffffff":"#F1F5F9";return jsxRuntime.jsxs("div",{onClick:()=>{!s&&l(o)},style:{cursor:"pointer",height:40,paddingTop:7,paddingBottom:5,paddingLeft:10,paddingRight:10,backgroundColor:u,display:"inline-flex",flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",borderTopLeftRadius:8,borderTopRightRadius:8,marginLeft:2},children:[jsxRuntime.jsx("div",{style:{color:s?"#001529":"#ADB0B3",userSelect:"none",height:40,display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:5,paddingRight:5,marginBottom:2},children:r}),jsxRuntime.jsx("div",{style:{paddingLeft:5,height:40,display:"flex",justifyContent:"center",alignItems:"center"},children:jsxRuntime.jsx(AntIcons.CloseOutlined,{style:{color:s?"#001529":"#ADB0B3"},onClick:c=>{c.stopPropagation(),a(o)}})})]})}function TabSelector(){const e=React$n.useContext(TabManagerContext),{activeKey:r,tabs:a,onRemoveTab:o,onChangeTab:s}=e||{};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a.map(l=>jsxRuntime.jsx(Tab,{tabKey:l.key,label:l.title,onClose:o,isActive:r===l.key,onSelected:s},l.key))})}function TabContent(e){const{tab:r}=e,a=React$n.useContext(TabManagerContext),{activeKey:o}=a||{},s={display:"none"};return jsxRuntime.jsx("div",{style:r.key!==o?s:void 0,children:r.content})}const TabContent$1=React__default.default.memo(TabContent,()=>!0);function CurrentTabContent(){const e=React$n.useContext(TabManagerContext),{tabs:r}=e||{},a=(r==null?void 0:r.map(o=>jsxRuntime.jsx(TabContent$1,{tab:o},o.key)))||null;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a})}const FavouriteButton=e=>{const{onRetrieveShortcuts:r,onCheckIsFavourite:a,onAddFavourite:o,onRemoveFavourite:s}=e,[l,u]=React$n.useState(!1),[c,d]=React$n.useState(!1),[f,p]=React$n.useState([]),[m,h]=React$n.useState(!0),[g,v]=React$n.useState(),{t:C}=React$n.useContext(LocaleContext),S=React$n.useContext(TabManagerContext),{openShortcut:x,tabs:y,activeKey:w,currentView:T,currentId:E,openDefaultActionForModel:O}=S||{};React$n.useEffect(()=>{G()},[]),React$n.useEffect(()=>{L()},[y,w,T,E]);async function G(){try{h(!0);const U=await r();p(U)}catch(U){showDialog$8(U)}finally{h(!1)}}function P(U){const{key:H}=U,K=f.find(re=>re.id===Number(H));(K==null?void 0:K.action_type)!=="ir.actions.wizard"&&(K&&x(K),d(!1))}function M(U){U&&G(),d(U)}async function L(){if(!T)return;const U=y.find(Q=>Q.key===w),{id:H,type:K}=(U==null?void 0:U.action)||{};if(!H||!K){u(!1);return}const re=T.view_id;let ie=!1;T.type==="form"&&(ie=E||!1);const ne=await a({action_id:H,action_type:K,view_id:re,res_id:ie});ne!==!1&&v(ne),u(ne!==!1)}async function W(){d(!1),O==null||O({model:"ir.ui.view_sc"})}const B=jsxRuntime.jsxs(antd.Menu,{onClick:P,children:[jsxRuntime.jsxs("div",{style:{width:300,padding:5,display:"flex"},children:[jsxRuntime.jsx("div",{style:{paddingLeft:15,color:"#ccc"},children:C("favorites").toUpperCase()}),jsxRuntime.jsx("div",{style:{flexGrow:1,paddingLeft:10},children:jsxRuntime.jsx(antd.Tooltip,{title:C("edit_favorites"),children:jsxRuntime.jsx(AntIcons.EditOutlined,{style:{color:"#1890FF",cursor:"pointer"},onClick:W})})})]}),jsxRuntime.jsx(antd.Menu.Divider,{}),m?jsxRuntime.jsx(antd.Spin,{style:{padding:"1rem"}}):f.length>0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.map(U=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsx(N,{title:U.name,type:U.view_type})},U.id))}):jsxRuntime.jsx("div",{style:{width:300,padding:5,paddingLeft:15},children:C("no_favorites")})]});function N({title:U,type:H}){const K=H==="tree"?jsxRuntime.jsx(AntIcons.TableOutlined,{}):jsxRuntime.jsx(AntIcons.FormOutlined,{});return jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:K}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:U})]})}async function J(){if(l&&g)await s(g);else{if(!T)return;const U=y.find(ne=>ne.key===w),{id:H,type:K}=(U==null?void 0:U.action)||{},re=T.view_id;let ie=!1;if(!H||!K){u(!1);return}T.type==="form"&&(ie=E||!1),await o({action_id:H,action_type:K,view_id:re,res_id:ie})}await G(),u(!l)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Button,{type:l?"primary":"default",icon:l?jsxRuntime.jsx(AntIcons.StarFilled,{style:{color:"white"}}):jsxRuntime.jsx(AntIcons.StarOutlined,{}),style:{width:50},onClick:J}),jsxRuntime.jsx(antd.Dropdown,{overlay:B,onVisibleChange:M,visible:c,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(AntIcons.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:U=>U.preventDefault()})})]})};exports.ActionBar=FormActionBar,exports.Binary=Binary,exports.Boolean=Boolean$1,exports.Button=Button,exports.ButtonGroup=ButtonGroup,exports.Char=Char,exports.CodeEditor=CodeEditor,exports.ConnectionProvider=ConnectionProvider,exports.ContentRootProvider=ContentRootProvider$1,exports.CurrentTabContent=CurrentTabContent,exports.Dashboard=Dashboard$1,exports.DashboardGrid=DashboardGrid,exports.DashboardGridItem=DashboardGridItem,exports.Date=Date$1,exports.DateTime=DateTime,exports.Email=Email,exports.ExportModal=ExportModal,exports.FavouriteButton=FavouriteButton,exports.Float=Float,exports.FloatTime=FloatTime,exports.Form=Form$1,exports.FormModal=FormModal,exports.GraphIndicator=GraphIndicator,exports.Group=Group,exports.Image=Image,exports.Integer=Integer,exports.Label=Label,exports.Many2one=Many2one,exports.MultiCheckbox=MultiCheckbox,exports.Notebook=Notebook,exports.One2many=One2many,exports.ProgressBar=ProgressBar,exports.Radio=Radio,exports.Reference=Reference,exports.RootView=RootView$1,exports.SearchFilter=SearchFilter,exports.SearchModal=SearchModal,exports.SearchTree=SearchTree$1,exports.Selection=Selection,exports.Separator=Separator,exports.Steps=Steps,exports.Switch=Switch,exports.TabSelector=TabSelector,exports.Tag=Tag,exports.Tags=Tags,exports.Text=Text$2,exports.Tree=Tree,exports.Url=Url,exports.iconMapper=iconMapper,exports.showConfirmDialog=showDialog$9,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
312
312
  //# sourceMappingURL=react-ooui.umd.js.map